Defining the key
To define a key that will contain a path (file path or URL), add the <keydef> element to a map. Use these attributes with the <keydef> element:
- keys: the name of the key
- href: the key target
- format: the type of file indicated by the key
For example:
<keydef keys="product_image" href="images/product_B.png" format="png"/>
Although the key name can contain some special characters, it is a good practice to limit names to letters, numbers, and the underscore character. If you need to use other special characters, check the DITA 1.2 specification.
It is also a good practice to use the format attribute when defining a key. Possible values include “dita”, “ditamap”, “pdf”, “html”, and graphic formats, such as “png” or “svg”.
If you’re defining a key for an external resource, such as a URL, you must use scope=”external” with the <keydef> element:
<keydef keys="our_url" href="http://www.scriptorium.com" scope="external" format="html"/>
The scope attribute prevents the DITA Open Toolkit (or other processors) from attempting to resolve the href target as part of the definition. Because the href attribute points to a web page, the format attribute must contain the value html.
Using the key
To use a key for a file path or URL, use the keyref attribute instead of the href attribute:
<image keyref="product_image"/>
- <image>
- <xref>
- <link>
- <coderef>
- <topicref>
- <mapref>