Different keywords in each submap not resolving

Post here questions and problems related to editing and publishing DITA content.
matt_k
Posts: 32
Joined: Mon Aug 17, 2020 7:16 pm

Different keywords in each submap not resolving

Post by matt_k »

Hi there
I am working on a catalogue and have the content for each product contained in a map. Each of these maps have two keydefs containing keywords for the product code and product name, e.g.:

Code: Select all

<map id="ditamap-5910">
    <title>Catalogue</title>
    <keydef keys="product_name">
        <topicmeta>
            <keywords><keyword>Product Name A</keyword></keywords>
        </topicmeta>
    </keydef>
    <keydef keys="product_code">
        <topicmeta>
            <keywords><keyword>Product A</keyword></keywords>
        </topicmeta>
    </keydef>
    <topicref href="topics/product_a.dita">
        <topicref href="topics/product_a_description.dita"/>
        <topicref href="shared_content/specification.dita"/>
        <topicref href="topics/product_a_use_case.dita"/>
        <topicref href="topics/product_a_pricing.dita"/>
    </topicref>
</map>
Each of these product maps are referenced in a parent map for the whole catalogue.
The 'specification.dita' topic has a two keywords in the first paragraph:

Code: Select all

<p>The … <keyword keyref="product_name"/> (<keyword keyref="product_code"/>) is the best product.</p>
This topic is used in each map and keywords should resolve to use the keydef in that map. Instead, when I publish, only the keywords from the first map are used.
Have I missed something here?
Many thanks
Matt
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Different keywords in each submap not resolving

Post by Radu »

Hi Matt,

By default there is a single key scope, the key scope of the entire publication. So if in a main DITA Map you refer to submap1 which defines "keyName" and to "submap2" which defines the same "keyName", the "keyName" will expand to its first definition, no matter if the keyref is in the first or second submap. This is how the DITA standard works.
But there is also this concept of key scope:
https://www.oxygenxml.com/dita/1.3/spec ... copes.html
So for example if in the main DITA Map you use:

Code: Select all

<mapref href="submap1.ditamap" keyscope="k1"/>
<mapref href="submap2.ditamap" keyscope="k2"/>
this would be enough for the keyref to "keyName" to resolve differently in the submaps.
https://www.oxygenxml.com/dita/1.3/spec ... copes.html
https://blog.oxygenxml.com/keyscopes/keyscopesBlog.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Different keywords in each submap not resolving

Post by chrispitude »

Hi Matt,

If a variable needs to have different values in different parts of your top-level map, you will need to use keyscopes. In the following application note:

DITA 1.3 Feature Article:
Understanding Scoped Keys in DITA 1.3


the "widget, gadget, doodad" example on the bottom of page 5 seems to match your example.
matt_k
Posts: 32
Joined: Mon Aug 17, 2020 7:16 pm

Re: Different keywords in each submap not resolving

Post by matt_k »

Thank you both for your replies.
The keyscope solution works perfectly.
Matt
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Different keywords in each submap not resolving

Post by chrispitude »

Hi Matt,

What made me really appreciate the power of keyscopes was when I had to include multiple books in an online help map:

Code: Select all

<map>
  <mapref href="book1" keyscope="book1"/>
  <mapref href="book2" keyscope="book2"/>
  <mapref href="book3" keyscope="book3"/>
</map>
and no matter what keys were used in each of the books, all the cross-references within the book continued to work perfectly without any interference or collision with the other books.
Post Reply