Can conkeyref be used for conditional content reuse in DITA?

Conkeyref (conditional key reference) stands as a potent tool within DITA to reference and reuse content. It permits the conditional reuse of content, allowing for content inclusion or exclusion based on designated conditions or key references.

The usage of conkeyref requires the assignment of keys to elements or attributes within DITA topics. These keys function as markers for specific content earmarked for reuse. In the target topic, these keys are referenced through conkeyref, specifying the content to be conditionally reused. Conkeyref can also be used with attributes. For example, it is possible to conditionally reuse the value of an attribute based on a key reference.

Example

A DITA topic contains information on a software application, and the intent is to reuse this content for various operating systems. Conkeyref can be employed for this purpose:

Source Topic (Original Content)


        <software>
          <name>AwesomeApp</name>
          <description conkey="os_windows">This software is compatible with Windows.</description>
          <description conkey="os_mac">This software is compatible with macOS.</description>
        </software>
    

In the source topic, keys, such as “os_windows” and “os_mac,” have been assigned to descriptions based on the associated operating systems using the conkey attribute.

Target Topic (Conditional Reuse)


        <software>
          <name conkeyref="os_windows">AwesomeApp</name>
          <description conkeyref="os_windows">This software is compatible with Windows.</description>
        </software>
    

In the target topic, conkeyref is employed to reference the specific key, in this case, “os_windows.” This denotes the desire to include content related to Windows, ensuring that only content associated with “os_windows” will be reused while content related to macOS is excluded.