Variables using conref and filtering
Single-source publishing relies heavily on the concept of variables. While DITA does not have a specifically named variables feature, it does readily support variables functionality.
In the context of single-source publishing, a variable is an element that is used throughout the content of a publication in place of a normal fixed unit of text. When the document is published, the variable element is replaced with a nominated phrase or block of text. Variables allow numerous text changes to be made with very little effort.
For example, documentation might be required for a product sold under
two brand names,
Legend and
Liberty. Instead of
hard-coding the product name, a variable of
brand_name might be used whenever the product is
mentioned in the text. During the publishing of the documentation for the
Liberty brand, the
brand_name variable is replaced with the word
Liberty.
In DITA, variables are implemented through the
conref and
ditaval filtering features. The variable is coded as
conreffed element, such as
<ph conref="abc.dita#product" />
. The
conref source is coded using metadata attributes that can be
used for filtering, such as:
<ph id="product">
<ph product="Liberty">Liberty</ph>
<ph product="Legend">Legend</ph>
</ph>
When the content is published, the conditional filtering in the ditaval can be set so that only the applicable product name element is included in the output.