How does the @platform attribute affect conditional processing in DITA?

The @platform attribute in DITA XML is used to control conditional processing based on the target platform or output format. It allows you to specify different content or processing instructions for various platforms or devices, ensuring that your documentation is tailored to the specific needs of each platform. This attribute is a powerful tool for content reuse and customization, enhancing the flexibility and efficiency of your documentation workflow.

Conditional Content Based on @platform Attribute

When you assign the @platform attribute to elements or topics in your DITA document, you can indicate which platforms the content is intended for. For example, you might have content that’s relevant for web, mobile, and print outputs. By using the @platform attribute, you can specify that certain content is only included or excluded for specific outputs.

Example:

Here’s an example of how the @platform attribute can be used to conditionally process content for different platforms:


<topic id="topic1" platform="web mobile print">
  <title>Product Features</title>
  <body>
    <p>This is common content for all platforms.</p>
    <p platform="web">This content is specific to the web output.</p>
    <p platform="mobile">This content is specific to the mobile output.</p>
    <p platform="print">This content is specific to the print output.</p>
  </body>

In this example, the @platform attribute is used to define content variations for web, mobile, and print platforms. The DITA processor will include or exclude content based on the platform specified during processing, allowing you to create platform-specific documentation efficiently.