@keyscope on the root <map> element causes builds to fail
See original GitHub issueIt seems that using @keyscope
on the root <map>
element causes builds to fail. (Put aside for the moment the fact that a keyspace on <map>
is a bad practice. The spec allows it, so it should work: "Map authors define the boundaries for key scopes by specifying the @keyscope
attribute on <map>
elements, <topicref>
elements, or elements that are specializations of <map>
or <topicref>
. ")
Sample map:
<map keyscope="widget">
<title>Keyscope test 4</title>
<keydef keys="module">
<topicmeta>
<keywords>
<keyword>Widget</keyword>
</keywords>
</topicmeta>
</keydef>
<topicgroup keyscope="gadget">
<keydef keys="module">
<topicmeta>
<keywords>
<keyword>Gadget</keyword>
</keywords>
</topicmeta>
</keydef>
<topicref href="topic1.xml" keyscope="doodad">
<keydef keys="module">
<topicmeta>
<keywords>
<keyword>Doodad</keyword>
</keywords>
</topicmeta>
</keydef>
</topicref>
</topicgroup>
</map>
With a simple keyref such as <ph keyref="module"/>
in topic1.xml, the build fails. With a pathed keyref such as <ph keyref="widget.gadget.doodad.module/>
in topic7.xml, the build still fails.
Removing the keyspace definition from the <map>
and using <ph keyref="module"/>
in topic1.xml, the key resolves to “Widget,” as expected. Using <ph keyref="gadget.doodad.module"/>
, the key resolves to “Doodad,” as expected.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
I’m not sure specifying @keyscope on map elements is necessarily bad practice. On root maps it basically has no effect (because all the keys defined in the map will be within the named scope so unqualified key references will resolve).
On submaps it can make sense to specify @keyscope on the map element, which can then be used as the scope name for references to keys within that submap from outside the submap’s context. That ensures that the submap is always a separate scope even if the author of the using map does not specify a scope on the reference to the submap.
Fix NPE root cause, not with a workaround.