map-first-preprocessing.dita 7.2 KB

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