Page 1 of 1

Different keywords in each submap not resolving

Posted: Thu May 18, 2023 1:32 pm
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

Re: Different keywords in each submap not resolving

Posted: Thu May 18, 2023 1:48 pm
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

Re: Different keywords in each submap not resolving

Posted: Thu May 18, 2023 1:51 pm
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.

Re: Different keywords in each submap not resolving

Posted: Fri May 19, 2023 11:39 am
by matt_k
Thank you both for your replies.
The keyscope solution works perfectly.
Matt

Re: Different keywords in each submap not resolving

Posted: Fri May 19, 2023 2:22 pm
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.