preprocess-flagging.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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="Beginning with DITA-OT 1.7, flagging support is implemented as a common flag-module preprocessing step. The module evaluates the DITAVAL against all flagging attributes, and adds DITA-OT–specific hints to the topic when flags are active. Any extended transformation type may use these hints to support flagging without adding logic to interpret the DITAVAL."><meta name="DC.Relation" scheme="URI" content="../reference/preprocessing.html"><meta name="DC.Relation" scheme="URI" content="../reference/preprocess-topicpull.html"><meta name="DC.Relation" scheme="URI" content="../reference/preprocess-clean-map.html"><meta name="DC.Format" content="HTML5"><meta name="DC.Identifier" content="flagging"><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>Flagging (flag-module)</title></head><body id="flagging"><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></li><li><a href="../topics/troubleshooting-overview.html">Troubleshooting</a></li><li><a href="../reference/index.html">Reference</a><ul><li><a href="../reference/architecture.html">DITA-OT architecture</a><ul><li><a href="../reference/processing-structure.html">Processing structure</a></li><li><a href="../reference/map-first-preprocessing.html">Map-first preprocessing</a></li><li><a href="../reference/processing-pipeline-modules.html">Processing modules</a></li><li><a href="../reference/processing-order.html">Processing order</a></li><li><a href="../reference/preprocessing.html">Pre-processing modules</a><ul><li><a href="../reference/preprocess-genlist.html">Generate lists (gen-list)</a></li><li><a href="../reference/preprocess-debugfilter.html">Debug and filter (debug-filter)</a></li><li><a href="../reference/preprocess-mapref.html">Resolve map references (mapref)</a></li><li><a href="../reference/preprocess-branch-filter.html">Branch filtering (branch-filter)</a></li><li><a href="../reference/preprocess-copyfiles.html">Copy related files (copy-files)</a></li><li><a href="../reference/preprocess-keyref.html">Resolve keyref (keyref)</a></li><li><a href="../reference/preprocess-copy-to.html">Copy topics (copy-to)</a></li><li><a href="../reference/preprocess-conrefpush.html">Conref push (conrefpush)</a></li><li><a href="../reference/preprocess-conref.html">Conref (conref)</a></li><li><a href="../reference/preprocess-profile.html">Filter conditional content (profile)</a></li><li><a href="../reference/preprocess-topic-fragment.html">Resolve topic fragments and code references (topic-fragment)</a></li><li><a href="../reference/preprocess-chunk.html">Chunk topics (chunk)</a></li><li><a href="../reference/preprocess-metadata.html">Move metadata (move-meta-entries) and pull content into maps (mappull) </a></li><li><a href="../reference/preprocess-maplink.html">Map based linking (maplink)</a></li><li><a href="../reference/preprocess-topicpull.html">Pull content into topics (topicpull)</a></li><li class="active"><a href="../reference/preprocess-flagging.html">Flagging (flag-module)</a></li><li><a href="../reference/preprocess-clean-map.html">Map cleanup (clean-map)</a></li></ul></li><li><a href="../reference/XhtmlWithNavigation.html">HTML-based processing modules</a></li><li><a href="../reference/pdf-transform.html">PDF processing modules</a></li></ul></li><li><a href="../reference/DITA_spec-support.html">DITA specification support</a></li><li><a href="../reference/java-api.html">Java API</a></li><li><a href="../reference/license.html">License</a></li></ul></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">Flagging (flag-module)</h1>
  8. <div class="body refbody"><p class="shortdesc">Beginning with DITA-OT 1.7, flagging support is implemented as a common <code class="ph codeph">flag-module</code>
  9. preprocessing step. The module evaluates the DITAVAL against all flagging attributes, and adds DITA-OT–specific
  10. hints to the topic when flags are active. Any extended transformation type may use these hints to support flagging
  11. without adding logic to interpret the DITAVAL.</p>
  12. <section class="section"><h2 class="title sectiontitle">Evaluating the DITAVAL flags</h2>
  13. <p class="p">Flagging is implemented as a reusable module during the preprocess stage. If a DITAVAL file is not used with a
  14. build, this step is skipped with no change to the file.</p>
  15. <p class="p">When a flag is active, relevant sections of the DITAVAL itself are copied into the topic as a sub-element of
  16. the current topic. The active flags are enclosed in a pseudo-specialization of the
  17. <code class="keyword markupname xmlelement">&lt;foreign&gt;</code> element (referred to as a pseudo-specialization because it is used only under
  18. the covers, with all topic types; it is not integrated into any shipped document types).</p>
  19. <dl class="dl parml">
  20. <dt class="dt pt dlterm"><code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code></dt>
  21. <dd class="dd pd">
  22. <p class="p">When any flag is active on an element, a <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code> element will be
  23. created as the first child of the flagged element:</p>
  24. <pre class="pre codeblock"><code>&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "&gt;</code></pre>
  25. <div class="p">The <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code> element will contain the following:
  26. <ul class="ul">
  27. <li class="li">If the active flags should create a new style, that style is included using standard CSS markup on
  28. the <code class="keyword markupname xmlatt">@outputclass</code> attribute. Output types that make use of CSS, such as XHTML, can use
  29. this value as-is.</li>
  30. <li class="li">If styles conflict, and a <code class="keyword markupname xmlelement">&lt;style-conflict&gt;</code> element exists in the DITAVAL, it
  31. will be copied as a child of <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code>.</li>
  32. <li class="li">Any <code class="keyword markupname xmlelement">&lt;prop&gt;</code> or <code class="keyword markupname xmlelement">&lt;revprop&gt;</code> elements that define active
  33. flags will be copied in as children of the <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code> element. Any
  34. <code class="keyword markupname xmlelement">&lt;startflag&gt;</code> children of the properties will be included, but
  35. <code class="keyword markupname xmlelement">&lt;endflag&gt;</code> children will not.</li>
  36. </ul>
  37. </div>
  38. </dd>
  39. <dt class="dt pt dlterm"><code class="keyword markupname xmlelement">&lt;ditaval-endprop&gt;</code></dt>
  40. <dd class="dd pd">
  41. <p class="p">When any flag is active on an element, a <code class="keyword markupname xmlelement">&lt;ditaval-endprop&gt;</code> element will be created
  42. as the last child of the flagged element:</p>
  43. <pre class="pre codeblock"><code>&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop "&gt;</code></pre>
  44. <p class="p">CSS values and <code class="keyword markupname xmlelement">&lt;style-conflict&gt;</code> elements are not included on this element.</p>
  45. <p class="p">Any <code class="keyword markupname xmlelement">&lt;prop&gt;</code> or <code class="keyword markupname xmlelement">&lt;revprop&gt;</code> elements that define active flags
  46. will be copied in as children of <code class="keyword markupname xmlelement">&lt;ditaval-prop&gt;</code>. Any
  47. <code class="keyword markupname xmlelement">&lt;startflag&gt;</code> children of the properties will be included, but
  48. <code class="keyword markupname xmlelement">&lt;endflag&gt;</code> children will not.</p>
  49. </dd>
  50. </dl>
  51. </section>
  52. <section class="section"><h2 class="title sectiontitle">Supporting flags in overrides or custom transformation types</h2>
  53. <p class="p">For most transformation types, the <code class="keyword markupname xmlelement">&lt;foreign&gt;</code> element should be ignored by default,
  54. because arbitrary non-DITA content may not mix well unless coded for ahead of time. If the
  55. <code class="keyword markupname xmlelement">&lt;foreign&gt;</code> element is ignored by default, or if a rule is added to specifically ignore
  56. <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code> and <code class="keyword markupname xmlelement">&lt;ditaval-endprop&gt;</code>, then the added
  57. elements will have no impact on a transform. If desired, flagging support may be integrated at any time in the
  58. future.</p>
  59. <p class="p">The processing described above runs as part of the common preprocess, so any transform that uses the default
  60. preprocess will get the topic updates. To support generating flags as images, XSLT based transforms can use
  61. default fallthrough processing in most cases. For example, if a paragraph is flagged, the first child of
  62. <code class="keyword markupname xmlelement">&lt;p&gt;</code> will contain the start flag information; adding a rule to handle images in
  63. <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code> will cause the image to appear at the start of the paragraph
  64. content.</p>
  65. <p class="p">In some cases fallthrough processing will not result in valid output; for those cases, the flags must be
  66. explicitly processed. This is done in the XHTML transform for elements like <code class="keyword markupname xmlelement">&lt;ol&gt;</code>, because
  67. fallthrough processing would place images in between <code class="keyword markupname xmlelement">&lt;ol&gt;</code> and
  68. <code class="keyword markupname xmlelement">&lt;li&gt;</code>. To handle this, the code processes <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code>
  69. before starting the element, and <code class="keyword markupname xmlelement">&lt;ditaval-endprop&gt;</code> at the end. Fallthrough processing is
  70. then disabled for those elements as children of <code class="keyword markupname xmlelement">&lt;ol&gt;</code>.</p></section>
  71. <div class="example"><h2 class="title sectiontitle">Example DITAVAL</h2>
  72. <p class="p">Assume the following DITAVAL file is in use during a build. This DITAVAL will be used for each of the following
  73. content examples.</p>
  74. <pre class="pre codeblock"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  75. &lt;val&gt;
  76. &lt;!-- Define what happens in the case of conflicting styles --&gt;
  77. &lt;style-conflict background-conflict-color="red"/&gt;
  78. &lt;!-- Define two flagging properties that give styles (no image) --&gt;
  79. &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
  80. &lt;prop action="flag" att="platform" style="overline" val="win" backcolor="blue"/&gt;
  81. &lt;!-- Define a property that includes start and end image flags --&gt;
  82. &lt;prop action="flag" att="platform" val="linux" style="overline" backcolor="blue"&gt;
  83. &lt;startflag imageref="startlin.png"&gt;&lt;alt-text&gt;Start linux&lt;/alt-text&gt;&lt;/startflag&gt;
  84. &lt;endflag imageref="endlin.png"&gt;&lt;alt-text&gt;End linux&lt;/alt-text&gt;&lt;/endflag&gt;
  85. &lt;/prop&gt;
  86. &lt;!-- Define a revision that includes start and end image flags --&gt;
  87. &lt;revprop action="flag" style="double-underline" val="rev2"&gt;
  88. &lt;startflag imageref="start_rev.gif"&gt;&lt;alt-text&gt;ssssssssssstart&lt;/alt-text&gt;&lt;/startflag&gt;
  89. &lt;endflag imageref="end_rev.gif"&gt;&lt;alt-text&gt;eeeeeeeeeeeeeend&lt;/alt-text&gt;&lt;/endflag&gt;
  90. &lt;/revprop&gt;
  91. &lt;/val&gt;</code></pre>
  92. </div>
  93. <div class="example"><h2 class="title sectiontitle">Content example 1: Adding style</h2>
  94. <p class="p">Now assume the following paragraph exists in a topic. Class attributes are included, as they would normally be
  95. in the middle of the preprocess routine; <code class="keyword markupname xmlatt">@xtrf</code> and <code class="keyword markupname xmlatt">@xtrc</code> are left off for
  96. clarity.</p>
  97. <pre class="pre codeblock"><code>&lt;p audience="user"&gt;Simple user; includes style but no images&lt;/p&gt;
  98. </code></pre>
  99. <p class="p">Based on the DITAVAL above, audience="user" results in a style with underlining and with a green background.
  100. The interpreted CSS value is added to <code class="keyword markupname xmlatt">@outputclass</code> on
  101. <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code>, and the actual property definition is included at the start and end
  102. of the element. The output from the flagging step looks like this (with newlines added for clarity, and class
  103. attributes added as they would appear in the temporary file):</p>
  104. <p class="p">The resulting file after the flagging step looks like this; for clarity, newlines are added, while
  105. <code class="keyword markupname xmlatt">@xtrf</code> and <code class="keyword markupname xmlatt">@xtrc</code> are removed:</p>
  106. <pre class="pre codeblock"><code>&lt;p audience="user" class="- topic/p "&gt;
  107. <strong class="ph b">&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "
  108. outputclass="background-color:green;text-decoration:underline;"&gt;
  109. &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
  110. &lt;/ditaval-startprop&gt;</strong>
  111. Simple user; includes style but no images
  112. <strong class="ph b">&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop "&gt;
  113. &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
  114. &lt;/ditaval-endprop&gt;</strong>
  115. &lt;/p&gt;</code></pre>
  116. </div>
  117. <div class="example"><h2 class="title sectiontitle">Content example 2: Conflicting styles</h2>
  118. <p class="p">This example includes a paragraph with conflicting styles. When the audience and platform attributes are both
  119. evaluated, the DITAVAL indicates that the background color is both green and blue. In this situation, the
  120. <code class="keyword markupname xmlelement">&lt;style-conflict&gt;</code> element is evaluated to determine how to style the content.</p>
  121. <pre class="pre codeblock"><code>&lt;p audience="user" platform="win"&gt;Conflicting styles (still no images)&lt;/p&gt;</code></pre>
  122. <p class="p">The <code class="keyword markupname xmlelement">&lt;style-conflict&gt;</code> element results in a background color of red, so this value is
  123. added to <code class="keyword markupname xmlatt">@outputclass</code> on <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code>. As above, active properties
  124. are copied into the generated elements; the <code class="keyword markupname xmlelement">&lt;style-conflict&gt;</code> element itself is also
  125. copied into the generated <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code> element.</p>
  126. <p class="p">The resulting file after the flagging step looks like this; for clarity, newlines are added, while
  127. <code class="keyword markupname xmlatt">@xtrf</code> and <code class="keyword markupname xmlatt">@xtrc</code> are removed:</p>
  128. <pre class="pre codeblock"><code>&lt;p audience="user" platform="win" class="- topic/p "&gt;
  129. <strong class="ph b">&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "
  130. outputclass="background-color:red;"&gt;
  131. &lt;style-conflict background-conflict-color="red"/&gt;
  132. &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
  133. &lt;prop action="flag" att="platform" style="overline" val="win" backcolor="blue"/&gt;
  134. &lt;/ditaval-startprop&gt;</strong>
  135. Conflicting styles (still no images)
  136. <strong class="ph b">&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop "&gt;
  137. &lt;prop action="flag" att="platform" style="overline" val="win" backcolor="blue"/&gt;
  138. &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
  139. &lt;/ditaval-endprop&gt;</strong>
  140. &lt;/p&gt;</code></pre>
  141. </div>
  142. <div class="example"><h2 class="title sectiontitle">Content example 3: Adding image flags</h2>
  143. <p class="p">This example includes image flags for both <code class="keyword markupname xmlatt">@platform</code> and <code class="keyword markupname xmlatt">@rev</code>, which are
  144. defined in DITAVAL <code class="keyword markupname xmlelement">&lt;prop&gt;</code> and <code class="keyword markupname xmlelement">&lt;revprop&gt;</code> elements.</p>
  145. <pre class="pre codeblock"><code>&lt;ol platform="linux" rev="rev2"&gt;
  146. &lt;li&gt;Generate images for platform="linux" and rev="2"&lt;/li&gt;
  147. &lt;/ol&gt;</code></pre>
  148. <p class="p">As above, the <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code> and <code class="keyword markupname xmlelement">&lt;ditaval-endprop&gt;</code> nest the
  149. active property definitions, with the calculated CSS value on <code class="keyword markupname xmlatt">@outputclass</code>. The
  150. <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code> drops the ending image, and
  151. <code class="keyword markupname xmlelement">&lt;ditaval-endprop&gt;</code> drops the starting image. To make document-order processing more
  152. consistent, property flags are always included before revisions in <code class="keyword markupname xmlelement">&lt;ditaval-startprop&gt;</code>,
  153. and the order is reversed for <code class="keyword markupname xmlelement">&lt;ditaval-endprop&gt;</code>.</p>
  154. <p class="p">The resulting file after the flagging step looks like this; for clarity, newlines are added, while
  155. <code class="keyword markupname xmlatt">@xtrf</code> and <code class="keyword markupname xmlatt">@xtrc</code> are removed:</p>
  156. <pre class="pre codeblock"><code>&lt;ol platform="linux" rev="rev2" class="- topic/ol "&gt;
  157. <strong class="ph b">&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "
  158. outputclass="background-color:blue;text-decoration:underline;text-decoration:overline;"&gt;
  159. &lt;prop action="flag" att="platform" val="linux" style="overline" backcolor="blue"&gt;
  160. &lt;startflag imageref="startlin.png"&gt;&lt;alt-text&gt;Start linux&lt;/alt-text&gt;&lt;/startflag&gt;
  161. &lt;/prop&gt;
  162. &lt;revprop action="flag" style="double-underline" val="rev2"&gt;
  163. &lt;startflag imageref="start_rev.gif"&gt;&lt;alt-text&gt;ssssssssssstart&lt;/alt-text&gt;&lt;/startflag&gt;
  164. &lt;/revprop&gt;
  165. &lt;/ditaval-startprop&gt;</strong>
  166. &lt;li class="- topic/li "&gt;Generate images for platform="linux" and rev="2"&lt;/li&gt;
  167. <strong class="ph b">&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop "&gt;
  168. &lt;revprop action="flag" style="double-underline" val="rev2"&gt;
  169. &lt;endflag imageref="end_rev.gif"&gt;&lt;alt-text&gt;eeeeeeeeeeeeeend&lt;/alt-text&gt;&lt;/endflag&gt;
  170. &lt;/revprop&gt;
  171. &lt;prop action="flag" att="platform" val="linux" style="overline" backcolor="blue"&gt;
  172. &lt;endflag imageref="endlin.png"&gt;&lt;alt-text&gt;End linux&lt;/alt-text&gt;&lt;/endflag&gt;
  173. &lt;/prop&gt;
  174. &lt;/ditaval-endprop&gt;</strong>
  175. &lt;/ol&gt;</code></pre>
  176. </div>
  177. </div>
  178. <nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../reference/preprocessing.html" title="The pre-processing operation is a set of steps that typically runs at the beginning of every DITA-OT transformation. Each step or stage corresponds to an Ant target in the build pipeline; the preprocess target calls the entire set of steps.">Pre-processing modules</a></div><div class="previouslink"><strong>Previous topic:</strong> <a class="link" href="../reference/preprocess-topicpull.html" title="The topicpull step pulls content into xref and link elements. This step is implemented in XSLT.">Pull content into topics (topicpull)</a></div><div class="nextlink"><strong>Next topic:</strong> <a class="link" href="../reference/preprocess-clean-map.html" title="The clean-map step removes any elements and attributes that were added to files to support preprocessing.">Map cleanup (clean-map)</a></div></div></nav></article></main></body></html>