Keyref to nested topic elements not working

Post here questions and problems related to editing and publishing DITA content.
jrehahn
Posts: 3
Joined: Fri Aug 19, 2022 10:53 am

Keyref to nested topic elements not working

Post by jrehahn »

Hello,

we have recently changed most of our xref href references to keyref references. Now we realize that we cannot address the same elements of a topic. It seems that a an href recognizes all IDs within a topic, whereas a keyref is limited to the top level element only.
Example:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA General Task//EN" "generalTask.dtd">
<task id="c_agents_overview">
    <title id="tests">Agents overview</title>
    <shortdesc/>
    <taskbody>
        <context id="context_flk_vlw_psb">
            <note id="note_m2v_tpz_lcc" type="attention">.</note>
        </context>
    </taskbody>
    <task id="task_czk_s2v_c2c">
        <title id="title_hbz_s2v_c2c">Test</title>
    </task>
</task>
I cannot address any ids that are outside the top level task element, meaning the nested task at the bottom is not recognized, the task and title elements cannot be found:

Code: Select all

<xref keyref="keyscope.fileName/task_czk_s2v_c2c"/>
"Referenced ID path "c_agents_overview/task_czk_s2v_c2c" not found."
Why is that happening and how can I solve it? We want to keep addressing sub-contents (nested tasks, concepts or section elements) within a topic to be more precise in our referencing.
Thanks for the help!
Radu
Posts: 9343
Joined: Fri Jul 09, 2004 5:18 pm

Re: Keyref to nested topic elements not working

Post by Radu »

Hi,
This is correct, according to the DITA 1.3 specification a key is defined to point to a topic and can refer sub elements from that topic, not from inner topics inside that topic. The DITA OT publishing engine may be more relaxed and not follow the specification on this but the Oxygen validation and editing does.
So for inner topics you would need to define separate keydefs like:

Code: Select all

<keydef keys="inner" href="path/to/fileName.dita#INNER_TOPIC_ID"/>
and then use those keys which point directly to the inner topic.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply