DITA conditional filtering allows you to choose what to show and hide in your DITA topics when they are processed for output.
You mark DITA elements for filtering by adding special conditional attributes to elements; the value you use with a conditional attribute is used to determine whether the element should be hidden (filtered out) or shown.
- Content is intended for a specific group of readers. The audience can be seen a number of different ways; it might be the experience level, role, security clearance, or some other way of grouping potential readers.
- Content is specific to a particular hardware or software platform.
- Content is specific to a particular product.
- Content is specific to a custom aspect.
For example, you might use the platform attribute to indicate whether content is intended for iPhone or Android users:
<p platform="android">Visit Google Play for more information.</p> <p platform="iphone">Visit the App Store for more information.</p>
When generating output for Android users, you can tell the DITA filtering mechanism to hide elements where platform=”iphone” and show elements where platform=”android”. To generate output for iPhone users, you show elements where platform has the value “iphone” and hide elements where platform has the value “android”. (How to hide and show content is described later in this lesson.)
The names of the attributes are defined in the DITA specification. They are a suggestion about how you might use them, but you should not feel locked into using them specifically for audience, platform, or product filtering; it’s up to you to determine how you want to use each one.
As with the attributes themselves, the values you use with each of the conditional attributes are up to you to decide. You can use any characters you want for the conditional attribute values, except for the space character. Case is important in the conditional attribute values, so choose one form of capitalization and use it consistently.
You can specify multiple values in these attributes; separate each value with one or more spaces.
The single most important thing, however, is that all content creators in your group, team, company, or organization agree on the purpose of each of the attributes and the values to use with the attributes.
Note: The four attributes listed here are just a starting point. It is possible to use DITA specialization to create additional conditional attributes that have meaning for your content. The DITA specification identifies another conditional attribute: props. This attribute is used as the basis for specialization.
Keep in mind that filtering of elements extends to DITA map elements, such as <topicref> and <mapref>. This way, you can use conditional attributes and filtering to remove entire topics or chapters from your output.