Skriftlig Info ➜ DITA publishing ➜ DITA variables ➜ About variables in DITA
DITA variables
Variable definitions using library topics
Variable definitions using topic maps
Prosedyrer
Defining a variable in a library topic
Inserting a variable from a library topic
Inserting the library topic into the publication
Defining a variable in a topic map
In many cases, a specific word, term or proper name (for example, the name of the product) makes it impossible for a fragment to be used in several places.
This gives us a dilemma.
To reuse a text fragment in many different contexts, we use variables in the text.
Variables in a text can be compared to the variables defined in software. These variables are normally defined early in the source code, and used throughout the application.
At first: What is a variable?
A variable (often referred to as text entity, variable or keyword) is a independent fragment that contains a value in the form of a text. This fragment can be defined as part of the meta information of a given publication, or in one of the underlying files used by the publication. The fragment is electronically linked into a given context, and will there display the defined value. By changing the variable's value, all instances of the fragment in the publication will automatically change to show the new value.
Next: What is the difference between a variable and a value?
The term variable (often referred to as text entity, variable or keyword) is used as a proper name to identify the independent fragment that can be reused in the texts. This name does not change. The variable has a value. The value is the text that the variable contains. It is this value that appears in the text in the publication.
DITA has no separate element for defining variables. Nevertheless, we can use the keyref attribute to achieve the desired functionality. Depending on which publishing system you use, there is another option, namely the varref attribute. That's why I tend to say there are two ways to define a variable and give it a value.
You can create a topic map and use the <keydef> element.
This is the usual way to define variables. In your topic, use, for example, the <keyword> element with the attribute keyref.
You can create a library topic and use the <keyword> element.
You can also use other elements. Defining variables in this way requires that your DITA system supports the use of the varref attribute. This attribute is not defined in the DITA standard but is a widely used proprietary attribute. The use of the varref attribute, the <keyword> element, and possibly other elements is determined by the Document Type Definition (DTD) that you are using.
Both library topic and topic map can contain multiple definitions, and each variable can have any value you want.
The following suggestions for basic rules are based on several years of experience:
All the variables you use must be standardized.
It cannot be possible for individual working group members to define variables themselves. Defining variables must be an administrator task. Without a standardized system, it is impossible to establish effective reuse.
All variables must be communicated to all members of the working group.
Each author must clearly understand how they shall use the variables and their purpose.
All variables must be documented.
A written description of each variable must be prepared. This description must explain the purpose of the variable, what it is used for, how it is used, and what kind of values it can have. Such documentation is important for internal use but even more important for those who shall translate.
Be careful when you choose which variables to establish.
It is wise to be restrictive. Using variables is a very efficient function, but it becomes tricky if a writer has to deal with unknown variables. The same is the case if you have to bring in a lot of unknown variables to publish.
Be aware of complications with translations.
If you translate your publications, variables pose a major challenge for the translators. You cannot assume that the translators are familiar with the functionality. The translator also has to deal with unknown variables, including values that are difficult to translate when taken out of context. We have also experienced that the values defined in different combinations can be difficult to translate because different languages operate with different grammatical genders. We had several discussions with our translators. After listening to their arguments and advice, we removed most of the variables from our texts.
TipThese pages only explain how variables are used in DITA publishing. If you want additional explanations about the principle of variables, see under Methodology and especially Using variables in the text. |
All external links open in a new window. I take no responsibility for information on external websites, even if I have linked to them. Please report links that do not work.
The information on this page represents my personal opinions and my understanding of the topic being described. Feel free to link to the page, but do not copy large parts of the content without permission. I take no responsibility for any errors, misunderstandings or missing information. I also take no responsibility for any mistakes you may make or cause as a result of incorrect or missing information. You are welcome to contribute with comments, relevant experiences or additional information. See Editor and contact information.