Content Key Reference (conkeyref)

The content key reference mechanism combines the content reference mechanism with the key reference mechanism.

Sample project: conkeyref.zip

conkeyref.ditamap

On the conkeyref.ditamap the <keydef> element defines the key source for the source.dita topic using the @keys attribute. The <keydef> element is a specialization of the <topicref> element and implicitely sets the @processing-role attribute to resource-only.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map>
    <title>conkeyref</title>
    <!--
        Instead of using a <topicref>, we can use a <keydef> element,
        which is a "short form" of the following <topicref>:
        
        <topicref href="source.dita" keys="source" processing-role="resource-only" toc="no"/>
    -->
    <keydef keys="source" href="source.dita"/>
    <topicref href="target.dita"/>
</map>

source.dita

The source.dita topic contains a <note> element, that has an @id attribute and therefore can be pulled using a content reference or content key reference.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="conkeyref-source">
    <title>source</title>
    <body>
        <note id="charge-before-use">Use the included USB cable to charge your speaker and make sure
            it is fully charged before first use.</note>
    </body>
</topic>

target.dita

The target.dita file pulls the <note> element by content keys reference. The pattern of the @conkeyref attribute is:

KEY OF THE TOPIC + "/" + ID OF THE ELEMENT
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="conkeyref-target">
    <title>target</title>
    <body>
        <!--
            Instead of using a @conref, we're using a @conkeyref
            
            <note conref="source.dita#conref-source/charge-before-use"/>
        -->
        <note conkeyref="source/charge-before-use"/>
    </body>
</topic>