flagging-migration.dita 12 KB

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