map-first-preprocessing.dita 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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="ID" rev="3.0">
  5. <title>Map-first preprocessing</title>
  6. <titlealts>
  7. <navtitle>Map-first preprocessing</navtitle>
  8. </titlealts>
  9. <shortdesc><ph id="map-first-preproc-desc">DITA-OT 3.0 provides a map-first preprocessing option as an alternative to
  10. the default <codeph>preprocess</codeph> operation. The method, which was introduced in DITA-OT 2.5 as an
  11. experimental feature, has been improved and is ready for use in many production scenarios. Map-first-preprocessing
  12. provides the same functionality as the default <codeph>preprocess</codeph>, but takes a different
  13. approach.</ph></shortdesc>
  14. <prolog>
  15. <metadata>
  16. <keywords>
  17. <indexterm>filters<indexterm>map-first preprocessing</indexterm></indexterm>
  18. <indexterm>preprocessing<indexterm>map first</indexterm></indexterm>
  19. <indexterm>DITA 1.0</indexterm>
  20. <indexterm>DITA 1.2</indexterm>
  21. <indexterm>DITA 1.3<indexterm>effect on preprocessing</indexterm></indexterm>
  22. <indexterm>pipelines<indexterm>map first</indexterm></indexterm>
  23. <indexterm>validate</indexterm>
  24. <indexterm>maps<index-see>DITA maps</index-see></indexterm>
  25. <indexterm>DITA maps<indexterm>validate</indexterm></indexterm>
  26. </keywords>
  27. </metadata>
  28. </prolog>
  29. <conbody>
  30. <p id="map-first-preproc-gain">Whereas the default preprocessing routine handles both maps and topics at the same
  31. time, often switching back and forth between map operations and topic operations, the map-first approach only
  32. begins processing topics after nearly all map processing is complete. This simplifies the processing logic and
  33. creates cleaner module responsibilities, which makes it easier to process only those topics that are actually
  34. referenced after filtering, for example, or to only process the map to validate the map structure.</p>
  35. <p>The current preprocessing architecture was established during the DITA 1.0 era when there were fewer DITA
  36. features that operated on the map level. Initially, the difference between processing modes was not that great.
  37. DITA 1.2 and 1.3 introduced many more map-level features, such as keys and key scopes, that make it difficult to
  38. reliably work with topics before all map features have been resolved. </p>
  39. <p>The original preprocessing operation already handles many map operations first, but this was not the original
  40. design and requires regular refactoring to handle edge cases. The new map-first preprocessing is designed with
  41. this model in mind, improving the overall processing flow and making it more formal about the map-first model. The
  42. new model also takes advantage of hashed topic file names in the temporary directory, which simplifies many
  43. processing steps, and is better able to handle topics referenced outside of the map directory (that case has
  44. resulted in a variety of issues with the original model).</p>
  45. <note id="map-first-preproc-note">The map-first preprocessing option is enabled by default in DITA-OT 3.0 for PDF
  46. and HTML Help. These formats were chosen because they generate a compiled result file, so temporarily hashed file
  47. names should all be invisible to the build. After further testing and feedback, the new option will most likely
  48. become the default for other output formats in future versions. Because the DITA-OT development team cannot have
  49. access to all varieties of DITA, all edge cases, or even all the ways DITA-OT itself is extended, the switch to
  50. default map-first preprocessing for other output formats will be smoother for everyone if more people can test and
  51. provide feedback.</note>
  52. <section>
  53. <title>How to use map-first preprocessing</title>
  54. <p>To use (or test) map-first preprocessing, call the <codeph>preprocess2</codeph> Ant target in your custom
  55. transformation types instead of using the default <codeph>preprocess</codeph> target.</p>
  56. <p>For example, if you have a custom HTML5 transformation type named "myhtml", then you may have a plug-in
  57. extension that looks this:</p>
  58. <codeblock outputclass="language-xml">&lt;!-- Simple variant: set properties and call default HTML5 -->
  59. &lt;target name="dita2myhtml" depends="myhtml.init,dita2html5"/>
  60. </codeblock>
  61. <p>This type of extension is quite common, and is used to set default properties for your environment followed by
  62. a normal build to use those properties. In this case, you'll need to replace <codeph>dita2html5</codeph> with
  63. the normal HTML5 steps, swapping out <codeph>preprocess</codeph> for <codeph>preprocess2</codeph>:</p>
  64. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;!-- Simple variant: set properties and call default HTML5 -->
  65. &lt;target name="dita2myhtml"
  66. depends="myhtml.init,
  67. html5.init,
  68. build-init,
  69. <b>preprocess2,</b>
  70. html5.topic,
  71. html5.map,
  72. html5.css"/></codeblock>
  73. <note>If you use this simple method for customized PDF or HTML Help builds, you will automatically be using
  74. <codeph>preprocess2</codeph>.</note>
  75. <p>Some custom transformation types already require you to repeat the default dependencies, in which case you
  76. should already call <codeph>preprocess</codeph> directly, as in the following:</p>
  77. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;!-- More complex variant: add processing steps to default HTML5 -->
  78. &lt;target name="dita2myhtml"
  79. depends="myhtml.init,
  80. build-init,
  81. preprocess,
  82. local-extensions-after-preprocess,
  83. html5.topic,
  84. html5.map,
  85. html5.css"/></codeblock>
  86. <p>In such cases, the modification is much easier – simply add a <codeph>2</codeph> to the existing
  87. <codeph>preprocess</codeph> target.</p>
  88. </section>
  89. <section>
  90. <title>How to test in a production environment</title>
  91. <p>In some cases, you may be responsible for maintaining transformation types that are actually run by many people
  92. on your team or around a company. In this case, you likely need to maintain your existing transformation types
  93. based on the backwards-compatible <codeph>preprocess</codeph> modules, but also want to provide your colleagues
  94. with a way to test their own documents using <codeph>preprocess2</codeph>.</p>
  95. <p>There are several ways to do this. One fairly straightforward approach would be to create a new custom
  96. transformation type that is exactly the same, except for preprocessing. For example, if you have a local HTML
  97. variant called <codeph>myhtml</codeph> as above, instead of modifying that transformation directly, you could
  98. create a second transformation type called <codeph>myhtml-beta</codeph> that provides exactly the same support,
  99. but with the new map-first preprocessing:</p>
  100. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace"><i>&lt;!-- Original "myhtml" is not modified, used for production --></i>
  101. &lt;target name="dita2myhtml5" depends="myhtml.init,dita2html5"/>
  102. <i>&lt;!-- "myhtml-beta" used to test and provide feedback on preprocess2 --></i>
  103. &lt;target name="dita2myhtml-beta"
  104. depends="myhtml.init,
  105. html5.init,
  106. build-init,
  107. <b>preprocess2,</b>
  108. html5.topic,
  109. html5.map,
  110. html5.css"/></codeblock>
  111. </section>
  112. <section>
  113. <title>Known limitations</title>
  114. <p>The <codeph>preprocess2</codeph> implementation details are subject to change; dependencies within
  115. <codeph>preprocess2</codeph> may be renamed or removed based on feedback.</p>
  116. <p conkeyref="reusable-components/no-internal-preprocess2-ext"/>
  117. </section>
  118. </conbody>
  119. </concept>