• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Define a key to reference an element

Explorer ,
Jun 03, 2016 Jun 03, 2016

Copy link to clipboard

Copied

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

TOPICS
Structured

Views

845

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Jun 08, 2016 Jun 08, 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

...

Votes

Translate

Translate
Adobe Employee ,
Jun 08, 2016 Jun 08, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 10, 2016 Jun 10, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

Hi

I'm using the 2019 version I have tried to do according your instructions written above, but I don't get the text to my file. Do you have any ideas why? See my test below:

MAP:

<map xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">

<title>MY TEST MAP</title>

<keydef href="MyTestingVariables.dita" keys="ReuseTest"

    type="topic">

<topicmeta>

<navtitle>MyTestVariables</navtitle>

</topicmeta>

</keydef>

<topicref href="My test concept.xml" type="concept">

<topicmeta>

<navtitle>My test concept</navtitle>

</topicmeta>

</topicref>

</map>

CONCEPT:

<concept id="id191VCE00GY4"

    xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">

<title>My test concept</title>

<shortdesc>Only for testing</shortdesc>

<prolog>

<author></author>

</prolog>

<conbody>

<p>The name of the product is

<keyword

    keyref="ReuseTest/productname"></keyword>

</p>

</conbody>

</concept>

MY TOPIC WITH REUSABLE CONTENT:

<topic id="id191VCB00Y5Z"

    xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">

<title>MyTestVariables</title>

<shortdesc>Only a location for references.</shortdesc>

<prolog>

<author></author>

</prolog>

<body>

<p>Product name:

<keyword id="productname">Test product</keyword>

</p>

</body>

</topic>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Feb 05, 2019 Feb 05, 2019

Copy link to clipboard

Copied

For using the keyref in the concept, it works via this way

so either you could define the keyword at map level or if it is within a topicref, add the same through xref. This seems to be a bug in DITA-OT as well for 2.X

Hope this helps.

thanks

Amitoj Singh

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 05, 2019 Feb 05, 2019

Copy link to clipboard

Copied

LATEST

Thank you for your reply!

I fixed the problem with keyspace. I had tried it earlier but with no luck. The reason was I did it in a wrong way earlier.

I can also try this method at some point.

Br,

Pekka

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines