Can topics in a DITA map be conditionally included based on output requirements?

In DITA maps, topics can be conditionally included or excluded based on output requirements using conditional processing attributes. These attributes allow authors to customize content for specific output formats, audiences, or conditions without creating separate copies of the content.

Conditional Inclusion in DITA Maps

Conditional inclusion of topics in a DITA map is accomplished through the use of conditional processing attributes, typically the conref, conkeyref, or props attributes, applied to <topicref> elements within the map. These attributes are set based on specific conditions or values, allowing topics to be included or excluded from output based on criteria like audience type, output format (PDF, HTML, etc.), product versions, or other factors. For example, a single DITA topic that includes details relevant to both novice and advanced users can use conditional attributes to include only the relevant content for each audience during output generation.

Example

A DITA map for software documentation contains content which should be conditionally included or excluded for different product versions.


<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map>
  <title>Product Documentation</title>

  <topicref href="introduction.dita" />

  <!-- Include for version 2.0 -->
  <topicref href="new-features.dita" conkeyref="product-version" conaction="include" conref="2.0" />

  <!-- Include for version 3.0 -->
  <topicref href="new-features.dita" conkeyref="product-version" conaction="include" conref="3.0" />

  <topicref href="user-guide.ditamap" />
</map>
    

In this example:

  • The DITA map includes a topic, “introduction.dita,” that is relevant for all product versions.
  • The topic “new-features.dita” contains content about new features in the software. This topic is reused for both version 2.0 and 3.0 of the product. Conditional processing attributes are applied to the <topicref> elements to include the relevant version-specific content. The conkeyref attribute, set to “product-version,” specifies the condition key to use. The conref attribute indicates the specific condition value to include, and the conaction attribute defines the action to take based on the condition. In this case, the topic will be included in the output for the respective product version.