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