Variable Reuse with Conkeyrefs
Content key references (conkeyref
) enable you to reuse variables defined in DITA topics and added to a variable warehouse map.
The deliverable Map A contains the Variable Warehouse Map with warehouse topics. The warehouse topics contain variables with the
id
attribute assigned to them. The warehouse topics are added to the Variable Warehouse Map through the keydef element element. Both theid
andkeys
attributes are necessary to reuse content with conkeyrefs.Important: Including variable warehouse topics through the keydef element with the@keys
attribute assigned is necessary for the variable reuse mechanism to operate properly. By default, keydef elements are not included in the output.- Variable A is used in Element A in Topic A.
- Variable B is used in Element A and in Element D. The elements are in different topics.
Example
The following examples show the variable reuse mechanism through conkeyref attributes in Heretto CCMS. In the Content Editor, reused variables are indicated by a gray background with a key icon above.
This Variable Warehouse Map contains a Product Names Variables topic added to the map with a keydef
element and the keys
attribute defined.
<map id="ditamap-4622">
<title>Variable Warehouse Map</title>
<keydef href="Product_Names_Variables.dita" keys="varsProductNames"/>
</map>
This example shows a map that includesTopic A,Topic BandVariable Warehouse Map. The warehouse map contains topics with variables.
<map id="ditamap-6720">
<title>Map A</title>
<topicref href="Topic_A.dita"/>
<topicref href="Topic_B.dita"/>
<mapref format="ditamap" href="../_Global_Shared/Variables/Variable_Warehouse_Map.ditamap" processing-role="resource-only"/>
</map>
This example shows a warehouse topic that includes two variables.
The following example shows a topic that references two variables from the variable warehouse topic.
The following example shows a topic that references one variable from the variable warehouse topic.
Create a Variable Warehouse Topic
Create a variable warehouse topic that contains variables for a group of variables like product names or interface component names.
We recommend grouping similar variables in dedicated variable warehouses. For example, keep your product name variables and interface variables in separate variable warehouses. This strategy prevents your variable warehouses from becoming very large, cluttered, and disorganized as you add new reusable elements over time.
Create a table for your variables
phrase
element and the ID added to it make your variable content reusable. Create a Warehouse Map with Conkeyrefs
conkeyref
) for product names, interface names, and more.
Create a variable warehouse topic and define variables. See Create a Variable Warehouse Topic.
Add a variable warehouse topic to the map
Add a Warehouse Map with Conkeyrefs to a Deliverable Map
You can add a variable warehouse map to a deliverable map to ensure that every time you open the deliverable map, variables get resolved based on that warehouse map. This is a good approach for deliverable maps for which variables should always resolve to the same values.
If you do not want to add your warehouse maps to your deliverable maps, you can skip this procedure and set your warehouse maps as context maps. See Context Maps.
You added a variable map to a deliverable map as a resource-only resource which ensures that it will resolve variables but will not publish to outputs.
<map id="ditamap-6720">
<title>Deliverable Map</title>
<topicref href="Topic_A.dita"/>
<topicref href="Topic_B.dita"/>
<mapref format="ditamap" href="../_Global_Shared/Variables/Variable_Warehouse_Map.ditamap" processing-role="resource-only"/>
</map>
Reuse Variables through Conkeyrefs
You reuse variables from the variable warehouse topics through phrase elements and conkeyref attributes.
Add a variable warehouse topic to a map as a keydef element. See Add a Warehouse Map with Conkeyrefs to a Deliverable Map.
Set a context map. See 2.