dita-ot icon indicating copy to clipboard operation
dita-ot copied to clipboard

Variable references inside <navtitle> do not resolve inside a multiple-value @keyscope region

Open chrispy-snps opened this issue 4 years ago • 2 comments

Expected Behavior

If the current @keyscope region has multiple values (1) and a variable is defined (2), that variable should resolve both in a <navtitle> element (3) as well in topic content (4).

multiple_value_keyscope

Actual Behavior

The variable does not resolve in the <navtitle> element (3). The HTML output is as follows:

Map Title
- Navigation Title for ""
  - Topic Title for "My Product"

This issue occurs when there are multiple space-separated values in @keyscope, whether they are the same value ("top top" or "local local") or different ("top local").

This testcase might seem improbable, but it is reduced for simplicity. In our production environment, a top-level <mapref> with a top-level scope instantiates a submap's <map> with its own local scope. The @keyscope values are concatenated during mapref preprocessing per "2.3.4.2 Key scopes", thus triggering this bug and causing a product variable to fail evaluation in a <navtitle> within the submap.

Possible Solution

I hope the solution is as simple as changing a string comparison to a list comparison in the code that evaluates scoped variables for <navtitle> elements.

Steps to Reproduce

Testcase: multiple-value-keyscope.zip

Command: dita -i map.ditamp -f html5

Environment

  • DITA-OT version: 3.6.1
  • Operating system and version: Linux (Ubuntu 20.04)
  • How did you run DITA-OT? dita command
  • Transformation type: html5

chrispy-snps avatar Aug 23 '21 21:08 chrispy-snps

@chrispy-snps #3796 has been merged. Has it affected this issue?

jelovirt avatar Aug 31 '21 08:08 jelovirt

@jelovirt - I confirmed that the fix for #3796 works around this bug when the <mapref> and <map> share the same @keyscope value:

<!-- map.ditamap -->
<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="urn:oasis:names:tc:dita:rng:map.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<map>
  <title>Map Title</title>
  <mapref href="submap.ditamap" keyscope="my_book"/>
                           <!-- ^^^^^^^^^^^^^^^^^^  note @keyscope -->
</map>
<!-- submap.ditamap -->
<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="urn:oasis:names:tc:dita:rng:map.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<map keyscope="my_book">
<!-- ^^^^^^^^^^^^^^^^^^^  note @keyscope -->
  <title>Submap Title</title>
  <keydef keys="Product">
    <topicmeta>
      <keywords>
        <keyword>My Product</keyword>
      </keywords>
    </topicmeta>
  </keydef>
  <topichead>
    <topicmeta>
      <navtitle>Navigation Title for "<ph keyref="Product"/>"</navtitle>
    </topicmeta>
    <topicref href="topic.dita"/>
  </topichead>
</map>

However, I confirmed that when the @keyscope values differ, the bug is still present.

In most cases, our @keyscope values match. But when we instantiate multiple conditional variants of a book, we must specify unique per-<mapref> keyscopes to keep them unambiguous, which still triggers the bug.

chrispy-snps avatar Aug 31 '21 19:08 chrispy-snps