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:

With the attribute action, DITA gives the element <prop> these processing options:

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 attributes rev to process.

  • action: defines the method for processing the element marked with the attribute. Possible values for the attribute action are listed below.

  • color: if the attribute action is set to flag (see below), flagged text uses the value defined in the attribute color. The color is a six-digit hexadecimal number, as in HTML, written in lowercase and preceded by #.

  • backcolor: if the attribute action is set to flag (see below), the flagged text’s background uses the value defined in the attribute color. The color is a six-digit hexadecimal number, as in HTML, written in lowercase and preceded by #.

  • style: if the attribute action is set to flag (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 attribute action is set to flag (see below), the content of elements containing the attribute changebar receives 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 value include is the default.

  • passthrough: the element’s content appears in the output. The value of the attribute passthrough is 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.

  

 

 

 

back to top