Attributes for Content Reuse

Explore DITA attributes for conditional processing and content reuse through conref and copy-to mechanisms.

DITA provides sophisticated attribute systems that enable precise control over when and how content appears in different publications. These attributes act as filters during the publishing process, allowing single-source content to serve multiple audiences and scenarios.

Conditional Processing Attributes

These attributes allow you to include or exclude content based on specific conditions, supporting sophisticated conditional publishing.

  • audience: Targets user groups (e.g., admin, enduser). Example:
    
    <p audience="admin">Use the command line interface...</p>
          
  • platform: Targets operating systems (e.g., windows, mac). Example:
    
    <p platform="windows">Double-click the installer...</p>
          
  • product: Targets specific product versions. Example:
    
    <p product="professional">Configure single sign-on...</p>
          
  • otherprops: Custom filtering for specific needs. Example:
    
    <note otherprops="gdpr">European customers must consent...</note>
          

DITA processors support complex filtering using Boolean logic and multiple attributes.

conref Attribute

The conref attribute enables direct reuse of content elements from other topics. Referenced content stays synchronized across uses.

Sample Usage:


<task id="userlogin">
  <title>Log In</title>
  <shortdesc>This task guides users through logging in.</shortdesc>
  <taskbody>
    <steps>
      <step conref="snippets.dita#snippets/loginstep"/>
    </steps>
  </taskbody>
</task>
  

Best Practices: Organize reusable content, use meaningful IDs, maintain appropriate granularity, and manage changes carefully.

copy-to Attribute

The copy-to attribute creates topic copies with different contexts or metadata while maintaining original content integrity.

When to Use: When content needs to appear in multiple locations with distinct navigational or URL contexts.

conref vs. copy-to Comparison:

Feature conref copy-to
Granularity Element-level reuse Topic-level reuse
Synchronization Automatic Manual
File Proliferation No Yes
Context/URL Same context New navigation
Complexity Simpler More complex

Decision Framework: Use conref for embedded reuse with synchronization, and copy-to for multiple locations with different contexts or URLs.