VirtualBox

source: vbox/trunk/src/libs/dita-ot-1.8.5/doc/dev_ref/preprocess-flagging.html@ 99507

最後變更 在這個檔案從99507是 98584,由 vboxsync 提交於 2 年 前

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

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 15.6 KB
 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE html
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4<html xml:lang="en-us" lang="en-us">
5<head>
6<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7<meta name="copyright" content="(C) Copyright 2005"/>
8<meta name="DC.rights.owner" content="(C) Copyright 2005"/>
9<meta name="DC.Type" content="reference"/>
10<meta name="DC.Title" content="Flagging in the toolkit"/>
11<meta name="abstract" content="Beginning with DITA-OT 1.7, flagging support is implemented as a common preprocess module. The module evaluates the DITAVAL against all flagging attributes, and adds DITA-OT specific hints in to the topic when flags are active. Any extended transform type may use these hints to support flagging without adding logic to interpret the DITAVAL."/>
12<meta name="description" content="Beginning with DITA-OT 1.7, flagging support is implemented as a common preprocess module. The module evaluates the DITAVAL against all flagging attributes, and adds DITA-OT specific hints in to the topic when flags are active. Any extended transform type may use these hints to support flagging without adding logic to interpret the DITAVAL."/>
13<meta name="DC.Relation" scheme="URI" content="../dev_ref/DITA-OTPreprocess.html"/>
14<meta name="DC.Relation" scheme="URI" content="../dev_ref/preprocess-topicpull.html"/>
15<meta name="DC.Format" content="XHTML"/>
16<meta name="DC.Identifier" content="flagging"/>
17<meta name="DC.Language" content="en-us"/>
18<link rel="stylesheet" type="text/css" href="../commonltr.css"/>
19<link rel="stylesheet" type="text/css" href="../dita-ot-doc.css"/>
20<title>Flagging in the toolkit</title>
21</head>
22<body id="flagging">
23
24
25<h1 class="title topictitle1">Flagging in the toolkit</h1>
26
27
28<div class="body refbody"><p class="shortdesc">Beginning with DITA-OT 1.7, flagging support is implemented
29as a common preprocess module. The module evaluates the DITAVAL against
30all flagging attributes, and adds DITA-OT specific hints in to the
31topic when flags are active. Any extended transform type may use these
32hints to support flagging without adding logic to interpret the DITAVAL.</p>
33
34<div class="section"><h2 class="title sectiontitle">Evaluating the DITAVAL flags</h2><p class="p">Flagging is
35implemented as a reusable module during the preprocess stage. If a
36DITAVAL file is not used with a build, this step is skipped with no
37change to the file.</p>
38<p class="p">When a flag is active, relevant sections
39of the DITAVAL itself are copied into the topic as a sub-element of
40the current topic. The active flags are enclosed in a pseudo-specialization
41of the <samp class="ph codeph">&lt;foreign&gt;</samp> element (referred to as a pseudo-specialization
42because it is used only under the covers, with all topic types; it
43is not integrated into any shipped document types).</p>
44<dl class="dl">
45<dt class="dt dlterm"><samp class="ph codeph">&lt;ditaval-startprop&gt;</samp></dt>
46
47<dd class="dd">When any flag is active on an element, a <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp> element
48will be created as the first child of the flagged element:<pre class="pre codeblock">&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "&gt;</pre>
49<div class="p">The <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp> element
50will contain the following:<ul class="ul">
51<li class="li">If the active flags should create a new style, that style is included
52using standard CSS markup on the @outputclass attribute. Output types
53that make use of CSS, such as XHTML, can use this value as-is.</li>
54
55<li class="li">If styles conflict, and a <samp class="ph codeph">&lt;style-conflict&gt;</samp> element
56exists in the DITAVAL, it will be copied as a child of <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp>.</li>
57
58<li class="li">Any <samp class="ph codeph">&lt;prop&gt;</samp> or <samp class="ph codeph">&lt;revprop&gt;</samp> elements
59that define active flags will be copied in as children of the <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp> element.
60Any <samp class="ph codeph">&lt;startflag&gt;</samp> children of the properties will
61be included, but <samp class="ph codeph">&lt;endflag&gt;</samp> children will not.</li>
62
63</ul>
64</div>
65</dd>
66
67
68<dt class="dt dlterm"><samp class="ph codeph">&lt;ditaval-endprop&gt;</samp></dt>
69
70<dd class="dd">When any flag is active on an element, a <samp class="ph codeph">&lt;ditaval-endprop&gt;</samp> element
71will be created as the last child of the flagged element:<pre class="pre codeblock">&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop "&gt;</pre>
72<p class="p">CSS
73values and <samp class="ph codeph">&lt;styleconflict&gt;</samp> elements are not included
74on this element.</p>
75<p class="p">Any <samp class="ph codeph">&lt;prop&gt;</samp> or <samp class="ph codeph">&lt;revprop&gt;</samp> elements
76that define active flags will be copied in as children of <samp class="ph codeph">&lt;ditaval-prop&gt;</samp>.
77Any <samp class="ph codeph">&lt;endflag&gt;</samp> children of the properties will
78be included, but <samp class="ph codeph">&lt;startflag&gt;</samp> children will not.</p>
79</dd>
80
81</dl>
82</div>
83
84<div class="section"><h2 class="title sectiontitle">Supporting flags in overrides or custom transform
85types</h2><p class="p">For most transform types, the <samp class="ph codeph">&lt;foreign&gt;</samp> element
86should be ignored by default, because arbitrary non-DITA content may
87not mix well unless coded for ahead of time. If the <samp class="ph codeph">&lt;foreign&gt;</samp> element
88is ignored by default, or if a rule is added to specifically ignore <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp> and <samp class="ph codeph">&lt;ditaval-endprop&gt;</samp>,
89then the added elements will have no impact on a transform. If desired,
90flagging support may be integrated at any time in the future.</p>
91<p class="p">The
92processing described above runs as part of the common preprocess,
93so any transform that uses the default preprocess will get the topic
94updates. To support generating flags as images, XSLT based transforms
95can use default fallthrough processing in most cases. For example,
96if a paragraph is flagged, the first child of <samp class="ph codeph">&lt;p&gt;</samp> will
97contain the start flag information; adding a rule to handle images
98in <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp> will cause the image to
99appear at the start of the paragraph content.</p>
100<p class="p">In some cases
101fallthrough processing will not result in valid output; for those
102cases, the flags must be explicitly processed. This is done in the
103XHTML transform for elements like <samp class="ph codeph">&lt;ol&gt;</samp>, because
104fallthrough processing would place images in between <samp class="ph codeph">&lt;ol&gt;</samp> and <samp class="ph codeph">&lt;li&gt;</samp>.
105To handle this, the code processes <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp> before
106starting the element, and <samp class="ph codeph">&lt;ditaval-endprop&gt;</samp> at
107the end. Fallthrough processing is then disabled for those elements
108as children of <samp class="ph codeph">&lt;ol&gt;</samp>.</p>
109</div>
110
111<div class="example"><h2 class="title sectiontitle">Example DITAVAL</h2><p class="p">Assume the following DITAVAL
112file is in use during a build. This DITAVAL will be used for each
113of the following content examples.</p>
114<pre class="pre codeblock">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
115&lt;val&gt;
116 &lt;!-- Define what happens in the case of conflicting styles --&gt;
117 &lt;style-conflict background-conflict-color="red"/&gt;
118
119 &lt;!-- Define two flagging properties that give styles (no image) --&gt;
120 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
121 &lt;prop action="flag" att="platform" style="overline" val="win" backcolor="blue"/&gt;
122
123 &lt;!-- Define a property that includes start and end image flags --&gt;
124 &lt;prop action="flag" att="platform" val="linux" style="overline" backcolor="blue"&gt;
125 &lt;startflag imageref="startlin.png"&gt;&lt;alt-text&gt;Start linux&lt;/alt-text&gt;&lt;/startflag&gt;
126 &lt;endflag imageref="endlin.png"&gt;&lt;alt-text&gt;End linux&lt;/alt-text&gt;&lt;/endflag&gt;
127 &lt;/prop&gt;
128
129 &lt;!-- Define a revision that includes start and end image flags --&gt;
130 &lt;revprop action="flag" style="double-underline" val="rev2"&gt;
131 &lt;startflag imageref="start_rev.gif"&gt;&lt;alt-text&gt;ssssssssssstart&lt;/alt-text&gt;&lt;/startflag&gt;
132 &lt;endflag imageref="end_rev.gif"&gt;&lt;alt-text&gt;eeeeeeeeeeeeeend&lt;/alt-text&gt;&lt;/endflag&gt;
133 &lt;/revprop&gt;
134&lt;/val&gt;</pre>
135</div>
136
137<div class="example"><h2 class="title sectiontitle">Content example 1: adding style</h2><p class="p">Now assume
138the following paragraph exists in a topic. Class attributes are included,
139as they would normally be in the middle of the preprocess routine;
140@xtrf and @xtrc are left off for clarity.</p>
141<pre class="pre codeblock">&lt;p audience="user"&gt;Simple user; includes style but no images&lt;/p&gt;
142</pre>
143<p class="p">Based on the DITAVAL above, audience="user" results
144in a style with underlining and with a green background. The interpreted
145CSS value is added to @outputclass on <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp>,
146and the actual property definition is included at the start and end
147of the element. The output from the flagging step looks like this
148(with newlines added for clarity, and class attributes added as they
149would appear in the temporary file):</p>
150<p class="p">The resulting file after
151the flagging step looks like this; for clarity, newlines are added,
152while @xtrf and @xtrc are removed:</p>
153<pre class="pre codeblock">&lt;p audience="user" class="- topic/p "&gt;
154 <strong class="ph b">&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "
155 outputclass="background-color:green;text-decoration:underline;"&gt;
156 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
157 &lt;/ditaval-startprop&gt;</strong>
158 Simple user; includes style but no images
159 <strong class="ph b">&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop "&gt;
160 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
161 &lt;/ditaval-endprop&gt;</strong>
162&lt;/p&gt;</pre>
163</div>
164
165<div class="example"><h2 class="title sectiontitle">Content example 2: conflicting styles</h2><p class="p">This
166example includes a paragraph with conflicting styles. When the audience
167and platform attributes are both evaluated, the DITAVAL indicates
168that the background color is both green and blue. In this situation,
169the <samp class="ph codeph">&lt;style-conflict&gt;</samp> element is evaluated to determine
170how to style the content.</p>
171<pre class="pre codeblock">&lt;p audience="user" platform="win"&gt;Conflicting styles (still no images)&lt;/p&gt;
172</pre>
173<p class="p">The <samp class="ph codeph">&lt;style-conflict&gt;</samp> element results
174in a background color of red, so this value is added to @outputclass
175on <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp>. As above, active properties
176are copied into the generated elements; the <samp class="ph codeph">&lt;style-conflict&gt;</samp> element
177itself is also copied into the generated <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp> element.</p>
178<p class="p">The
179resulting file after the flagging step looks like this; for clarity,
180newlines are added, while @xtrf and @xtrc are removed:</p>
181<pre class="pre codeblock">&lt;p audience="user" platform="win" class="- topic/p "&gt;
182 <strong class="ph b">&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "
183 outputclass="background-color:red;"&gt;
184 &lt;style-conflict background-conflict-color="red"/&gt;
185 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
186 &lt;prop action="flag" att="platform" style="overline" val="win" backcolor="blue"/&gt;
187 &lt;/ditaval-startprop&gt;</strong>
188 Conflicting styles (still no images)
189 <strong class="ph b">&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop "&gt;
190 &lt;prop action="flag" att="platform" style="overline" val="win" backcolor="blue"/&gt;
191 &lt;prop action="flag" att="audience" style="underline" val="user" backcolor="green"/&gt;
192 &lt;/ditaval-endprop&gt;</strong>
193&lt;/p&gt;
194</pre>
195</div>
196
197<div class="example"><h2 class="title sectiontitle">Content example 3: adding image flags</h2><p class="p">This
198example includes image flags for both @platform and @rev, which are
199defined in DITAVAL <samp class="ph codeph">&lt;prop&gt;</samp> and <samp class="ph codeph">&lt;revprop&gt;</samp> elements.</p>
200<pre class="pre codeblock">&lt;ol platform="linux" rev="rev2"&gt;
201 &lt;li&gt;Generate images for platform="linux" and rev="2"&lt;/li&gt;
202&lt;/ol&gt;</pre>
203<p class="p">As above, the <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp> and <samp class="ph codeph">&lt;ditaval-endprop&gt;</samp> nest
204the active property definitions, with the calculated CSS value on
205@outputclass. The <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp> drops the
206ending image, and <samp class="ph codeph">&lt;ditaval-endprop&gt;</samp> drops the
207starting image. To make document-order processing more consistent,
208property flags are always included before revisions in <samp class="ph codeph">&lt;ditaval-startprop&gt;</samp>,
209and the order is reversed for <samp class="ph codeph">&lt;ditaval-endprop&gt;</samp>.</p>
210<p class="p">The
211resulting file after the flagging step looks like this; for clarity,
212newlines are added, while @xtrf and @xtrc are removed:</p>
213<pre class="pre codeblock">&lt;ol platform="linux" rev="rev2" class="- topic/ol "&gt;
214 <strong class="ph b">&lt;ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop "
215 outputclass="background-color:blue;text-decoration:underline;text-decoration:overline;"&gt;
216 &lt;prop action="flag" att="platform" val="linux" style="overline" backcolor="blue"&gt;
217 &lt;startflag imageref="startlin.png"&gt;&lt;alt-text&gt;Start linux&lt;/alt-text&gt;&lt;/startflag&gt;
218 &lt;/prop&gt;
219 &lt;revprop action="flag" style="double-underline" val="rev2"&gt;
220 &lt;startflag imageref="start_rev.gif"&gt;&lt;alt-text&gt;ssssssssssstart&lt;/alt-text&gt;&lt;/startflag&gt;
221 &lt;/revprop&gt;
222 &lt;/ditaval-startprop&gt;</strong>
223 &lt;li class="- topic/li "&gt;Generate images for platform="linux" and rev="2"&lt;/li&gt;
224 <strong class="ph b">&lt;ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop "&gt;
225 &lt;revprop action="flag" style="double-underline" val="rev2"&gt;
226 &lt;endflag imageref="end_rev.gif"&gt;&lt;alt-text&gt;eeeeeeeeeeeeeend&lt;/alt-text&gt;&lt;/endflag&gt;
227 &lt;/revprop&gt;
228 &lt;prop action="flag" att="platform" val="linux" style="overline" backcolor="blue"&gt;
229 &lt;endflag imageref="endlin.png"&gt;&lt;alt-text&gt;End linux&lt;/alt-text&gt;&lt;/endflag&gt;
230 &lt;/prop&gt;
231 &lt;/ditaval-endprop&gt;</strong>
232&lt;/ol&gt;</pre>
233</div>
234
235</div>
236
237<div class="related-links">
238<div class="familylinks">
239<div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../dev_ref/DITA-OTPreprocess.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>
240<div class="previouslink"><strong>Previous topic:</strong> <a class="link" href="../dev_ref/preprocess-topicpull.html" title="The topicpull step pulls content into &lt;xref&gt; and &lt;link&gt; elements. This step is implemented in XSLT.">Pull content into topics (topicpull)</a></div>
241</div>
242</div>
243
244</body>
245</html>
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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