12.2 Assigning variable names to element paths

You can assign a name to an element path to capture the element content in a DITA2Go user variable of that name.

To map an element path to a user variable:

[VariableMaps]
; element path = name to use for variable with element content
; default is the element name itself
elementpath = varname

For example:

[VariableMaps]
mainbooktitle/* = BookTitle

The user variable is then available for use in DITA2Go macros. This assignment applies to any element, regardless of the properties set for the element in [ElementTypes]. How many variables you get depends on how many instances of the element path occur in your document. For example, if you set:

[VariableMaps]
title/* = MainTitle

you will get a variable $$MainTitle[index] for every use of title in your document. If you change the setting to:

[VariableMaps]
title/map/1 = MainTitle

you will get just one variable, $$MainTitle. How specific you make the path determines how many matches you get.

Previous Topic:  12.1 Understanding how DITA2Go user variables work

Next Topic:  12.3 Including user variables in DITA2Go macros

Parent Topic:  12. Creating and deploying user variables

Sibling Topics:

12.1 Understanding how DITA2Go user variables work

12.3 Including user variables in DITA2Go macros

12.4 Deploying user variables in template macros