plugin-best-practices.dita 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <concept id="best-practices-pdf-customization-plugins">
  5. <title>Best practices for custom plug-ins</title>
  6. <titlealts>
  7. <navtitle>Best practices</navtitle>
  8. </titlealts>
  9. <shortdesc>Adhering to certain development practices will properly isolate your code from that of DITA Open Toolkit.
  10. This will make it easier to you to upgrade to new versions of DITA-OT when they are released.</shortdesc>
  11. <prolog>
  12. <metadata>
  13. <keywords>
  14. <indexterm>plug-ins<indexterm>best practices</indexterm></indexterm>
  15. <indexterm>upgrading<indexterm>best practices</indexterm></indexterm>
  16. <indexterm>XSLT<indexterm>best practices</indexterm></indexterm>
  17. </keywords>
  18. </metadata>
  19. </prolog>
  20. <conbody>
  21. <ul>
  22. <li>
  23. <p>Use a properly-constructed DITA-OT plug-in.</p></li>
  24. <li>
  25. <p>Use a version control system to store your code.</p></li>
  26. <li>
  27. <p>Never modify any of the core DITA-OT code.<note type="tip">You may want to set the permissions on default
  28. plug-in directories such as <filepath>org.dita.pdf2</filepath> to “read-only” to ensure that you do not
  29. accidentally modify the files within as you develop your customized plug-in.</note></p></li>
  30. <li>
  31. <p>Avoid copying entire DITA-OT files into your customization plug-in. When you only copy the attribute sets and
  32. templates that you need to override, there is less risk of impact from new features or fixes in the base code,
  33. making your code more stable and easier to upgrade between releases.</p></li>
  34. <li>
  35. <p>If you only need to change a few attribute sets and templates, you may prefer to store your overrides in
  36. <filepath>custom.xsl</filepath> files, or a simple folder hierarchy within your custom plug-in.</p></li>
  37. <li>
  38. <p>In cases that require substantial customizations, you may prefer to organize the files in a folder structure
  39. that mimics the hierarchy of the default plug-in you are customizing. This facilitates comparisons with the
  40. default settings in the base plug-in and makes it easier to migrate your changes to new toolkit versions. See
  41. <xref keyref="pdf-plugin-structure"/> for information on the files in the base PDF plug-in.</p></li>
  42. <li>
  43. <p>Upgrade your customization plug-in to new versions of DITA-OT regularly. Do not wait through several major
  44. releases before upgrading.</p></li>
  45. <li><div conkeyref="reusable-components/plugin.rnc"/></li>
  46. <li>
  47. <p>For XSLT customizations, use a custom namespace for any modified template modes, template names, attribute
  48. sets, functions, and variables. This helps to clarify which portions of the code are specific to your
  49. customizations, and serves to isolate your changes in the event that items with the same name are added to the
  50. base plug-ins in the future.</p>
  51. <p>For example, instead of creating a template named <codeph>searchbar</codeph>, use something like
  52. <codeph>corp:searchbar</codeph> instead. This ensures that if future versions of DITA-OT add a
  53. <codeph>searchbar</codeph> template, your custom version will be unaffected.</p>
  54. <p>Instead of: <codeblock outputclass="language-xml">&lt;xsl:template name="searchbar"/></codeblock></p>
  55. <p>use: <codeblock outputclass="language-xml">&lt;xsl:template name="corp:searchbar"/></codeblock></p>
  56. </li>
  57. </ul>
  58. </conbody>
  59. </concept>