preprocess-conref.dita 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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>Resolve content references (conref)</title>
  6. <shortdesc>The <codeph>conref</codeph> step resolves content references, processing only the DITA maps or topics that
  7. use the <xmlatt>conref</xmlatt> attribute. This step is implemented in XSLT.</shortdesc>
  8. <prolog>
  9. <metadata>
  10. <keywords>
  11. <indexterm><xmlelement>fig</xmlelement></indexterm>
  12. <indexterm><xmlelement>xref</xmlelement></indexterm>
  13. <indexterm><xmlelement>section</xmlelement></indexterm>
  14. <indexterm><xmlatt>conref</xmlatt><indexterm>resolving</indexterm></indexterm>
  15. <indexterm><xmlatt>id</xmlatt><indexterm><xmlatt>conref</xmlatt> resolution</indexterm></indexterm>
  16. <indexterm><xmlatt>xref</xmlatt></indexterm>
  17. <indexterm>preprocessing<indexterm><codeph>conref</codeph></indexterm></indexterm>
  18. <indexterm><codeph>conref</codeph></indexterm>
  19. <indexterm>XSLT<indexterm><codeph>conref</codeph> step</indexterm></indexterm>
  20. </keywords>
  21. </metadata>
  22. </prolog>
  23. <conbody>
  24. <section>
  25. <p>The values of the <xmlatt>id</xmlatt> attribute on referenced content are changed as the elements are pulled
  26. into the new locations. This ensures that the values of the <xmlatt>id</xmlatt> attribute within the referencing
  27. topic remain unique.</p>
  28. <p>If an element is pulled into a new context along with a cross reference that references the target, both the
  29. values of the <xmlatt>id</xmlatt> and <xmlatt>xref</xmlatt> attributes are updated so that they remain valid in
  30. the new location. For example, a referenced topic might include a section as in the following example: <fig>
  31. <title>Referenced topic that contains a section and cross reference</title>
  32. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;topic id="referenced_topic">
  33. &lt;title>...&lt;/title>
  34. &lt;body>
  35. &lt;section id="sect">
  36. &lt;title>Sample section&lt;/title>
  37. &lt;p>Figure &lt;xref href="#referenced_topic/fig"/>
  38. contains a code sample that demonstrates ... .&lt;/p>
  39. &lt;fig id="fig">
  40. &lt;title>Code sample&lt;/title>
  41. &lt;codeblock>....&lt;/codeblock>
  42. &lt;/fig>
  43. &lt;/section>
  44. &lt;/body>
  45. &lt;/topic></codeblock>
  46. </fig></p>
  47. <p>When the section is referenced using a <xmlatt>conref</xmlatt> attribute, the value of the <xmlatt>id</xmlatt>
  48. attribute on the <xmlelement>fig</xmlelement> element is modified to ensure that it remains unique in the new
  49. context. At the same time, the <xmlelement>xref</xmlelement> element is also modified so that it remains valid
  50. as a local reference. For example, if the referencing topic has an <xmlatt>id</xmlatt> set to "new_topic", then
  51. the conrefed element may look like this in the intermediate document <xmlelement>section</xmlelement>. <fig>
  52. <title>Resolved conrefed <xmlelement>section</xmlelement> element after the conref step</title>
  53. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;section id="sect">
  54. &lt;title>Sample section&lt;/title>
  55. &lt;p>Figure &lt;xref href="#new_topic/d1e25"/> contains a code sample
  56. that demonstrates ... .&lt;/p>
  57. &lt;fig id="d1e25">
  58. &lt;title>Code sample&lt;/title>
  59. &lt;codeblock>....&lt;/codeblock>
  60. &lt;/fig>
  61. &lt;/section></codeblock>
  62. </fig></p>
  63. <p>In this case, the value of the <xmlatt>id</xmlatt> attribute on the <xmlelement>fig</xmlelement> element has
  64. been changed to a generated value of "d1e25". At the same time, the <xmlelement>xref</xmlelement> element has
  65. been updated to use that new generated ID, so that the cross reference remains valid.</p>
  66. </section>
  67. </conbody>
  68. </concept>