Skip to main content
Known Participant
June 3, 2016
Answered

Define a key to reference an element

  • June 3, 2016
  • 1 reply
  • 1190 views

Hi,

As far as I can tell, in a map you can define a key to reference a topic:

<keydef href = "Concepts/c_access_control_policies.xml"

    keys = "access control policies" type = "concept"><topicmeta>

<navtitle>Access control policies</navtitle></topicmeta></keydef>

For entire topics this is fine: I can then use they key "access control policies" whenever I need to reference this topic.

However, I'd like to be able to reference an element within a topic. For example, have a topic that lists all the standard terms and phrases; each of these elements would have unique IDs etc. In the map, I'd then create keydefs to reference these elements. So far, I've been unable to do this.

I can easily create references to these standard terms and phrases via conrefs, but each time I want to create a conref, I have to go through the process of locating the file etc. I would have thought that keys would be easier.

Any help gratefully received.

Peter

This topic has been closed for replies.
Correct answer AJIT_M

Hi There,

For references to topics, maps, and non-DITA resources, the value of the @keyref attribute is simply a key name: keyref="topic-key". However for references to non-topic elements within topics and non-topicref elements within maps, the value of the @keyref attribute is a key name, a solidus ("/"), and the ID of the target element: keyref="topic-key/some-element-id"

For example, consider this topic in the document "file.dita":

<topic id="topicid">

<title>Example referenced topic</title>

<body>

  <p id="para-01">Some content.</p>

</body>

</topic>

And this key definition:

<map>

  <topicref keys="myexample"

    href="file.dita"/>

</map>

A keyref of the form "myexample/para-01" resolves to the <p> element in the topic. Let me know if I understood your question correctly.

Regards,

Ajit

1 reply

AJIT_M
AJIT_MCorrect answer
Inspiring
June 8, 2016

Hi There,

For references to topics, maps, and non-DITA resources, the value of the @keyref attribute is simply a key name: keyref="topic-key". However for references to non-topic elements within topics and non-topicref elements within maps, the value of the @keyref attribute is a key name, a solidus ("/"), and the ID of the target element: keyref="topic-key/some-element-id"

For example, consider this topic in the document "file.dita":

<topic id="topicid">

<title>Example referenced topic</title>

<body>

  <p id="para-01">Some content.</p>

</body>

</topic>

And this key definition:

<map>

  <topicref keys="myexample"

    href="file.dita"/>

</map>

A keyref of the form "myexample/para-01" resolves to the <p> element in the topic. Let me know if I understood your question correctly.

Regards,

Ajit

Known Participant
June 10, 2016

Ajit,

Thank you for your your clear response.

The problem was that I was expecting to be able to see the key when browsing for it via the Source > Refer to Key > Edit button, which would only take me to the topic file.

By simply entering the keyname/id_name into the Refer to Key field, this works perfectly.

I now have a key called "standard_phrases", which refers to the file that contains all the standard stuff, and can insert any material within that file using: standard_phrases/reference

Many Thanks

Peter