Example: Key definition with key reference

Darwin Information Typing Architecture (DITA) Version 1.3 Part 2: Technical Content Edition

OASIS DITA Technical Committee

When a key definition also specifies a key reference, the key reference must also be resolved in order to determine the effective resources bound to that key definition.

In the following example, a topicref element references the key "widget". The definition for "widget" in turn references the key "mainProduct".

  <topicref keyref="widget" id="example"/>
  <keydef keys="widget" href="widgetInfo.dita" scope="local" format="dita" rev="v1r2"
    <topicmeta><navtitle>Information about Widget</navtitle></topicmeta>
  <keydef keys="mainProduct" href="http://example.com/productPage" scope="external" format="html"
          product="prodCode" audience="sysadmin">
    <topicmeta><navtitle>Generic product page</navtitle></topicmeta>

For this example, the key reference to "widget" pulls resources from that key definition, which in turn pulls resources from "mainProduct". The metadata resources from "mainProduct" are combined with the resources already specified on the "widget" key definition, resulting in the addition of product and audience values. Along with the navigation title, the href, scope, and format attributes on the "widget" key definition override those on "mainProduct". Thus after key references are resolved, the original reference from topicref is equivalent to:

<topicref id="example"
          href="widgetInfo.dita" scope="local" format="dita" rev="v1r2"
          product="prodCode" audience="sysadmin">
   <topicmeta><navtitle>Information about Widget</navtitle></topicmeta>