How can attributes be used to control the display of topics in DITA maps?
Yes, attributes can be used to control the display of topics in DITA maps. This feature allows content creators to define conditions under which topics are included or excluded from the output, providing flexibility in generating tailored documentation for different purposes or audiences.
Using Attributes to Control Topic Display
Defining Conditions:
Conditions are defined based on specific criteria, such as audience, product version, or publication type. Conditions can be predefined (e.g., audience=”beginner”) or custom (e.g., mycondition=”custom_value”). Conditions are typically specified in the DITA map’s specialization schema.
Associating Conditions with Topics:
Topics are associated with conditions using attributes like @props, @audience, @product, or custom attributes. For example, a topic intended for “beginner” users may have the attribute audience=”beginner.”
Configuring Publishing Output:
During the publishing or output generation process, the DITA processor evaluates the conditions associated with topics. Topics that meet the specified conditions are included in the output, while topics that don’t meet the conditions are excluded. Output formats can be customized for different conditions. For example, content for “beginner” users may have a different style or structure than content for “advanced” users.
Example:
A DITA map for software documentation includes topics for different audience levels: “beginner,” “intermediate,” and “advanced.” Which topics need to be included or excluded in the output based on the audience.
Define Conditions:
In your DITA specialization schema, you define conditions for each audience level, such as audience=”beginner,” audience=”intermediate,” and audience=”advanced.”
Associate Conditions with Topics:
In your DITA map, you associate each topic with the appropriate audience condition. For example:
<map>
<topicref href="beginner-topic.dita" audience="beginner" />
<topicref href="intermediate-topic.dita" audience="intermediate" />
<topicref href="advanced-topic.dita" audience="advanced" />
</map>
Configure Publishing Output:
When generating documentation, the DITA processor evaluates the audience conditions. If you generate documentation for “beginner” users, only the “beginner-topic.dita” topic will be included in the output, and the content can be styled or structured accordingly. Similarly, you can generate documentation tailored to “intermediate” or “advanced” users by specifying the corresponding audience condition.