XML technologies / DITA / Conditional processing / The ditaval file
(Excerpt from “DITA – Der neue Standard für Technische Dokumentation” by Johannes Hentrich)
Conditional processing in DITA is controlled by a file called ditaval. A file ditaval specifies the attributes and values used for conditional processing. The file ditaval also defines the processing rules to apply.
A file ditaval is an XML file with the element <val> as its root.
<?xml version="1.0" encoding="UTF-8"?>
<val> </val>The element <val> can contain one or more elements <prop> and elements <revprop>, as the following example shows:
<?xml version="1.0" encoding="UTF-8"?>
<val>
<prop/>
<prop/>
<revprop/>
</val>An element <prop> defines the attributes and values subject to conditional processing. It also specifies the method: filtering or flagging content. Information about the element <revprop> is provided in Flagging content.
The element <prop> provides these attributes:
att: specifies the attributes used to filter and flag content. Besides DITA’s standard attributes, specialized attributes can also be used. They derive from the standard attributeprops. The section Domain attributes shows how to specialize the attributeprops.val: contains the values the attributeattcan take.action: defines the method for processing the element marked with the attribute. Possible values for the attributeactionare listed below.color: if the action attribute is set to flag (see below), the flagged text is output using the value defined in the attribute color. The color value is a six-digit hexadecimal number, as in HTML, written in lowercase and preceded by #.backcolor: if the action attribute is set to flag (see below), the flagged text’s background uses the value defined in the color attribute. The color value is a six-digit hexadecimal number, as in HTML, written in lowercase and preceded by #.style: if the action attribute is set to flag (see below), the text can receive this typographic markup:
- italic (italics)
- bold (bold)
- overlined (overline)
- underlined (underline)
- double-underlined (double-underline)
With the attribute action, DITA gives the element <prop> these processing options:
include: the element’s content appears in the output. The valueincludeis the default.exclude: the element’s content does not appear in the output.passthrough: the element’s content appears in the output. The value of the attributepassthroughis passed on to other processing mechanisms.flag: content appears in the output and is flagged there, for example with a graphic.
The next two sections give examples of filtering and flagging content with a file ditaval.
Filtering content
The following example shows a simple ditaval file for filtering content:
<?xml version="1.0" encoding="UTF-8"?>
<val>
<prop att="audience" val="user" action="exclude"/>
</val>The content of every element whose attribute audience has the value user is omitted from the output.
With this ditaval file, content of elements such as
<steps audience="user expert">...</steps>is not filtered out unless the value expert is also excluded. The file ditaval would then look like this:
<?xml version="1.0" encoding="UTF-8"?>
<val>
<prop att="audience" val="user" action="exclude"/>
<prop att="audience" val="expert" action="exclude"/>
</val>To exclude the element
<steps audience="user expert">...</steps> for the value user of the attribute audience and include it for the value expert, use the following file ditaval:
<?xml version="1.0" encoding="UTF-8"?>
<val>
<prop att="audience" val="user" action="exclude"/>
<prop att="audience" val="expert" action="include"/>
</val>Flagging content
A file ditaval for flagging content is structured like a file ditaval for filtering, except that the attribute action is set to flag.
<?xml version="1.0" encoding="UTF-8"?>
<val>
<prop att="audience" val="user" action="flag" color="#cceecc"/>
</val>Text in elements whose attribute audience has the value user appears in the output in the color cceecc.
Content of elements such as
<steps audience="user expert">...</steps> is always flagged in the output with the specified file ditaval, regardless of whether the attribute value expert has a definition. With multiple attribute values, a definition for any one value is enough to flag the content.
Flagging can cause conflicts when parent content should be marked differently from child content. For example, in a task topic the elements <step> with the attribute audience set to expert may use a different color from their parent elements <steps>. The element <style-conflict> resolves this conflict. The attribute foreground-conflict-color specifies the text color when several colors are defined. The attribute background-conflict-color specifies the background color when several are defined.
<val>
<style-conflict background-conflict-color="#FFFFFF"/>
</val>The element <startflag> positions a graphic at the start of flagged content in the output.
<?xml version="1.0" encoding="UTF-8"?>
<val>
<prop att="audience" val="user" action="flag">
<startflag imageref="../special.gif"/>
</prop>
</val>Similarly, the element <endflag> positions a graphic at the end of flagged content in the output.
<?xml version="1.0" encoding="UTF-8"?>
<val>
<prop att="audience" val="user" action="flag">
<endflag imageref="../obacht.gif"/>
</prop>
</val>Both the element <startflag> and the element <endflag> provide the element <alt-text> for alternative text describing the graphics.
Conditional processing of the attribute rev is special. Processing for elements with an attribute rev is defined not in the element <prop> but in the element <revprop>.
The element <revprop> provides these attributes:
val: contains the values of the attributesrevto process.action: defines the method for processing the element marked with the attribute. Possible values for the attributeactionare listed below.color: if the attributeactionis set toflag(see below), flagged text uses the value defined in the attributecolor. The color is a six-digit hexadecimal number, as in HTML, written in lowercase and preceded by #.backcolor: if the attributeactionis set toflag(see below), the flagged text’s background uses the value defined in the attributecolor. The color is a six-digit hexadecimal number, as in HTML, written in lowercase and preceded by #.style: if the attributeactionis set toflag(see below), flagged text can receive the following typographic markup:
- italic (italics)
- bold (bold)
- overlined (overline)
- underlined (underline)
- double-underlined (double-underline)
changebar: if the attributeactionis set toflag(see below), the content of elements containing the attributechangebarreceives a change bar in the output, where supported.
With the attribute action, DITA gives the element <revprop> these processing options:
include: the element’s content appears in the output. The valueincludeis the default.passthrough: the element’s content appears in the output. The value of the attributepassthroughis passed on to other processing mechanisms.flag: content appears in the output and is flagged with colored text or a graphic.
The following example shows a file ditaval that flags two revision states in different colors.
<?xml version="1.0" encoding="UTF-8"?>
<val>
<revprop val="revion1" action="flag" backcolor="#eeddcc"/>
<revprop val="revion2" action="flag" backcolor="#ccddcc"/>
</val>As with the element <prop>, the element <revprop> also provides the elements <startflag>, <endflag> and <alt-text> to add graphics to flagged content.
Copyright © 2008 XLcontent Verlag
You may print the online version for your private use.
Otherwise, this chapter from “DITA - Der neue Standard für Technische Dokumentation” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
XLcontent Verlag, Pflegerstraße 40, 81247 München