How are conditional processing attributes defined in DITA?
Conditional processing attributes in DITA are used to specify under what conditions certain content should be included or excluded in the final output. These attributes allow for control over content variations based on conditions such as audience, product version, or output format, ensuring that content can be reused efficiently. The primary attributes involved in conditional processing are @conref
and @conkeyref
.
@conref
Attribute:
The @conref
attribute is used to reference content from another DITA topic while applying conditional processing.
It enables inclusion of content from one topic into another, and conditions to be specified to determine when the content should be included.
The content to be included is defined in the referenced topic, and it may contain conditional processing instructions.
@conkeyref
Attribute:
The @conkeyref
attribute is used to link to conditions defined in a DITA map, making it possible to control when and how content is included based on these conditions.
It references a key or key reference defined in the DITA map, and this key represents specific conditions.
Each key can have multiple values, each associated with different conditions. Conditions can be anything from audience segments to product versions.
Defining Conditions:
Conditions are defined at the DITA map level using keys and their values. Keys represent the various criteria, and values represent the conditions themselves. For example, a key named “audience” could have values like “beginner” and “advanced” to represent different audience segments.
Example:
A software documentation project needs to include different content based on the target audience, either “beginner” or “advanced.”
In the DITA Map:
<map>
<keydef keys="audience" keyscope="local">
<topicmeta>
<keywords>
<keyword keyname="beginner">Beginner</keyword>
<keyword keyname="advanced">Advanced</keyword>
</keywords>
</topicmeta>
</keydef>
</map>
In the DITA Topic:
<p conref="beginner_topic.dita" conkeyref="audience=beginner">This content is for beginners.</p>
<p conref="advanced_topic.dita" conkeyref="audience=advanced">This content is for advanced users.</p>
In this example:
- A key named “audience” is defined in the DITA map.
- Two values, “beginner” and “advanced,” are associated with the “audience” key to represent the conditions.
- The
@conref
attribute references different topics, “beginner_topic.dita” and “advanced_topic.dita,” each containing content relevant to their respective audience segments. - The
@conkeyref
attribute specifies which condition (audience) to use when including these topics.