flagging-migration.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <!DOCTYPE html
  2. SYSTEM "about:legacy-compat">
  3. <html lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2019"><meta name="DC.rights.owner" content="(C) Copyright 2019"><meta name="DC.type" content="reference"><meta name="description" content="This topic is primarily of interest to developers with XHTML transform overrides written prior to DITA-OT 1.7. Due to significant changes in the flagging process with the 1.7 release, some changes may be needed to make overrides work properly with DITAVAL-based flagging. The new design is significantly simpler than the old design; in many cases, migration will consist of deleting old code that is no longer needed."><meta name="DC.subject" content=", ul, deprecated features, mode=&#34;elementname-fmt&#34;, DITAVAL templates, DITAVAL, template changes in 1.7, CSS, gen-style, flagging"><meta name="keywords" content=", ul, deprecated features, mode=&#34;elementname-fmt&#34;, DITAVAL templates, DITAVAL, template changes in 1.7, CSS, gen-style, flagging"><meta name="DC.relation" scheme="URI" content="../topics/migrating-to-1.7.html"><meta name="DC.format" content="HTML5"><meta name="DC.identifier" content="flagging-migration"><meta name="DC.language" content="en-US"><link rel="stylesheet" type="text/css" href="../css/commonltr.css"><link rel="stylesheet" type="text/css" href="../css/dita-ot-doc.css"><title>XHTML migration for flagging updates in DITA-OT 1.7</title></head><body id="flagging-migration"><header role="banner"><div class="header">
  4. <p>DITA Open Toolkit</p>
  5. <hr>
  6. </div></header><nav role="toc"><ul><li><a href="../index.html">DITA Open Toolkit 3.3</a></li><li><a href="../release-notes/index.html">Release Notes</a></li><li><a href="../topics/installing-client.html">Installing DITA-OT</a></li><li><a href="../topics/alternative-input-formats.html">Authoring formats</a></li><li><a href="../topics/building-output.html">Building output</a></li><li><a href="../parameters/index.html">Setting parameters</a></li><li><a href="../topics/customizing.html">Customizing DITA-OT</a><ul><li><a href="../topics/html-customization.html">Customizing HTML</a></li><li><a href="../topics/pdf-customization.html">Customizing PDF</a></li><li><a href="../topics/custom-plugins.html">Working with plug-ins</a></li><li><a href="../extension-points/plugin-extension-points.html">Extension points</a></li><li><a href="../topics/migration.html">Migrating customizations</a><ul><li><a href="../topics/migrating-to-3.3.html">To 3.3</a></li><li><a href="../topics/migrating-to-3.2.html">To 3.2</a></li><li><a href="../topics/migrating-to-3.1.html">To 3.1</a></li><li><a href="../topics/migrating-to-3.0.html">To 3.0</a></li><li><a href="../topics/migrating-to-2.5.html">To 2.5</a></li><li><a href="../topics/migrating-to-2.4.html">To 2.4</a></li><li><a href="../topics/migrating-to-2.3.html">To 2.3</a></li><li><a href="../topics/migrating-to-2.2.html">To 2.2</a></li><li><a href="../topics/migrating-to-2.1.html">To 2.1</a></li><li><a href="../topics/migrating-to-2.0.html">To 2.0</a></li><li><a href="../topics/migrating-to-1.8.html">To 1.8</a></li><li><a href="../topics/migrating-to-1.7.html">To 1.7</a><ul><li class="active"><a href="../reference/flagging-migration.html">Flagging updates</a></li></ul></li><li><a href="../topics/migrating-to-1.6.html">To 1.6</a></li><li><a href="../topics/migrating-to-1.5.4.html">To 1.5.4</a></li></ul></li><li><a href="../topics/globalization.html">Globalizing DITA content</a></li><li><a href="../topics/rebuilding-docs.html">Rebuilding documentation</a></li></ul></li><li><a href="../topics/troubleshooting-overview.html">Troubleshooting</a></li><li><a href="../reference/index.html">Reference</a></li><li><a href="../topics/dita-and-dita-ot-resources.html">Resources</a></li></ul></nav><main role="main"><article role="article" aria-labelledby="ariaid-title1">
  7. <h1 class="title topictitle1" id="ariaid-title1">XHTML migration for flagging updates in DITA-OT 1.7</h1>
  8. <div class="body refbody"><p class="shortdesc">This topic is primarily of interest to developers with XHTML transform overrides written prior to DITA-OT
  9. 1.7. Due to significant changes in the flagging process with the 1.7 release, some changes may be needed to make
  10. overrides work properly with DITAVAL-based flagging. The new design is significantly simpler than the old design; in
  11. many cases, migration will consist of deleting old code that is no longer needed.</p>
  12. <section class="section"><h2 class="title sectiontitle">Which XHTML overrides need to migrate?</h2>
  13. <p class="p">If your override does not contain any code related to DITAVAL flagging, then there is nothing to migrate.</p>
  14. <p class="p">If your builds do not make use of DITAVAL-based flagging, but call the deprecated flagging templates, then you
  15. should override but there is little urgency. You will not see any difference in the output, but those templates
  16. will be removed in a future release.</p>
  17. <div class="p">If you do make use of DITAVAL-based flagging, try using your override with 1.7. Check the elements you
  18. override:
  19. <ol class="ol">
  20. <li class="li">In some cases flags may be doubled. This will be the case if you call routines such as
  21. <code class="ph codeph">"start-flagit"</code>.</li>
  22. <li class="li">In some cases flags may be removed. This will be the case if you call shortcut routines such as
  23. <code class="ph codeph">"revtext"</code> or <code class="ph codeph">"revblock"</code>.</li>
  24. <li class="li">In other cases, flags may still appear properly, in which case migration is less urgent.</li>
  25. </ol></div>
  26. <p class="p">For any override that needs migration, please see the instructions that follow.</p></section>
  27. <section class="section"><h2 class="title sectiontitle">Deprecated templates in DITA-OT 1.7</h2>
  28. <p class="p">All of the old DITAVAL based templates are deprecated in DITA-OT 1.7. If your overrides include any of the
  29. following templates, they should be migrated for the new release; in many cases the templates below will not
  30. have any effect on your output, but all instances should be migrated.</p>
  31. <ul class="ul">
  32. <li class="li">The <code class="ph codeph">"gen-style"</code> template used to add CSS styling</li>
  33. <li class="li">The <code class="ph codeph">"start-flagit"</code> and <code class="ph codeph">"end-flagit"</code> templates used to generate image flags
  34. based on property attributes like @audience</li>
  35. <li class="li">The <code class="ph codeph">"start-revflag"</code> and <code class="ph codeph">"end-revflag"</code> templates, used to generate images
  36. for active revisions</li>
  37. <li class="li">Shortcut templates that group these templates into a single call, such as:
  38. <ul class="ul">
  39. <li class="li"><code class="ph codeph">"start-flags-and-rev"</code> and <code class="ph codeph">"end-flags-and-rev"</code>, used to combine flags
  40. and revisions into one call</li>
  41. <li class="li"><code class="ph codeph">"revblock"</code> and <code class="ph codeph">"revtext"</code>, both used to output start revisions, element
  42. content, and end revisions</li>
  43. <li class="li">The modes <code class="ph codeph">"outputContentsWithFlags"</code> and
  44. <code class="ph codeph">"outputContentsWithFlagsAndStyle"</code>, both used to combine processing for
  45. property/revision flags with content processing</li>
  46. </ul></li>
  47. <li class="li">All other templates that make use of the <code class="ph codeph">$flagrules</code> variable, which is no longer used in
  48. any of the DITA-OT 1.7 code</li>
  49. <li class="li">All templates within <span class="ph filepath">flag.xsl</span> that were called from the templates listed above</li>
  50. <li class="li">Element processing handled with mode="elementname-fmt", such as <code class="ph codeph">mode="ul-fmt"</code> for
  51. processing unordered lists and <code class="ph codeph">mode="section-fmt"</code> for sections.</li>
  52. </ul></section>
  53. <section class="section"><h2 class="title sectiontitle">What replaces the templates?</h2>
  54. <p class="p">The new flagging design described in the preprocess design section now adds literal copies of relevant DITAVAL
  55. elements, along with CSS based flagging information, into the relevant section of the topic. This allows most
  56. flags to be processed in document order; in addition, there is never a need to read the DITAVAL, interpret CSS,
  57. or evaluate flagging logic. The <span class="ph filepath">htmlflag.xsl</span> file contains a few rules to match and process
  58. the start/end flags; in most cases, all code to explicitly process flags can be deleted.</p>
  59. <div class="p">For example, the common logic for most element rules before DITA-OT 1.7 could be boiled down to the following:
  60. <ol class="ol">
  61. <li class="li">Match element </li>
  62. <li class="li">Create <code class="ph codeph">"flagrules"</code> variable by reading DITAVAL for active flags </li>
  63. <li class="li">Output start tag such as <code class="ph codeph">&lt;div&gt;</code> or <code class="ph codeph">&lt;span&gt;</code>
  64. </li>
  65. <li class="li">Call <code class="ph codeph">"commonattributes"</code> and ID processing </li>
  66. <li class="li">Call <code class="ph codeph">"gen-style"</code> with <code class="ph codeph">$flagrules</code>, to create DITAVAL based CSS </li>
  67. <li class="li">Call <code class="ph codeph">"start-flagit"</code> with <code class="ph codeph">$flagrules</code>, to create start flag images </li>
  68. <li class="li">Call <code class="ph codeph">"start-revflag"</code> with <code class="ph codeph">$flagrules</code>, to create start revision images </li>
  69. <li class="li">Output contents </li>
  70. <li class="li">Call <code class="ph codeph">"end-revflag"</code> with <code class="ph codeph">$flagrules</code>, to create end revision images </li>
  71. <li class="li">Call <code class="ph codeph">"end-flagit"</code> with <code class="ph codeph">$flagrules</code>, to create end flag images </li>
  72. <li class="li">Output end tag such as <code class="ph codeph">&lt;/div&gt;</code> or <code class="ph codeph">&lt;/span&gt;</code></li>
  73. </ol>
  74. </div>
  75. <p class="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. </p>
  78. <div class="p">The sample above is reduced to:
  79. <ol class="ol">
  80. <li class="li">Match element </li>
  81. <li class="li">Output start tag such as <code class="ph codeph">&lt;div&gt;</code> or <code class="ph codeph">&lt;span&gt;</code>
  82. </li>
  83. <li class="li">Call <code class="ph codeph">"commonattributes"</code> and ID processing </li>
  84. <li class="li">Output contents </li>
  85. <li class="li">Output end tag such as <code class="ph codeph">&lt;/div&gt;</code> or <code class="ph codeph">&lt;/span&gt;</code></li>
  86. </ol>
  87. </div>
  88. </section>
  89. <section class="section"><h2 class="title sectiontitle">Migrating <code class="ph codeph">"gen-style"</code> named template</h2>
  90. <p class="p">Calls to the <code class="ph codeph">"gen-style"</code> template should be deleted. There is no need to replace this call for
  91. most elements.</p>
  92. <p class="p">The <code class="ph codeph">"gen-style"</code> template was designed to read a DITAVAL file, find active style-based flagging
  93. (such as colored or bold text), and add it to the generated @style attribute in HTML.</p>
  94. <div class="p">With DITA-OT 1.7, the style is calculated in the pre-process flagging module. The result is created as
  95. @outputclass on a <code class="ph codeph">&lt;ditaval-startprop&gt;</code> sub-element. The <code class="ph codeph">"commonattributes"</code>
  96. template now includes a line to process that value; the result is that for every element that calls
  97. <code class="ph codeph">"commonattributes"</code>, DITAVAL style will be processed when needed. Because virtually every
  98. element includes a call to this common template, there is little chance that your override needs to explicitly
  99. process the style. The new line in <code class="ph codeph">"commonattributes"</code> that handles the style is:
  100. <pre class="pre codeblock language-xml"><code>&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]/@outputclass" mode="add-ditaval-style"/&gt;</code></pre></div></section>
  101. <section class="section"><h2 class="title sectiontitle">Migrating <code class="ph codeph">"start-flagit"</code>, <code class="ph codeph">"start-revflag"</code>, <code class="ph codeph">"end-flagit"</code>,
  102. and <code class="ph codeph">"end-flagit"</code> named templates</h2>
  103. <p class="p">Calls to these templates fall into two general groups.</p>
  104. <p class="p">If the flow of your element rule is to create a start tag like <code class="ph codeph">&lt;div&gt;</code>,
  105. <code class="ph codeph">"start-flagit"</code>/<code class="ph codeph">"start-revflag"</code>, process contents,
  106. <code class="ph codeph">"end-revflag"</code>/<code class="ph codeph">"end-flagit"</code>, end tag - you just need to delete the calls to
  107. these templates. Flags will be generated simply by processing the element contents in document order.</p>
  108. <p class="p">If the flow of your element rule processes flags outside of the normal document-order. There are generally two
  109. reasons this is done. The first case is for elements like <code class="ph codeph">&lt;ol&gt;</code>, where flags must appear
  110. before the <code class="ph codeph">&lt;ol&gt;</code> in order to create valid XHTML. The second is for elements like
  111. <code class="ph codeph">&lt;section&gt;</code>, where start flags are created, followed by the title or some generated text,
  112. element contents, and finally end flags. In either of these cases, support for processing flags in document
  113. order is disabled, so they must be explicitly processed out-of-line.</p>
  114. <p class="p">This is done with the following two lines (one for start flag/revision, one for end flag/revision):</p>
  115. <ul class="ul">
  116. <li class="li">
  117. <p class="p">Create starting flag and revision images:</p>
  118. <pre class="pre codeblock language-xml"><code>&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/&gt;</code></pre></li>
  119. <li class="li">
  120. <p class="p">Create ending flag and revision images:</p>
  121. <pre class="pre codeblock language-xml"><code>&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/&gt;</code></pre></li>
  122. </ul>
  123. <div class="p">For example, the following lines are used in DITA-OT 1.7 to process the <code class="keyword markupname xmlelement">&lt;ul&gt;</code> element
  124. (replacing the 29 lines used in DITA-OT
  125. 1.6):<pre class="pre codeblock language-xml normalize-space show-line-numbers show-whitespace"><code>&lt;xsl:template match="*[contains(@class,' topic/ul ')]"&gt;
  126. <strong class="ph b">&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/&gt;</strong>
  127. &lt;xsl:call-template name="setaname"/&gt;
  128. &lt;ul&gt;
  129. &lt;xsl:call-template name="commonattributes"/&gt;
  130. &lt;xsl:apply-templates select="@compact"/&gt;
  131. &lt;xsl:call-template name="setid"/&gt;
  132. &lt;xsl:apply-templates/&gt;
  133. &lt;/ul&gt;
  134. <strong class="ph b">&lt;xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/&gt;</strong>
  135. &lt;xsl:value-of select="$newline"/&gt;
  136. &lt;/xsl:template&gt;</code></pre></div></section>
  137. <section class="section"><h2 class="title sectiontitle">Migrating <code class="ph codeph">"start-flags-and-rev"</code> and <code class="ph codeph">"end-flags-and-rev"</code></h2>
  138. <ul class="ul">
  139. <li class="li"><code class="ph codeph">"start-flags-and-rev"</code> is equivalent to calling <code class="ph codeph">"start-flagit"</code> followed by
  140. <code class="ph codeph">"start-revflag"</code>; it should be migrated as in the previous section.</li>
  141. <li class="li"><code class="ph codeph">"end-flags-and-rev"</code> is equivalent to calling <code class="ph codeph">"end-revflag"</code> followed by
  142. <code class="ph codeph">"end-flagit"</code>; it should be migrated as in the previous section.</li>
  143. </ul></section>
  144. <section class="section"><h2 class="title sectiontitle">Migrating <code class="ph codeph">"revblock"</code> and <code class="ph codeph">"revtext"</code></h2>
  145. <p class="p">Calls to these two templates can be replaced with a simple call to
  146. <code class="ph codeph">&lt;xsl:apply-templates/&gt;</code>.</p></section>
  147. <section class="section"><h2 class="title sectiontitle">Migrating modes <code class="ph codeph">"outputContentsWithFlags"</code> and
  148. <code class="ph codeph">"outputContentsWithFlagsAndStyle"</code></h2>
  149. <p class="p">Processing an element with either of these modes can be replaced with a simple call to
  150. <code class="ph codeph">&lt;xsl:apply-templates/&gt;</code>.</p></section>
  151. <section class="section"><h2 class="title sectiontitle">Migrating <code class="ph codeph">mode="elementname-fmt"</code></h2>
  152. <div class="p">Prior to DITA-OT 1.7, many elements were processed with the following
  153. logic:<pre class="pre">Match element
  154. Set variable to determine if revisions are active and $DRAFT is on
  155. If active
  156. create division with rev style
  157. process element with mode="elementname-fmt"
  158. end division
  159. Else
  160. process element with mode="elementname-fmt"
  161. Match element with mode="elementname-fmt"
  162. Process as needed</pre></div>
  163. <p class="p">Beginning with DITA-OT 1.7, styling from revisions is handled automatically with the
  164. <code class="ph codeph">"commonattributes"</code> template. This means there is no need for the extra testing, or the
  165. indirection to <code class="ph codeph">mode="elementname-fmt"</code>. These templates are deprecated, and element processing
  166. will move into the main element rule. Overrides that include this indirection may remove it; overrides should
  167. also be sure to match the default rule, rather than matching with
  168. <code class="ph codeph">mode="elementname-fmt"</code>.</p></section>
  169. </div>
  170. <nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/migrating-to-1.7.html" title="In DITA-OT 1.7, a new preprocessing step implements flagging for HTML-based output formats. PDF processing was corrected with regard to shortdesc handling, and a new XSLT template mode was introduced for HTML TOC processing. Several stylesheets were moved to plug-in specific folders and deprecated properties and XSLT variables were removed.">Migrating to release 1.7</a></div></div></nav></article></main></body></html>