Overview
DITA provides features that allow you to use text in multiple contexts. Reusing text (single sourcing) allows you to author something once and deploy it in multiple places
Some methods for reuse include:
- Conditional processing – You can selectively filter content in and out of maps and topics by applying metadata values. Doing so lets alter the content to fit the current content.
- Content references – You can share the content of an element into multiple topics.
- Topic and map reuse – You can use the same topic or map in multiple deliverables.
Conditional processing attributes
Conditional processing attributes allow you to filter the content in a topic based on metadata that you enter. It enables the reuse of the same topic in multiple contexts (single-sourcing)
For example, assume that you have two versions of a cellphone. One cellphone has more screen icons than the other phone. In a reference topic, you could apply conditional processing values to the icons to the more feature-rich phones to identify the model. Doing so would allow you to document all of the icons in one file and to share the definitions for the icons that both phones have. However, you could filter out the unique icons from the user guide for the simpler cellphone when publishing the output.
DITA supports the following conditional processing attributes for filtering content:
- audience – Identifies the audience for the tagged text (such as installers, programmers, novice users, expert users and so on)
- platform – Identifies operating systems (such as Windows or Linux)
- product – Identifies product or component
- props – Acts as generic attribute (used to extend DITA)
- otherprops – Includes miscellaneous values that do not fit in the other categories
Examples:
<p product=“MyProduct”>This product….</p>
<step audience=“expert”><cmd>Do this</cmd></step>
Define the conditional processing values that you want to use up front.
For example, you might identify relevant audiences and product models for your cellphone documentation:
Attribute |
Values |
audience |
expert
novice |
product |
modelA
modelB |
You do not need to use all conditional processing attributes for a single element.
Example
Assume that you have a definition list of icons with different product attributes applied, depending on the model of the product to which the icon applies.
<dl>
<dlentry product="modelA modelB">
<dt>Icon 1</dt>
<dd><p>description of icon 1</p></dd>
</dlentry>
<dlentry product="modelA modelB">
<dt>Icon 2</dt>
<dd><p>Description of icon 2</p></dd>
</dlentry>
<dlentry product="modelB">
<dt>Icon 3</dt>
<dd><p>Description of icon 3</p></dd>
</dlentry>
<dlentry product="modelA">
<dt>Icon 4</dt>
<dd><p>Description of icon 4</p></dd>
</dlentry>
<dlentry>
<dt>Icon 5</dt>
<dd><p>Description of icon 5</p></dd>
</dlentry>
</dl>
If you specify the following value to publish: |
The following definitions appear in output: |
modelA |
Icon 1, Icon 2, Icon 4,
and Icon 5 |
modelB |
Icon 1, Icon 2, Icon 3,
and Icon 5 |
In this example, you can see:
-
Multiple conditions – more than one value for an attribute. If either value is true, the content is included in output.
<p product=“modelA modelB”>This paragraph…</p>
-
Compound condition – more than one attribute applied to the element. If either of the values is false, the content is not included.
<step audience=“expert” product=“modelA”><cmd>Do this..</cmd></step>
Creating content references
Using a content reference (conref) enables you to pull the content of an element in one topic into the same type of element in another topic.
Examples of things you might use a content reference for include:
- A product name
- A step that occurs in multiple tasks
- A menu option name that might change
<p><ph id="sugar">sugar</ph></p>
<p>1 to 2 tablespoons white <ph conref="myconreff.dita#conc_wj/sugar"/></p>
Store the shared elements in a separate file. Many topics can point to the shared location and use the content of the element.
If you change the shared information in the source element, any conrefs that point to that element will be updated with the changes.
What can’t be shared as a conref? You can’t include any element that isn’t valid it the current context! For example, you can’t put a <step> element in a concept topic.
Creating the shared content in the source file
- Create a topic to contain the shared content.
- Provide a title and short description for the shared content file to indicate that the topic is used to contain shared content.
- Add the element that you want to share (for example, a paragraph, a note or so on).
- Add an ID attribute to the element.
- Save your file.
Tip: Keep your shared content in a separate file. Doing so allows you to easily identify what is shared content.
Inserting the content reference in the target file
- Position your cursor where you want to insert the shared content.
- Select DITA > Insert Content Reference.
- In the Insert Content Reference window, click the folder next to URL, navigate to your concept topic, and click OK.
- In the Target ID list, select the element that you want to include.
- Click OK to insert the shared content.