flagging-migration.html 18 KB

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