preprocess-conref.dita 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <concept id="preprocess-conref" xml:lang="en-US">
  5. <title>Conref (conref)</title>
  6. <shortdesc>The <codeph>conref</codeph> step resolves conref attributes, processing only the DITA maps or topics that
  7. use the @conref attribute. This step is implemented in XSLT.</shortdesc>
  8. <conbody>
  9. <section>
  10. <p>The values of the <xmlatt>id</xmlatt> attribute on referenced content are changed as the elements are pulled
  11. into the new locations. This ensures that the values of the <xmlatt>id</xmlatt> attribute within the referencing
  12. topic remain unique.</p>
  13. <p>If an element is pulled into a new context along with a cross reference that references the target, both the
  14. values of the <xmlatt>id</xmlatt> and <xmlatt>xref</xmlatt> attributes are updated so that they remain valid in
  15. the new location. For example, a referenced topic might include a section as in the following example: <fig>
  16. <title>Referenced topic that contains a section and cross reference</title>
  17. <codeblock>&lt;topic id="referenced_topic">
  18. &lt;title>...&lt;/title>
  19. &lt;body>
  20. &lt;section id="sect">&lt;title>Sample section&lt;/title>
  21. &lt;p>Figure &lt;xref href="#referenced_topic/fig"/> contains a code sample that demonstrates ... .&lt;/p>
  22. &lt;fig id="fig">&lt;title>Code sample&lt;/title>
  23. &lt;codeblock>....&lt;/codeblock>
  24. &lt;/fig>
  25. &lt;/section>
  26. &lt;/body>
  27. &lt;/topic></codeblock>
  28. </fig></p>
  29. <p>When the section is referenced using a <xmlatt>conref</xmlatt> attribute, the value of the <xmlatt>id
  30. </xmlatt>attribute on the <xmlelement>fig</xmlelement> element is modified to ensure that it remains unique in
  31. the new context. At the same time, the <xmlelement>xref</xmlelement> element is also modified so that it
  32. remains valid as a local reference. For example, if the referencing topic has an <xmlatt>id </xmlatt> set to
  33. "new_topic", then the conrefed element may look like this in the intermediate
  34. document <xmlelement>section</xmlelement>.
  35. <fig>
  36. <title>Resolved conrefed <xmlelement>section</xmlelement> element after the conref step</title>
  37. <codeblock>&lt;section id="sect">&lt;title>Sample section&lt;/title>
  38. &lt;p>Figure &lt;xref href="#new_topic/d1e25"/> contains a code sample that demonstrates ... .&lt;/p>
  39. &lt;fig id="d1e25">&lt;title>Code sample&lt;/title>
  40. &lt;codeblock>....&lt;/codeblock>
  41. &lt;/fig>
  42. &lt;/section></codeblock>
  43. </fig></p>
  44. <p>In this case, the value of the <xmlatt>id </xmlatt> attribute on the <xmlelement>fig</xmlelement> element has
  45. been changed to a generated value of "d1e25". At the same time, the <xmlelement>xref</xmlelement> element has
  46. been updated to use that new generated ID, so that the cross reference remains valid.</p>
  47. </section>
  48. </conbody>
  49. </concept>