Using conditional processing

Attributes used for conditional processing

The following attributes for conditional processing are available on most DITA elements:

Attribute Definition
product The product that is the subject of the content, or to which the content applies.
platform The platform (for example, Windows or UNIX) on which the product is deployed.
audience The intended audience for the content.
rev The revision or draft during which the content was added or changed. You can only flag revisions, not exclude them.
otherprops Anything else.

Each attribute takes zero or more space-delimited string values. For example, you can use the product attribute to identify that an element applies to two particular products.

At processing time, specify the values you want to exclude and the values you want to flag.

Setting conditions

You can define what to do with these values in a .ditaval filtering file.

Specify the filter file at processing time by entering the /filter:{args.input.valfile} output option to name the .ditaval file that has these entries.

Excluding information

Specify the attribute and value you want to exclude. For example, exclude when audience="admin". For an element to be excluded, all the values in at least one attribute must be set to exclude. For example, if a paragraph applies to two audiences (audience="admin programmer") both values must be set to exclude in the filtering file before the paragraph is excluded.

You cannot exclude revisions, only choose whether or not to flag them.

Flagging information

Specify the attribute and value you want to flag. On output, the element will be flagged with the image you specify, or, in the case of revisions, with the method you specify. For an element to be flagged, at least one flagged value must be present. For example, if a paragraph applies to two audiences, either one set to flag will flag the element.

Example

Given this source:
<ul>
  <li audience="admin programmer">
    This is important for lots of reasons.
  </li> 
  <li audience="programmer">
    This is only important to programmers.
  </li>
  <li audience="programmer" platform="unix">
    This is important only to UNIX programmers. 
  </li>
  <li platform="unix">
    This applies on UNIX.
  </li>
</ul>
And given this filter file:
Attribute Value Action Flag
audience programmer exclude  
platform unix flag ../images/ngunix.png
You should get this output:

  • This is important for lots of reasons.
  • This applies on UNIX.

The first list item remains because it applies to an administrator and programmer audience. The second list item is removed because it applies to programmers only, and programmer-specific information has been excluded. The third list item is removed because it applies to programmers as well: the fact that it applies to the UNIX platform does not save it from exclusion. The fourth list item is flagged based on its platform attribute.