Support for xrefs with keyref

105 views
Skip to first unread message

mr.uma...@gmail.com

unread,
Nov 16, 2020, 11:10:38 AM11/16/20
to DITA-OT Users

Hi,

We have a use case for which we use <xref> with keyref attribute.

<keydef href="topics/task/topic-name.dita" keys="topic-name"/>
--> Defined in ditamap

<xref keyref="guide-name.topic-name">Link to another topic</xref> --> Inside topic

This link is resolved properly in DITA-OT XHTML and HTML5 output. However, when I give link to a sub-topic in it, then the link is resolved incorrectly.

Here is our test case. We gave links to an image and a subtopic from a topic using xref with keyref.

Link 1: <xref keyref="guide-name.topic-name/my-graph-picture">Link to image in another topic</xref> --> This is resolved into <a class="xref" href="topic-name.html#topic-root-id__my-graph-picture">Link to image in another topic</a>. Also, the id for the image is set to "topic-root-id__my-graph-picture". So, it is working fine.
Link 2: <xref keyref="guide-name.topic-name/my-sub-topic">Link to sub-topic</xref> --> This is resolved into <a class="xref" href="topic-name.html#topic-root-id__my-sub-topic">Link to sub-topic</a>. But the id for the sub-topic (concept/concept) is set to "my-sub-topic". So the link is broken. I have checked this behavior in DITA-OT 3.5.2.

I understand that the links using keyrefs are not completely supported; but this seems like an inconsistency to me.

Thank you.

Best Regards,
Uma Shankar

Chris Papademetrious

unread,
Nov 16, 2020, 3:52:23 PM11/16/20
to DITA-OT Users

Hi Uma,

You cannot keyref to subtopic elements within a topic. The subtopics must have their own key names defined in the map:

      <topicref href="my_topic.dita" keys="top_level_topic">
        <topicref href="my_topic.dita#sub1_id" keys="subtopic1"/>
        <topicref href="my_topic.dita#sub2_id" keys="subtopic2"/>
      </topicref>

 then you reference those subtopics (or non-topic elements inside them) via their own key values.

Our writers use subtopics a lot, but there is no automation in Oxygen to keep the map updated with subtopics inside topic files. So we developed our own utility, written in perl, that reads map and topic files, then updates the maps to reflect subtopic structure in topic files. Writers need to remember to run this utility after creating or modifying subtopic structure. It's not pretty but it works.  :)

 - Chris
Reply all
Reply to author
Forward
0 new messages