How are related topics and content linked in DITA XML?
Linking related topics and content in DITA XML is a fundamental aspect of creating structured and interconnected documentation. DITA offers several mechanisms to establish these links effectively, ensuring a seamless reading experience for users.
1. Cross-References: Cross-references are commonly used in DITA to link to related topics. They allow you to refer readers to other sections or topics within the documentation. Cross-references are typically created using the <xref> element, and they can include attributes to specify the target topic, such as @href, @scope, and @format. These elements ensure that your links are accurately directed to the appropriate content.
Example:
<xref href="related-topic.dita">Learn more about the related topic.</xref>
In this example, the <xref> element links to a topic titled “related-topic.dita,” providing additional information to the reader.
2. Key References: DITA allows you to create key references to link to related topics based on key definitions. This method is useful when you want to link to specific content without worrying about the topic’s location or file name. Key references utilize the <keyword> element to define the key, and you can use the @keyref attribute within <xref> to link to it.
Example:
<keyword keyref="related-key">Important Information</keyword>
...
<xref keyref="related-key">Read important details here.</xref>
Here, a key reference is created with the key “related-key,” and an <xref> element links to it without specifying a file or topic name directly.
3. Relationship Tables: DITA supports the use of relationship tables, which are a more structured way to link related topics. Relationship tables define relationships between topics, such as parent-child or sibling relationships, and these relationships can be leveraged in the generation of navigation menus and hierarchical TOCs.
Example:
<reltable>
<relrow>
<relcell>Parent Topic</relcell>
<relcell>Child Topic 1</relcell>
</relrow>
<relrow>
<relcell>Parent Topic</relcell>
<relcell>Child Topic 2</relcell>
</relrow>
</reltable>
In this example, a relationship table specifies that “Parent Topic” has two child topics: “Child Topic 1” and “Child Topic 2.”
By utilizing these methods, you can effectively establish links between related topics and content in DITA XML, enhancing the structure and navigation of your documentation.