VirtualBox

source: vbox/trunk/src/libs/DITA-OT-1.8.5/docsrc/dev_ref/preprocess-flagging.dita@ 98584

Last change on this file since 98584 was 98584, checked in by vboxsync, 2 years ago

Docs: bugref:10302. Setting svn properties of DITA-OT library.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.6 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN"
3 "reference.dtd">
4<reference id="flagging" rev="1.7" xml:lang="en-us">
5<title>Flagging in the toolkit</title>
6<shortdesc>Beginning with DITA-OT 1.7, flagging support is implemented
7as a common preprocess module. The module evaluates the DITAVAL against
8all flagging attributes, and adds DITA-OT specific hints in to the
9topic when flags are active. Any extended transform type may use these
10hints to support flagging without adding logic to interpret the DITAVAL.</shortdesc>
11<refbody>
12<section><title>Evaluating the DITAVAL flags</title><p>Flagging is
13implemented as a reusable module during the preprocess stage. If a
14DITAVAL file is not used with a build, this step is skipped with no
15change to the file.</p><p>When a flag is active, relevant sections
16of the DITAVAL itself are copied into the topic as a sub-element of
17the current topic. The active flags are enclosed in a pseudo-specialization
18of the <codeph>&lt;foreign></codeph> element (referred to as a pseudo-specialization
19because it is used only under the covers, with all topic types; it
20is not integrated into any shipped document types).</p><dl><dlentry>
21<dt><codeph>&lt;ditaval-startprop></codeph></dt>
22<dd>When any flag is active on an element, a <codeph>&lt;ditaval-startprop></codeph> element
23will be created as the first child of the flagged element:<codeblock>&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "></codeblock><p>The <codeph>&lt;ditaval-startprop></codeph> element
24will contain the following:<ul>
25<li>If the active flags should create a new style, that style is included
26using standard CSS markup on the @outputclass attribute. Output types
27that make use of CSS, such as XHTML, can use this value as-is.</li>
28<li>If styles conflict, and a <codeph>&lt;style-conflict></codeph> element
29exists in the DITAVAL, it will be copied as a child of <codeph>&lt;ditaval-startprop></codeph>.</li>
30<li>Any <codeph>&lt;prop></codeph> or <codeph>&lt;revprop></codeph> elements
31that define active flags will be copied in as children of the <codeph>&lt;ditaval-startprop></codeph> element.
32Any <codeph>&lt;startflag></codeph> children of the properties will
33be included, but <codeph>&lt;endflag></codeph> children will not.</li>
34</ul></p></dd>
35</dlentry><dlentry>
36<dt><codeph>&lt;ditaval-endprop></codeph></dt>
37<dd>When any flag is active on an element, a <codeph>&lt;ditaval-endprop></codeph> element
38will be created as the last child of the flagged element:<codeblock>&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop "></codeblock><p>CSS
39values and <codeph>&lt;styleconflict></codeph> elements are not included
40on this element.</p><p>Any <codeph>&lt;prop></codeph> or <codeph>&lt;revprop></codeph> elements
41that define active flags will be copied in as children of <codeph>&lt;ditaval-prop></codeph>.
42Any <codeph>&lt;endflag></codeph> children of the properties will
43be included, but <codeph>&lt;startflag></codeph> children will not.</p></dd>
44</dlentry></dl></section>
45<section><title>Supporting flags in overrides or custom transform
46types</title><p>For most transform types, the <codeph>&lt;foreign></codeph> element
47should be ignored by default, because arbitrary non-DITA content may
48not mix well unless coded for ahead of time. If the <codeph>&lt;foreign></codeph> element
49is ignored by default, or if a rule is added to specifically ignore <codeph>&lt;ditaval-startprop></codeph> and <codeph>&lt;ditaval-endprop></codeph>,
50then the added elements will have no impact on a transform. If desired,
51flagging support may be integrated at any time in the future.</p><p>The
52processing described above runs as part of the common preprocess,
53so any transform that uses the default preprocess will get the topic
54updates. To support generating flags as images, XSLT based transforms
55can use default fallthrough processing in most cases. For example,
56if a paragraph is flagged, the first child of <codeph>&lt;p></codeph> will
57contain the start flag information; adding a rule to handle images
58in <codeph>&lt;ditaval-startprop></codeph> will cause the image to
59appear at the start of the paragraph content.</p><p>In some cases
60fallthrough processing will not result in valid output; for those
61cases, the flags must be explicitly processed. This is done in the
62XHTML transform for elements like <codeph>&lt;ol></codeph>, because
63fallthrough processing would place images in between <codeph>&lt;ol></codeph> and <codeph>&lt;li></codeph>.
64To handle this, the code processes <codeph>&lt;ditaval-startprop></codeph> before
65starting the element, and <codeph>&lt;ditaval-endprop></codeph> at
66the end. Fallthrough processing is then disabled for those elements
67as children of <codeph>&lt;ol></codeph>.</p></section>
68<example><title>Example DITAVAL</title><p>Assume the following DITAVAL
69file is in use during a build. This DITAVAL will be used for each
70of the following content examples.</p><codeblock>&lt;?xml version="1.0" encoding="UTF-8"?>
71&lt;val>
72 &lt;!-- Define what happens in the case of conflicting styles -->
73 &lt;style-conflict background-conflict-color="red"/>
74
75 &lt;!-- Define two flagging properties that give styles (no image) -->
76 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/>
77 &lt;prop action="flag" att="platform" style="overline" val="win" backcolor="blue"/>
78
79 &lt;!-- Define a property that includes start and end image flags -->
80 &lt;prop action="flag" att="platform" val="linux" style="overline" backcolor="blue">
81 &lt;startflag imageref="startlin.png">&lt;alt-text>Start linux&lt;/alt-text>&lt;/startflag>
82 &lt;endflag imageref="endlin.png">&lt;alt-text>End linux&lt;/alt-text>&lt;/endflag>
83 &lt;/prop>
84
85 &lt;!-- Define a revision that includes start and end image flags -->
86 &lt;revprop action="flag" style="double-underline" val="rev2">
87 &lt;startflag imageref="start_rev.gif">&lt;alt-text>ssssssssssstart&lt;/alt-text>&lt;/startflag>
88 &lt;endflag imageref="end_rev.gif">&lt;alt-text>eeeeeeeeeeeeeend&lt;/alt-text>&lt;/endflag>
89 &lt;/revprop>
90&lt;/val></codeblock></example>
91<example><title>Content example 1: adding style</title><p>Now assume
92the following paragraph exists in a topic. Class attributes are included,
93as they would normally be in the middle of the preprocess routine;
94@xtrf and @xtrc are left off for clarity.</p><codeblock>&lt;p audience="user">Simple user; includes style but no images&lt;/p>
95</codeblock><p>Based on the DITAVAL above, audience="user" results
96in a style with underlining and with a green background. The interpreted
97CSS value is added to @outputclass on <codeph>&lt;ditaval-startprop></codeph>,
98and the actual property definition is included at the start and end
99of the element. The output from the flagging step looks like this
100(with newlines added for clarity, and class attributes added as they
101would appear in the temporary file):</p><p>The resulting file after
102the flagging step looks like this; for clarity, newlines are added,
103while @xtrf and @xtrc are removed:</p><codeblock>&lt;p audience="user" class="- topic/p ">
104 <b>&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "
105 outputclass="background-color:green;text-decoration:underline;">
106 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/>
107 &lt;/ditaval-startprop></b>
108 Simple user; includes style but no images
109 <b>&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop ">
110 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/>
111 &lt;/ditaval-endprop></b>
112&lt;/p></codeblock></example>
113<example><title>Content example 2: conflicting styles</title><p>This
114example includes a paragraph with conflicting styles. When the audience
115and platform attributes are both evaluated, the DITAVAL indicates
116that the background color is both green and blue. In this situation,
117the <codeph>&lt;style-conflict></codeph> element is evaluated to determine
118how to style the content.</p><codeblock>&lt;p audience="user" platform="win">Conflicting styles (still no images)&lt;/p>
119</codeblock><p>The <codeph>&lt;style-conflict></codeph> element results
120in a background color of red, so this value is added to @outputclass
121on <codeph>&lt;ditaval-startprop></codeph>. As above, active properties
122are copied into the generated elements; the <codeph>&lt;style-conflict></codeph> element
123itself is also copied into the generated <codeph>&lt;ditaval-startprop></codeph> element.</p><p>The
124resulting file after the flagging step looks like this; for clarity,
125newlines are added, while @xtrf and @xtrc are removed:</p><codeblock>&lt;p audience="user" platform="win" class="- topic/p ">
126 <b>&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "
127 outputclass="background-color:red;">
128 &lt;style-conflict background-conflict-color="red"/>
129 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/>
130 &lt;prop action="flag" att="platform" style="overline" val="win" backcolor="blue"/>
131 &lt;/ditaval-startprop></b>
132 Conflicting styles (still no images)
133 <b>&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop ">
134 &lt;prop action="flag" att="platform" style="overline" val="win" backcolor="blue"/>
135 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/>
136 &lt;/ditaval-endprop></b>
137&lt;/p>
138</codeblock></example>
139<example><title>Content example 3: adding image flags</title><p>This
140example includes image flags for both @platform and @rev, which are
141defined in DITAVAL <codeph>&lt;prop></codeph> and <codeph>&lt;revprop></codeph> elements.</p><codeblock>&lt;ol platform="linux" rev="rev2">
142 &lt;li>Generate images for platform="linux" and rev="2"&lt;/li>
143&lt;/ol></codeblock><p>As above, the <codeph>&lt;ditaval-startprop></codeph> and <codeph>&lt;ditaval-endprop></codeph> nest
144the active property definitions, with the calculated CSS value on
145@outputclass. The <codeph>&lt;ditaval-startprop></codeph> drops the
146ending image, and <codeph>&lt;ditaval-endprop></codeph> drops the
147starting image. To make document-order processing more consistent,
148property flags are always included before revisions in <codeph>&lt;ditaval-startprop></codeph>,
149and the order is reversed for <codeph>&lt;ditaval-endprop></codeph>.</p><p>The
150resulting file after the flagging step looks like this; for clarity,
151newlines are added, while @xtrf and @xtrc are removed:</p><codeblock>&lt;ol platform="linux" rev="rev2" class="- topic/ol ">
152 <b>&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "
153 outputclass="background-color:blue;text-decoration:underline;text-decoration:overline;">
154 &lt;prop action="flag" att="platform" val="linux" style="overline" backcolor="blue">
155 &lt;startflag imageref="startlin.png">&lt;alt-text>Start linux&lt;/alt-text>&lt;/startflag>
156 &lt;/prop>
157 &lt;revprop action="flag" style="double-underline" val="rev2">
158 &lt;startflag imageref="start_rev.gif">&lt;alt-text>ssssssssssstart&lt;/alt-text>&lt;/startflag>
159 &lt;/revprop>
160 &lt;/ditaval-startprop></b>
161 &lt;li class="- topic/li ">Generate images for platform="linux" and rev="2"&lt;/li>
162 <b>&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop ">
163 &lt;revprop action="flag" style="double-underline" val="rev2">
164 &lt;endflag imageref="end_rev.gif">&lt;alt-text>eeeeeeeeeeeeeend&lt;/alt-text>&lt;/endflag>
165 &lt;/revprop>
166 &lt;prop action="flag" att="platform" val="linux" style="overline" backcolor="blue">
167 &lt;endflag imageref="endlin.png">&lt;alt-text>End linux&lt;/alt-text>&lt;/endflag>
168 &lt;/prop>
169 &lt;/ditaval-endprop></b>
170&lt;/ol></codeblock></example>
171</refbody>
172</reference>
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette