[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: Why are key reference ID targets restricted to non-topics elements?
There are two reasons for the way key references work:
For example, consider this topic, “topics/topic-01.dita”: <topic id=”some-id”><title>Some Topic</title> <p id=”some-id”>This paragraph has the ID value “some-id”</p> </body> </topic> And these topicrefs in some map: <topicref keys=”topic-01” href=""> <topicref keys=”topic-02” href=""> And this key reference from topic topic-02.dita: <p>See <xref keyref=”topic-01/some-id”/>.</p> In the context of this map, the key reference “topic-01” resolves to the topic “topics/topic-01.dita” and the ID reference “some-id” can only resolve the non-topic element with the ID “some-id”—it could never refer to the topic element
that happens to also have the ID value “some-id”. This is also why you can’t use a key reference to a parent topic to refer to a child topic—the child topic must have its own key definition. Within DITA topics, each topic defines a separate ID space, separate from the ID of the topic element itself and separate from the IDs of any nested topics. The @id attribute on topics is defined as type ID, meaning the IDs must be unique
within the XML document that contains the topic, the but @id attribute on non-topic elements is defined as type NAME, so they do not have the usual uniqueness requirements of attributes of type ID. As further example, consider this topic with a nested topic: <topic id=”some-id”><title>Root Topic</title> <body> <p id=”some-id”>This paragraph has the ID value “some-id”</p> </body> <topic id=”some-other-id”><title>Nested Topic</title> <body> <p id=”some-id”>This paragraph has the ID value “some-id”</p> </body> </topic> </topic> Here the two topic elements must have distinct @id values (“some-id” and “some-other-id”) but the <p> elements within them can both have the ID value “some-id” because each topic establishes a separate ID name space, so there is no conflict
with either the root topic’s @id value or the two <p> elements with the same @id value in two different topics.
Cheers, Eliot Kimber Member, DITA Technical Committee Original request: Chris Trenkamp writes (https://lists.oasis-open.org/archives/dita-comment/202304/msg00000.html)
Why are keyref ID targets limited to non-topic elements? I can’t find an explanation for this in the specification, and I can’t think of a reason why this restriction would be in place.
In fact, this restriction seems to operate in direct contradiction to how the id attribute operates:
The specification states that id attributes on topic elements are XML attribute type ID’s, so they are strictly required to be unique by the XML parser. All other id’s only have to be
unique within the topic they are declared in.
It’s entirely possible to create a key reference to an element id that was declared multiple times in different sub-topics. I haven’t found anything in the specification that states how
key references to an ID target that was redeclared multiple times is supposed to be resolved. Does it take the first one? Does it throw an error? Is it up to the individual processor?
At the very least, topic id’s are required to be unique by the XML parser, so you can be confident that when you create a key reference with an ID target to a topic, you know that target
is unique.
Can someone explain why this restriction is in place? Is the reasoning still relevant? _____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 |
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]