<anchorid> element allows an author to define a
@conref target that will be resolved dynamically when rendered for an end user
of the content. This element is useful when doing an initial process of the DITA content prior
to final rendering of the content; it causes specified IDs to be preserved after that process,
@conref relationships that reuse the element will not be resolved during the
<anchorid> element is defined within a topic prolog, the
specified IDs will be found within that topic. When an
element is defined within a
<topicref> element, the specified IDs
will be found within the referenced topic (if the
references a collection of topics, such as a reference that uses only a file name, the IDs
will be found within the first or root topic).
The only difference between specifying an
<anchorid> in the
<prolog> and specifying it in the
<topicmeta> is that from the map it is possible to export the ID of
the entire referenced topic. If
<anchorid id="zero"/> is specified in
<topicmeta>, and the referenced topic has an id of "zero", this
means that the
<anchorid> is a reference to the entire topic. If the
topic id is not "zero", then the
<anchorid> is a reference to the
element with id="zero" within that topic.
Along with the preservation of the element's ID, any
@conref attribute that
references the element's ID will not be resolved during an initial process. In that case,
@conref will be resolved during a later rendering process.
This description does not imply that IDs are not discarded when
is not used; though this element requires that IDs be preserved in some manner, it is also
common for IDs to be preserved when
<anchorid> is not used. Thus the
primary impact of the
<anchorid> element is on
Many publishing systems for which DITA is used as a source format do not have a way to dynamically resolve content references; those systems will not see any benefit from this element. When DITA is used for those systems, behaviors related to this element are ignored.
Why not use topicid/elementid?
This element differs from normal DITA referencing syntax in that it can reference an element within a topic without using the topic's ID. There are two
reasons for this. First, the
<anchorid> element might only be defined in a situation that refers unambiguously
to a single topic (in the
<prolog>, or in the
<topicmeta> for a reference to a topic). Second, it allows the
<anchorid> to be combined with key values.
It is possible to combine an
<anchorid> with a key in order to delay
@conref in the topic represented by that key (see the second
set of examples below). This would not be possible if the
element required both the topic id and the element id. That is,
allows a modifiable reference to a topic, so a map might
instruct processors to delay conref for item "step1" in the topic represented by the key
"commonconfig". If the
<anchorid> element required a topic id, the
delayed conref would always be bound to that specific topic.
See appendix for information about this element in OASIS document type shells.
+ topic/keyword delay-d/anchorid
In this example, a set of information contains multiple components. Some references to component
A use keys rather than a direct reference, so that
@conref can be redirected
to a different component when component A is not installed. The keys might be exported, in addition to the IDs, so that some
references become bound to the actual component while other references might be redirected.
<map> <topicref keys="componentAconfig commonconfig" href="componentA/configA.dita#configA"> <topicmeta> <exportanchors> <anchorkey keyref="commonconfig"/> <anchorid id="step1"/> <anchorid id="step2"/> </exportanchors> </topicmeta> </topicref> </map>
@keys attributes declares two distinct keys that can be used to refer to this topic (componentAconfig and commonconfig). Only the
second is preserved using
<anchorkey>. A task topic from another
component might reuse steps within this topic in a variety of
<steps> <step conkeyref="componentAconfig/step1"><cmd/></step> <step conkeyref="componentAconfig/step1.5"><cmd/></step> <step conkeyref="commonconfig/step2"><cmd/></step> <step conkeyref="commonconfig/step2.5"><cmd/></step> <step><cmd>And that is the end of that</cmd></step> </steps>
- The componentAconfig key is not preserved, so the first
<step conref="componentA/configA.dita#configA/step1"><cmd/></step>. At that point the
<anchorid>element instructs the step1 ID to be preserved; for runtime applications which support it, this relationship will be preserved in the processed DITA output.
- The second
<step>with the same key becomes
<step conref="componentA/configA.dita#configA/step1.5"><cmd/></step>. However, conref relationships to step1.5 are not preserved, so this conref should be resolved into static content.
<step>three, the map instructs that both the key commonconfig and the ID step2 should be preserved in any content generated for this DITA topic. For formats that support runtime resolution through keys, a process must convert the
@conkeyrefvalue into an equivalent value for that format.
- Although resolution for the key used in
<step>four is delayed, the specific element that is referenced should not be delayed. Thus the fourth step becomes
<step conref="componentA/configA.dita#configA/step2.5"><cmd/></step>. This value is then processed as an ordinary
This allows the information assembler to resolve references that must be to componentA while deferring references that can be fulfilled by alternative component content.
<anchorid>element cannot reference an element with the usual topicid/elementid format. If the two
<anchorid>elements in the example had been set to config/step1 and config/step2, then they would only ever apply in a topic with id="config". It would not be possible to redirect the key to another topic, but still preserve conref behaviors as desired.
@conrefresolution for an entire topic using the key. If
@conkeyrefon a task topic element is set to "componentAconfig", which is not delayed, the
@conrefwill be evaluated as usual. However, if
@conkeyrefon the task is set to "commonconfig", which is delayed, resolution of
@conrefon that element should be delayed by a processor.
- Indicates an ID within the specific topic that will be preserved during processing.
@conrefvalues referencing the indicated ID will not be resolved; when possible, the original relationship is preserved in any processed document. Note that this element creates an exception to the general rules that IDs can only be used once within a single topic or within a map; this is because the ID is actually a pointer to another target, rather than being a target itself. This attribute is defined with the XML Data Type CDATA.