dita2odt-relinks.xsl 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!-- This file is part of the DITA Open Toolkit project.
  3. See the accompanying license.txt file for applicable licenses. -->
  4. <!-- (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved. -->
  5. <xsl:stylesheet
  6. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  8. xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  9. xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  10. xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  11. xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  12. xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  13. xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  14. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"
  15. xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  16. xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
  17. xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  18. xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  19. xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  20. xmlns:math="http://www.w3.org/1998/Math/MathML"
  21. xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  22. xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  23. xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"
  24. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  25. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  26. xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
  27. xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
  28. xmlns:prodtools="http://www.ibm.com/xmlns/prodtools"
  29. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  30. xmlns:related-links="http://dita-ot.sourceforge.net/ns/200709/related-links"
  31. exclude-result-prefixes="xs related-links ditamsg"
  32. version="2.0">
  33. <xsl:output method="xml"/>
  34. <xsl:output indent="yes"/>
  35. <xsl:strip-space elements="*"/>
  36. <xsl:key name="link" match="*[contains(@class, ' topic/link ')][not(ancestor::*[contains(@class, ' topic/linklist ')])]" use="concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ', @href,@type,@role,@platform,@audience,@importance,@outputclass,@keyref,@scope,@format,@otherrole,@product,@otherprops,@rev,@class,normalize-space(child::*[1]))"/>
  37. <xsl:key name="linkdup" match="*[contains(@class, ' topic/link ')][not(ancestor::*[contains(@class, ' topic/linklist ')])][not(@role='child' or @role='parent' or @role='previous' or @role='next' or @role='ancestor' or @role='descendant')]" use="concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ', @href)"/>
  38. <xsl:key name="hideduplicates" match="*[contains(@class, ' topic/link ')][not(ancestor::*[contains(@class, ' topic/linklist ')])][not(@role) or @role='cousin' or @role='external' or @role='friend' or @role='other' or @role='sample' or @role='sibling']" use="concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ',@href,@scope,@audience,@platform,@product,@otherprops,@rev,@type,normalize-space(child::*[1]))"/>
  39. <!-- ========== Hooks for common user customizations ============== -->
  40. <!-- The following two templates are available for anybody who needs
  41. to put out an token at the start or end of a link, such as an
  42. icon to indicate links to PDF files or external web addresses. -->
  43. <xsl:template match="*" mode="add-link-highlight-at-start"/>
  44. <xsl:template match="*" mode="add-link-highlight-at-end"/>
  45. <xsl:template match="*" mode="add-xref-highlight-at-start"/>
  46. <xsl:template match="*" mode="add-xref-highlight-at-end"/>
  47. <!-- Override this template to add any standard link attributes.
  48. Called for all links. -->
  49. <xsl:template match="*" mode="add-custom-link-attributes"/>
  50. <!-- Override these templates to place some a prefix before generated
  51. child links, such as "Optional" for optional child links. Called
  52. for all child links. -->
  53. <xsl:template match="*" mode="related-links:ordered.child.prefix"/>
  54. <xsl:template match="*" mode="related-links:unordered.child.prefix"/>
  55. <!-- xref tag -->
  56. <xsl:template match="*[contains(@class,' topic/xref ')]">
  57. <xsl:variable name="samefile" as="xs:boolean">
  58. <xsl:call-template name="check_file_location"/>
  59. </xsl:variable>
  60. <xsl:variable name="href-value" as="xs:string?">
  61. <xsl:call-template name="format_href_value"/>
  62. </xsl:variable>
  63. <xsl:choose>
  64. <!-- for footnote -->
  65. <xsl:when test="@type = 'fn'">
  66. <!-- topic id -->
  67. <xsl:variable name="topicId" select="substring-before(substring-after(@href, '#'), '/')"/>
  68. <!-- element id -->
  69. <xsl:variable name="elementId" select="substring-after(@href, '/')"/>
  70. <!-- get footnote text -->
  71. <xsl:variable name="fntext" select="//*[contains(@class, ' topic/topic ')]
  72. [@id = $topicId]
  73. //*[contains(@class, ' topic/fn ')]
  74. [@id = $elementId]/text()"/>
  75. <xsl:variable name="fnNumber">
  76. <xsl:choose>
  77. <xsl:when test="*[not(contains(@class,' topic/desc '))]|text()">
  78. <xsl:apply-templates select="*[not(contains(@class,' topic/desc '))]|text()"/>
  79. </xsl:when>
  80. <xsl:otherwise>
  81. <!--use xref content-->
  82. <!--
  83. <xsl:call-template name="href"/>
  84. -->
  85. </xsl:otherwise>
  86. </xsl:choose>
  87. </xsl:variable>
  88. <text:note text:note-class="footnote">
  89. <text:note-citation text:label="{$fnNumber}">
  90. <xsl:value-of select="$fnNumber"/>
  91. </text:note-citation>
  92. <text:note-body>
  93. <text:p text:style-name="footnote">
  94. <xsl:value-of select="$fntext"/>
  95. </text:p>
  96. </text:note-body>
  97. </text:note>
  98. </xsl:when>
  99. <!-- TODO -->
  100. <xsl:otherwise>
  101. <xsl:choose>
  102. <xsl:when test="@href and not(@href = '')">
  103. <text:a>
  104. <xsl:choose>
  105. <xsl:when test="$samefile='true'">
  106. <xsl:attribute name="xlink:href">
  107. <xsl:value-of select="$href-value"/>
  108. </xsl:attribute>
  109. </xsl:when>
  110. <xsl:otherwise>
  111. <xsl:variable name="NORMAMLIZEDOUTPUT" select="translate($OUTPUTDIR, '\', '/')"/>
  112. <xsl:attribute name="xlink:href">
  113. <xsl:value-of select="concat($FILEREF, $NORMAMLIZEDOUTPUT, '/', $href-value)"/>
  114. </xsl:attribute>
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. <xsl:call-template name="gen-linktxt"/>
  118. <xsl:if test="contains(@class,' topic/link ')">
  119. <xsl:apply-templates select="*[contains(@class,' topic/desc ')]"/>
  120. <text:line-break/>
  121. </xsl:if>
  122. </text:a>
  123. </xsl:when>
  124. <xsl:otherwise>
  125. <xsl:call-template name="output-message">
  126. <xsl:with-param name="id" select="'DOTX028E'"/>
  127. </xsl:call-template>
  128. </xsl:otherwise>
  129. </xsl:choose>
  130. </xsl:otherwise>
  131. </xsl:choose>
  132. </xsl:template>
  133. <!-- ignore desc tag under xref or link -->
  134. <xsl:template match="*[contains(@class,' topic/xref ') or contains(@class, ' topic/link ')]/*[contains(@class,' topic/desc ')]" priority="1"/>
  135. <!--create breadcrumbs for each grouping of ancestor links; include previous, next, and ancestor links, sorted by linkpool/related-links parent. If there is more than one linkpool that contains ancestors, multiple breadcrumb trails will be generated-->
  136. <xsl:template match="*[contains(@class,' topic/related-links ')]" mode="breadcrumb">
  137. <xsl:for-each select="descendant-or-self::*[contains(@class,' topic/related-links ') or contains(@class,' topic/linkpool ')][child::*[@role='ancestor']]">
  138. <text:p>
  139. <xsl:choose>
  140. <!--output previous link first, if it exists-->
  141. <xsl:when test="*[@href][@role='previous']">
  142. <xsl:apply-templates select="*[@href][@role='previous'][1]" mode="breadcrumb"/>
  143. </xsl:when>
  144. <xsl:otherwise/>
  145. </xsl:choose>
  146. <!--if both previous and next links exist, output a separator bar-->
  147. <xsl:if test="*[@href][@role='next'] and *[@href][@role='previous']">
  148. <xsl:text> | </xsl:text>
  149. </xsl:if>
  150. <xsl:choose>
  151. <!--output next link, if it exists-->
  152. <xsl:when test="*[@href][@role='next']">
  153. <xsl:apply-templates select="*[@href][@role='next'][1]" mode="breadcrumb"/>
  154. </xsl:when>
  155. <xsl:otherwise/>
  156. </xsl:choose>
  157. <!--if we have either next or previous, plus ancestors, separate the next/prev from the ancestors with a vertical bar-->
  158. <xsl:if test="(*[@href][@role='next'] or *[@href][@role='previous']) and *[@href][@role='ancestor']">
  159. <xsl:text> | </xsl:text>
  160. </xsl:if>
  161. <!--if ancestors exist, output them, and include a greater-than symbol after each one, including a trailing one-->
  162. <xsl:if test="*[@href][@role='ancestor']">
  163. <xsl:for-each select="*[@href][@role='ancestor']">
  164. <xsl:apply-templates select="."/> &gt;
  165. </xsl:for-each>
  166. </xsl:if>
  167. </text:p>
  168. </xsl:for-each>
  169. </xsl:template>
  170. <!--create prerequisite links with all dups eliminated. -->
  171. <!-- Omit prereq links from unordered related-links (handled by mode="prereqs" template). -->
  172. <xsl:key name="omit-from-unordered-links" match="*[@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='cousin')]" use="1"/>
  173. <xsl:template match="*[contains(@class,' topic/related-links ')]" mode="prereqs">
  174. <!--if there are any prereqs create a list with dups-->
  175. <xsl:if test="descendant::*[contains(@class, ' topic/link ')][not(ancestor::*[contains(@class, ' topic/linklist ')])][@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='previous' or @role='cousin')]">
  176. <text:p>
  177. <text:span text:style-name="default_text_style">
  178. <xsl:call-template name="getVariable">
  179. <xsl:with-param name="id" select="'Prerequisites'"/>
  180. </xsl:call-template>
  181. </text:span>
  182. </text:p>
  183. <!--only create link if there is an href, its importance is required, and the role is compatible (don't want a prereq showing up for a "next" or "parent" link, for example) - remove dups-->
  184. <xsl:apply-templates mode="prereqs" select="descendant::*[generate-id(.)=generate-id(key('link',concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ', @href,@type,@role,@platform,@audience,@importance,@outputclass,@keyref,@scope,@format,@otherrole,@product,@otherprops,@rev,@class,child::*))[1])] [@href] [@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='previous' or @role='cousin')] [not(ancestor::*[contains(@class, ' topic/linklist ')])]"/>
  185. </xsl:if>
  186. </xsl:template>
  187. <xsl:template mode="prereqs" match="*[contains(@class, ' topic/link ')]" priority="2">
  188. <!-- Allow for unknown metadata (future-proofing) -->
  189. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  190. <xsl:variable name="samefile" as="xs:boolean">
  191. <xsl:call-template name="check_file_location"/>
  192. </xsl:variable>
  193. <xsl:variable name="href-value" as="xs:string?">
  194. <xsl:call-template name="format_href_value"/>
  195. </xsl:variable>
  196. <text:p>
  197. <xsl:call-template name="create_related_links">
  198. <xsl:with-param name="samefile" select="$samefile"/>
  199. <xsl:with-param name="href-value" select="$href-value"/>
  200. </xsl:call-template>
  201. </text:p>
  202. </xsl:template>
  203. <xsl:template match="*[contains(@class,' topic/linkinfo ')]" name="topic.linkinfo">
  204. <!--
  205. <xsl:element name="text:line-break"/>
  206. <xsl:element name="text:span">
  207. <xsl:apply-templates/>
  208. </xsl:element>
  209. -->
  210. <text:list-item>
  211. <text:p>
  212. <xsl:apply-templates/>
  213. </text:p>
  214. </text:list-item>
  215. </xsl:template>
  216. <xsl:template match="*[contains(@class, ' topic/linklist ')]">
  217. <text:list>
  218. <xsl:apply-templates/>
  219. </text:list>
  220. </xsl:template>
  221. <xsl:template match="*[contains(@class, ' topic/linklist ')]/*[contains(@class, ' topic/title ')]" name="topic.linklist_title">
  222. <text:list-item>
  223. <text:p>
  224. <xsl:apply-templates/>
  225. </text:p>
  226. </text:list-item>
  227. </xsl:template>
  228. <xsl:template match="*[contains(@class, ' topic/linklist ')]/*[contains(@class, ' topic/desc ')]" name="topic.linklist_desc" priority="2">
  229. <text:list-item>
  230. <text:p>
  231. <xsl:apply-templates/>
  232. </text:p>
  233. </text:list-item>
  234. </xsl:template>
  235. <!-- related-links -->
  236. <!--main template for setting up all links after the body - applied to the related-links container-->
  237. <xsl:template match="*[contains(@class,' topic/related-links ')]" name="topic.related-links">
  238. <xsl:if test="normalize-space($includeRelatedLinkRoles)">
  239. <text:list text:style-name="list_style_without_bullet">
  240. <text:list-item>
  241. <!--handle child/descendants outside of linklists in collection-type=unordered or choice-->
  242. <xsl:call-template name="ul-child-links"/>
  243. <!--handle child/descendants outside of linklists in collection-type=ordered/sequence-->
  244. <xsl:call-template name="ol-child-links"/>
  245. <!--handle next and previous links-->
  246. <!--
  247. <xsl:call-template name="next-prev-parent-links"/>
  248. -->
  249. <!-- Group all unordered links (which have not already been handled by prior sections). Skip duplicate links. -->
  250. <!-- NOTE: The actual grouping code for related-links:group-unordered-links is common between
  251. transform types, and is located in ../common/related-links.xsl. Actual code for
  252. creating group titles and formatting links is located in XSL files specific to each type. -->
  253. <xsl:apply-templates select="." mode="related-links:group-unordered-links">
  254. <xsl:with-param name="nodes" select="descendant::*[contains(@class, ' topic/link ')]
  255. [count(. | key('omit-from-unordered-links', 1)) != count(key('omit-from-unordered-links', 1))]
  256. [generate-id(.)=generate-id((key('hideduplicates', concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ',@href,@scope,@audience,@platform,@product,@otherprops,@rev,@type,normalize-space(child::*[1]))))[1])]"/>
  257. </xsl:apply-templates>
  258. <!--linklists - last but not least, create all the linklists and their links, with no sorting or re-ordering-->
  259. <xsl:apply-templates select="*[contains(@class,' topic/linklist ')]"/>
  260. </text:list-item>
  261. </text:list>
  262. </xsl:if>
  263. </xsl:template>
  264. <!--children links - handle all child or descendant links except those in linklists or ordered collection-types.
  265. Each child is indented, the linktext is bold, and the shortdesc appears in normal text directly below the link, to create a summary-like appearance.-->
  266. <xsl:template name="ul-child-links">
  267. <xsl:if test="descendant::*[contains(@class, ' topic/link ')][@role='child' or @role='descendant'][not(parent::*/@collection-type='sequence')][not(ancestor::*[contains(@class, ' topic/linklist ')])]">
  268. <text:line-break/>
  269. <!--once you've tested that at least one child/descendant exists, apply templates to only the unique ones-->
  270. <xsl:apply-templates select="descendant::*
  271. [generate-id(.)=generate-id(key('link',concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ', @href,@type,@role,@platform,@audience,@importance,@outputclass,@keyref,@scope,@format,@otherrole,@product,@otherprops,@rev,@class,child::*))[1])]
  272. [contains(@class, ' topic/link ')]
  273. [@role='child' or @role='descendant']
  274. [not(parent::*/@collection-type='sequence')]
  275. [not(ancestor::*[contains(@class, ' topic/linklist ')])]"/>
  276. </xsl:if>
  277. </xsl:template>
  278. <!--children links - handle all child or descendant links in ordered collection-types.
  279. Children are displayed in a numbered list, with the target title as the cmd and the shortdesc as info, like a task.
  280. -->
  281. <xsl:template name="ol-child-links">
  282. <xsl:if test="descendant::*[contains(@class, ' topic/link ')][@role='child' or @role='descendant'][parent::*/@collection-type='sequence'][not(ancestor::*[contains(@class, ' topic/linklist ')])]">
  283. <text:list text:style-name="ordered_list_style">
  284. <!--once you've tested that at least one child/descendant exists, apply templates to only the unique ones-->
  285. <xsl:apply-templates select="descendant::*
  286. [generate-id(.)=generate-id(key('link',concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ', @href,@type,@role,@platform,@audience,@importance,@outputclass,@keyref,@scope,@format,@otherrole,@product,@otherprops,@rev,@class,child::*))[1])]
  287. [contains(@class, ' topic/link ')]
  288. [@role='child' or @role='descendant']
  289. [parent::*/@collection-type='sequence']
  290. [not(ancestor-or-self::*[contains(@class, ' topic/linklist ')])]"/>
  291. </text:list>
  292. </xsl:if>
  293. </xsl:template>
  294. <!-- Omit child and descendant links from unordered related-links (handled by ul-child-links and ol-child-links). -->
  295. <xsl:key name="omit-from-unordered-links" match="*[@role='child']" use="1"/>
  296. <xsl:key name="omit-from-unordered-links" match="*[@role='descendant']" use="1"/>
  297. <xsl:template name="gen-linktxt">
  298. <xsl:choose>
  299. <xsl:when test="contains(@class,' topic/xref ')">
  300. <xsl:choose>
  301. <xsl:when test="text() or *">
  302. <xsl:apply-templates/>
  303. </xsl:when>
  304. <xsl:otherwise>
  305. <xsl:value-of select="@href"/>
  306. </xsl:otherwise>
  307. </xsl:choose>
  308. </xsl:when>
  309. <xsl:when test="contains(@class,' topic/link ')">
  310. <xsl:choose>
  311. <xsl:when test="*[contains(@class,' topic/linktext ')]">
  312. <xsl:value-of select="*[contains(@class,' topic/linktext ')]"/>
  313. </xsl:when>
  314. <xsl:when test="text()">
  315. <xsl:value-of select="text()"/>
  316. </xsl:when>
  317. <xsl:otherwise>
  318. <xsl:value-of select="@href"/>
  319. </xsl:otherwise>
  320. </xsl:choose>
  321. </xsl:when>
  322. </xsl:choose>
  323. </xsl:template>
  324. <!--Get Related Information for topic type-->
  325. <xsl:template match="*[contains(@class, ' topic/link ')][@type='topic']" priority="1">
  326. <xsl:param name="links"/>
  327. <xsl:variable name="samefile" as="xs:boolean">
  328. <xsl:call-template name="check_file_location"/>
  329. </xsl:variable>
  330. <xsl:variable name="href-value" as="xs:string?">
  331. <xsl:call-template name="format_href_value"/>
  332. </xsl:variable>
  333. <text:p>
  334. <text:span text:style-name="bold">
  335. <xsl:call-template name="getVariable">
  336. <xsl:with-param name="id" select="'Related information'"/>
  337. </xsl:call-template>
  338. </text:span>
  339. </text:p>
  340. <text:p>
  341. <xsl:call-template name="create_related_links">
  342. <xsl:with-param name="samefile" select="$samefile"/>
  343. <xsl:with-param name="href-value" select="$href-value"/>
  344. </xsl:call-template>
  345. </text:p>
  346. </xsl:template>
  347. <!--Get Related Information for topic type-->
  348. <xsl:template match="*[contains(@class, ' topic/link ')]" priority="0">
  349. <xsl:param name="links"/>
  350. <xsl:variable name="samefile" as="xs:boolean">
  351. <xsl:call-template name="check_file_location"/>
  352. </xsl:variable>
  353. <xsl:variable name="href-value" as="xs:string?">
  354. <xsl:call-template name="format_href_value"/>
  355. </xsl:variable>
  356. <xsl:choose>
  357. <xsl:when test="parent::*[contains(@class, ' topic/linklist ')]">
  358. <text:list-item>
  359. <text:p>
  360. <xsl:call-template name="create_related_links">
  361. <xsl:with-param name="samefile" select="$samefile"/>
  362. <xsl:with-param name="href-value" select="$href-value"/>
  363. </xsl:call-template>
  364. </text:p>
  365. </text:list-item>
  366. </xsl:when>
  367. <xsl:otherwise>
  368. <text:line-break/>
  369. <xsl:call-template name="create_related_links">
  370. <xsl:with-param name="samefile" select="$samefile"/>
  371. <xsl:with-param name="href-value" select="$href-value"/>
  372. </xsl:call-template>
  373. </xsl:otherwise>
  374. </xsl:choose>
  375. </xsl:template>
  376. <!-- same file or not -->
  377. <xsl:template name="check_file_location" as="xs:boolean">
  378. <xsl:sequence select="@href and starts-with(@href,'#')"/>
  379. </xsl:template>
  380. <xsl:template name="format_href_value" as="xs:string?">
  381. <xsl:choose>
  382. <xsl:when test="@href and starts-with(@href,'#')">
  383. <xsl:choose>
  384. <!-- get element id -->
  385. <xsl:when test="contains(@href,'/')">
  386. <xsl:value-of select="concat('#', substring-after(@href,'/'))"/>
  387. </xsl:when>
  388. <xsl:otherwise>
  389. <xsl:value-of select="@href"/>
  390. </xsl:otherwise>
  391. </xsl:choose>
  392. </xsl:when>
  393. <xsl:when test="@href and contains(@href,'#')">
  394. <xsl:value-of select="substring-before(@href,'#')"/>
  395. </xsl:when>
  396. <xsl:when test="@href and not(@href='')">
  397. <xsl:value-of select="@href"/>
  398. </xsl:when>
  399. </xsl:choose>
  400. </xsl:template>
  401. <!-- create related links -->
  402. <xsl:template name="create_related_links">
  403. <xsl:param name="samefile" as="xs:boolean"/>
  404. <xsl:param name="text"/>
  405. <xsl:param name="href-value" as="xs:string?"/>
  406. <xsl:choose>
  407. <xsl:when test="@href and not(@href='')">
  408. <text:a>
  409. <xsl:choose>
  410. <xsl:when test="$samefile">
  411. <xsl:attribute name="xlink:href">
  412. <xsl:value-of select="$href-value"/>
  413. </xsl:attribute>
  414. </xsl:when>
  415. <xsl:otherwise>
  416. <xsl:variable name="NORMAMLIZEDOUTPUT" select="translate($OUTPUTDIR, '\', '/')"/>
  417. <xsl:attribute name="xlink:href">
  418. <xsl:value-of select="concat($FILEREF, $NORMAMLIZEDOUTPUT, '/', $href-value)"/>
  419. </xsl:attribute>
  420. </xsl:otherwise>
  421. </xsl:choose>
  422. <xsl:call-template name="gen-linktxt"/>
  423. <xsl:if test="contains(@class,' topic/link ')">
  424. <xsl:apply-templates select="*[contains(@class,' topic/desc ')]"/>
  425. <text:line-break/>
  426. </xsl:if>
  427. </text:a>
  428. </xsl:when>
  429. <xsl:otherwise>
  430. <xsl:call-template name="output-message">
  431. <xsl:with-param name="id" select="'DOTX028E'"/>
  432. </xsl:call-template>
  433. </xsl:otherwise>
  434. </xsl:choose>
  435. </xsl:template>
  436. </xsl:stylesheet>