• 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
  • Support the site
  • Contact
  • Recordings

Advanced key uses

Posted on 12.02.16

Advanced reuse in DITA Lesson 2: Using keys Advanced key uses
Lesson Progress
0% Complete

Compound uses of the <keydef> element

You can use keydefs to simultaneously define both file paths and text strings. Consider the case where you need to cross-reference a topic in many different places, but you want to use some text other than the topic title in the cross-reference. In this case, you can create a <keydef> element that associates a key with an href to the topic, but also uses the nested <topicmeta> to define a <linktext> element:

<keydef keys="initing_ddb" href="init_ddb.dita">
    <topicmeta>
        <linktext>Initializing the Duck Database</linktext>
    </topicmeta>
</keydef>
If you reference this key in a cross-reference (<xref> element), the link will target init_ddb.dita and the text for the link will be “Initializing the Duck Database”:

<xref keyref="initing_ddb"/>

Key references with fall-backs

If you use both a keyref and an href attribute in an element, a DITA output generator will attempt to resolve the keyref first. If the key is not defined, the href target is used as a fall-back.

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
    Need DITA help? We offer flat-rate consulting. Get help.
  • Scriptorium logo
    Already in DITA and need support? Contact us.
RSSTwitter

Want to add content? Join the ditatraining GitHub repository.

  • Home
  • Sponsor
  • News
  • Contact
  • Privacy

Maintained by Scriptorium Publishing

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