Key definition

A key definition provides a simple way to define a key without making the definition itself a part of rendered content.

Syntax

The syntax for representing this component varies depending on the authoring format:

Authoring format Syntax and example
XDITA

<keydef>

<keydef keys="product-name">
  <topicmeta>
    <keytext>Remote Network Lighting</keytext>
  </topicmeta>
</keydef>
HDITA

<div data-class="keydef">

<div data-class="keydef">
  <span data-class="keytext" data-keys="product-name">Remote Lighting Network</span>
</div>
MDITA

There is no specific support in the MDITA core profile. If needed, use an HDITA snippet.

Usage information

The key definition component is a convenience component. It is equivalent to a topic reference component that defines a key while also setting @processing-role to resource-only. Attributes defaulted on the key definition component ensure that key definitions do not appear in the TOC, do not add extra links, and are not rendered as topics.

Attributes

The available attributes vary based on the authoring format:

XDITA and HDITA
The following attributes are available on this element: localization attributes, link relationship attributes, universal attributes, @keys, @props, and @processing-role.
MDITA
There is no attribute support for the MDITA core profile. For the MDITA extended profile, attributes can be specified by using the HDITA representation.
(XDITA and HDITA) For the key definition component, the following considerations apply:
  • The @keys attribute is required.
  • The @href attribute might be omitted when the key definition is used for variable text.
  • The @processing-role attribute has a default value of resource-only.

Examples

This section is non-normative.

The section contains examples of how the key definition component can be used. Key definitions can be used to define keys for topics, as well as variable text.

Example 1. XDITA example

The following code sample shows how the <keydef> element can be used to define keys for resources:

<map>
  <!-- Key definitions -->
  <keydef keys="winter-garden" href="garden/winter-garden.dita"/>
  <keydef keys="crop-types" href="crop-types.html" format="html" scope="local"/>
  <keydef keys="selecting-plants" href="garden/tasks/selecting-plants.dita"/>
  <!-- ... -->
</map>

For an example of a key definition used to define variable text, see Figure 1.

Example 2. HDITA example

The following code sample shows how the <keydef> element can be used to define keys for resources:

<nav>
  <h1>Planting a winter garden</h1>
<!-- Key definitions -->
  <div data-class="keydef" 
       data-keys="winter-garden" 
       href="garden/winter-garden.html"/>
  <div data-class="keydef" 
       data-keys="crop-types" 
       href="garden/crop-types.html"/>
  <div data-class="keydef" 
       data-keys="selecting-plants" 
       href="garden/selecting-plants.html"/>
  <!-- ... -->
  
</nav>

For an example of a key definition used to define variable text, see Figure 2.

Example 3. MDITA example

The following code sample shows how the <keydef> element can be used to define keys for resources. Note that in an MDITA map, the HDITA representation for key definitions must be used.

# Planting a winter garden
  <!-- Key definitions -->
  <div data-class="keydef" 
       data-keys="winter-garden" 
       href="garden/winter-garden.md"/>
  <div data-class="keydef" 
       data-keys="crop-types" 
       href="garden/crop-types.md"/>
  <div data-class="keydef" 
       data-keys="selecting-plants" 
       href="garden/selecting-plants.md"/>
  <!-- ... -->

For an example of a key definition used to define variable text, see Figure 3.