flagging-migration.dita 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <reference id="flagging-migration" rev="1.7" xml:lang="en-US">
  5. <title>XHTML migration for flagging updates in DITA-OT 1.7</title>
  6. <titlealts>
  7. <navtitle>Flagging updates</navtitle>
  8. </titlealts>
  9. <shortdesc>This topic is primarily of interest to developers with XHTML transform overrides written prior to DITA-OT
  10. 1.7. Due to significant changes in the flagging process with the 1.7 release, some changes may be needed to make
  11. overrides work properly with DITAVAL-based flagging. The new design is significantly simpler than the old design; in
  12. many cases, migration will consist of deleting old code that is no longer needed.</shortdesc>
  13. <prolog>
  14. <metadata>
  15. <keywords>
  16. <indexterm><xmlelement>ul</xmlelement></indexterm>
  17. <indexterm>deprecated features
  18. <indexterm><codeph>mode="elementname-fmt"</codeph></indexterm></indexterm>
  19. <indexterm>deprecated features
  20. <indexterm><codeph>DITAVAL templates</codeph></indexterm></indexterm>
  21. <indexterm>DITAVAL
  22. <indexterm>template changes in 1.7</indexterm></indexterm>
  23. <indexterm>CSS
  24. <indexterm>gen-style</indexterm></indexterm>
  25. <indexterm>flagging</indexterm>
  26. </keywords>
  27. </metadata>
  28. </prolog>
  29. <refbody>
  30. <section>
  31. <title>Which XHTML overrides need to migrate?</title>
  32. <p>If your override does not contain any code related to DITAVAL flagging, then there is nothing to migrate.</p>
  33. <p>If your builds do not make use of DITAVAL-based flagging, but call the deprecated flagging templates, then you
  34. should override but there is little urgency. You will not see any difference in the output, but those templates
  35. will be removed in a future release.</p>
  36. <p>If you do make use of DITAVAL-based flagging, try using your override with 1.7. Check the elements you
  37. override:
  38. <ol>
  39. <li>In some cases flags may be doubled. This will be the case if you call routines such as
  40. <codeph>"start-flagit"</codeph>.</li>
  41. <li>In some cases flags may be removed. This will be the case if you call shortcut routines such as
  42. <codeph>"revtext"</codeph> or <codeph>"revblock"</codeph>.</li>
  43. <li>In other cases, flags may still appear properly, in which case migration is less urgent.</li>
  44. </ol></p>
  45. <p>For any override that needs migration, please see the instructions that follow.</p></section>
  46. <section>
  47. <title>Deprecated templates in DITA-OT 1.7</title>
  48. <p>All of the old DITAVAL based templates are deprecated in DITA-OT 1.7. If your overrides include any of the
  49. following templates, they should be migrated for the new release; in many cases the templates below will not
  50. have any effect on your output, but all instances should be migrated.</p>
  51. <ul>
  52. <li>The <codeph>"gen-style"</codeph> template used to add CSS styling</li>
  53. <li>The <codeph>"start-flagit"</codeph> and <codeph>"end-flagit"</codeph> templates used to generate image flags
  54. based on property attributes like @audience</li>
  55. <li>The <codeph>"start-revflag"</codeph> and <codeph>"end-revflag"</codeph> templates, used to generate images
  56. for active revisions</li>
  57. <li>Shortcut templates that group these templates into a single call, such as:
  58. <ul>
  59. <li><codeph>"start-flags-and-rev"</codeph> and <codeph>"end-flags-and-rev"</codeph>, used to combine flags
  60. and revisions into one call</li>
  61. <li><codeph>"revblock"</codeph> and <codeph>"revtext"</codeph>, both used to output start revisions, element
  62. content, and end revisions</li>
  63. <li>The modes <codeph>"outputContentsWithFlags"</codeph> and
  64. <codeph>"outputContentsWithFlagsAndStyle"</codeph>, both used to combine processing for
  65. property/revision flags with content processing</li>
  66. </ul></li>
  67. <li>All other templates that make use of the <codeph>$flagrules</codeph> variable, which is no longer used in
  68. any of the DITA-OT 1.7 code</li>
  69. <li>All templates within <filepath>flag.xsl</filepath> that were called from the templates listed above</li>
  70. <li>Element processing handled with mode="elementname-fmt", such as <codeph>mode="ul-fmt"</codeph> for
  71. processing unordered lists and <codeph>mode="section-fmt"</codeph> for sections.</li>
  72. </ul></section>
  73. <section>
  74. <title>What replaces the templates?</title>
  75. <p>The new flagging design described in the preprocess design section now adds literal copies of relevant DITAVAL
  76. elements, along with CSS based flagging information, into the relevant section of the topic. This allows most
  77. flags to be processed in document order; in addition, there is never a need to read the DITAVAL, interpret CSS,
  78. or evaluate flagging logic. The <filepath>htmlflag.xsl</filepath> file contains a few rules to match and process
  79. the start/end flags; in most cases, all code to explicitly process flags can be deleted.</p>
  80. <p>For example, the common logic for most element rules before DITA-OT 1.7 could be boiled down to the following:
  81. <ol>
  82. <li>Match element </li>
  83. <li>Create <codeph>"flagrules"</codeph> variable by reading DITAVAL for active flags </li>
  84. <li>Output start tag such as <codeph>&lt;div></codeph> or <codeph>&lt;span></codeph>
  85. </li>
  86. <li>Call <codeph>"commonattributes"</codeph> and ID processing </li>
  87. <li>Call <codeph>"gen-style"</codeph> with <codeph>$flagrules</codeph>, to create DITAVAL based CSS </li>
  88. <li>Call <codeph>"start-flagit"</codeph> with <codeph>$flagrules</codeph>, to create start flag images </li>
  89. <li>Call <codeph>"start-revflag"</codeph> with <codeph>$flagrules</codeph>, to create start revision images </li>
  90. <li>Output contents </li>
  91. <li>Call <codeph>"end-revflag"</codeph> with <codeph>$flagrules</codeph>, to create end revision images </li>
  92. <li>Call <codeph>"end-flagit"</codeph> with <codeph>$flagrules</codeph>, to create end flag images </li>
  93. <li>Output end tag such as <codeph>&lt;/div></codeph> or <codeph>&lt;/span></codeph></li>
  94. </ol>
  95. </p>
  96. <p>In DITA-OT 1.7, style and images are typically handled with XSLT fallthrough processing. This removes virtually
  97. all special flag coding from element rules, because flags are already part of the document and processed in
  98. document order. </p>
  99. <p>The sample above is reduced to:
  100. <ol>
  101. <li>Match element </li>
  102. <li>Output start tag such as <codeph>&lt;div></codeph> or <codeph>&lt;span></codeph>
  103. </li>
  104. <li>Call <codeph>"commonattributes"</codeph> and ID processing </li>
  105. <li>Output contents </li>
  106. <li>Output end tag such as <codeph>&lt;/div></codeph> or <codeph>&lt;/span></codeph></li>
  107. </ol>
  108. </p>
  109. </section>
  110. <section>
  111. <title>Migrating <codeph>"gen-style"</codeph> named template</title>
  112. <p>Calls to the <codeph>"gen-style"</codeph> template should be deleted. There is no need to replace this call for
  113. most elements.</p>
  114. <p>The <codeph>"gen-style"</codeph> template was designed to read a DITAVAL file, find active style-based flagging
  115. (such as colored or bold text), and add it to the generated @style attribute in HTML.</p>
  116. <p>With DITA-OT 1.7, the style is calculated in the pre-process flagging module. The result is created as
  117. @outputclass on a <codeph>&lt;ditaval-startprop></codeph> sub-element. The <codeph>"commonattributes"</codeph>
  118. template now includes a line to process that value; the result is that for every element that calls
  119. <codeph>"commonattributes"</codeph>, DITAVAL style will be processed when needed. Because virtually every
  120. element includes a call to this common template, there is little chance that your override needs to explicitly
  121. process the style. The new line in <codeph>"commonattributes"</codeph> that handles the style is:
  122. <codeblock outputclass="language-xml">&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/></codeblock></p></section>
  123. <section>
  124. <title>Migrating <codeph>"start-flagit"</codeph>, <codeph>"start-revflag"</codeph>, <codeph>"end-flagit"</codeph>,
  125. and <codeph>"end-flagit"</codeph> named templates</title>
  126. <p>Calls to these templates fall into two general groups.</p>
  127. <p>If the flow of your element rule is to create a start tag like <codeph>&lt;div></codeph>,
  128. <codeph>"start-flagit"</codeph>/<codeph>"start-revflag"</codeph>, process contents,
  129. <codeph>"end-revflag"</codeph>/<codeph>"end-flagit"</codeph>, end tag - you just need to delete the calls to
  130. these templates. Flags will be generated simply by processing the element contents in document order.</p>
  131. <p>If the flow of your element rule processes flags outside of the normal document-order. There are generally two
  132. reasons this is done. The first case is for elements like <codeph>&lt;ol></codeph>, where flags must appear
  133. before the <codeph>&lt;ol></codeph> in order to create valid XHTML. The second is for elements like
  134. <codeph>&lt;section></codeph>, where start flags are created, followed by the title or some generated text,
  135. element contents, and finally end flags. In either of these cases, support for processing flags in document
  136. order is disabled, so they must be explicitly processed out-of-line.</p>
  137. <p>This is done with the following two lines (one for start flag/revision, one for end flag/revision):</p>
  138. <ul>
  139. <li>
  140. <p>Create starting flag and revision images:</p>
  141. <codeblock outputclass="language-xml">&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/></codeblock></li>
  142. <li>
  143. <p>Create ending flag and revision images:</p>
  144. <codeblock outputclass="language-xml">&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/></codeblock></li>
  145. </ul>
  146. <p>For example, the following lines are used in DITA-OT 1.7 to process the <xmlelement>ul</xmlelement> element
  147. (replacing the 29 lines used in DITA-OT
  148. 1.6):<codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;xsl:template match="*[contains(@class,' topic/ul ')]">
  149. <b>&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/></b>
  150. &lt;xsl:call-template name="setaname"/>
  151. &lt;ul>
  152. &lt;xsl:call-template name="commonattributes"/>
  153. &lt;xsl:apply-templates select="@compact"/>
  154. &lt;xsl:call-template name="setid"/>
  155. &lt;xsl:apply-templates/>
  156. &lt;/ul>
  157. <b>&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/></b>
  158. &lt;xsl:value-of select="$newline"/>
  159. &lt;/xsl:template></codeblock></p></section>
  160. <section>
  161. <title>Migrating <codeph>"start-flags-and-rev"</codeph> and <codeph>"end-flags-and-rev"</codeph></title>
  162. <ul>
  163. <li><codeph>"start-flags-and-rev"</codeph> is equivalent to calling <codeph>"start-flagit"</codeph> followed by
  164. <codeph>"start-revflag"</codeph>; it should be migrated as in the previous section.</li>
  165. <li><codeph>"end-flags-and-rev"</codeph> is equivalent to calling <codeph>"end-revflag"</codeph> followed by
  166. <codeph>"end-flagit"</codeph>; it should be migrated as in the previous section.</li>
  167. </ul></section>
  168. <section>
  169. <title>Migrating <codeph>"revblock"</codeph> and <codeph>"revtext"</codeph></title>
  170. <p>Calls to these two templates can be replaced with a simple call to
  171. <codeph>&lt;xsl:apply-templates/></codeph>.</p></section>
  172. <section>
  173. <title>Migrating modes <codeph>"outputContentsWithFlags"</codeph> and
  174. <codeph>"outputContentsWithFlagsAndStyle"</codeph></title>
  175. <p>Processing an element with either of these modes can be replaced with a simple call to
  176. <codeph>&lt;xsl:apply-templates/></codeph>.</p></section>
  177. <section>
  178. <title>Migrating <codeph>mode="elementname-fmt"</codeph></title>
  179. <p>Prior to DITA-OT 1.7, many elements were processed with the following
  180. logic:<pre>Match element
  181. Set variable to determine if revisions are active and $DRAFT is on
  182. If active
  183. create division with rev style
  184. process element with mode="elementname-fmt"
  185. end division
  186. Else
  187. process element with mode="elementname-fmt"
  188. Match element with mode="elementname-fmt"
  189. Process as needed</pre></p>
  190. <p>Beginning with DITA-OT 1.7, styling from revisions is handled automatically with the
  191. <codeph>"commonattributes"</codeph> template. This means there is no need for the extra testing, or the
  192. indirection to <codeph>mode="elementname-fmt"</codeph>. These templates are deprecated, and element processing
  193. will move into the main element rule. Overrides that include this indirection may remove it; overrides should
  194. also be sure to match the default rule, rather than matching with
  195. <codeph>mode="elementname-fmt"</codeph>.</p></section>
  196. </refbody>
  197. </reference>