### 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,
    ; or None (variables are ignored, except booktitle and booktitlealt)
    ; 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.

When elementpath=None (or No), user variables are not created for that particular element path.

The DITA2Go distribution includes the following setting in system configuration file %OMSYSHOME%\d2g\configs\d2g_config.ini:

    [VariableMaps]
    * = None

If you omit all settings in [VariableMaps], this what you get. In this case the only user variables DITA2Go recognizes are for booktitle and booktitlealt, which are handled differently.

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

Table of Contents • Index