preprocess-conref.dita 4.0 KB

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