• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Learning DITA

Free DITA training

Free DITA training

  • Log in
  • Register
  • Newsletter
  • Profile
  • Privacy
  • Home
  • About
  • Courses
  • News
  • Resources
    • Recordings
  • Questions?
  • Contact

Using keys for paths

Posted on 12.02.16

Advanced reuse in DITA Lesson 2: Using keys Using keys for paths

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"/>
You can use keys (with the keyref attribute) in any element that uses an href attribute to indicate a file path. These elements include (but are not limited to):

  • <image>
  • <xref>
  • <link>
  • <coderef>
  • <topicref>
  • <mapref>
Contributors
  • Simon Bate
  • Jake Campbell
  • Gretyl Kinsey
Previous Topic
Back to Lesson
Next Topic

sidebar

Blog Sidebar

  • Scriptorium logo
    Maximize the value of your content. Read more.
  • Scriptorium logo
    Already in DITA and need support? Contact us.
RSSLinkedin

Want to add content? Join the ditatraining GitHub repository.

  • Home
  • News
  • Contact
  • Privacy
  • Cookie Policy

Maintained by Scriptorium Publishing

Logo and site presentation © 2015–2023 Scriptorium Publishing. Content based on the open-source DITA training project.

Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage vendors Read more about these purposes
View preferences
{title} {title} {title}
Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage vendors Read more about these purposes
View preferences
{title} {title} {title}