rel-links.xsl 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!-- This file is part of the DITA Open Toolkit project hosted on
  3. Sourceforge.net. See the accompanying license.txt file for
  4. applicable licenses.-->
  5. <!-- (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved. -->
  6. <xsl:stylesheet version="2.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  9. xmlns:related-links="http://dita-ot.sourceforge.net/ns/200709/related-links"
  10. exclude-result-prefixes="related-links ditamsg">
  11. <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(string-join(*, ' ')))"/>
  12. <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)"/>
  13. <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(string-join(*, ' ')))"/>
  14. <xsl:param name="NOPARENTLINK" select="'no'"/><!-- "no" and "yes" are valid values; non-'no' is ignored -->
  15. <!-- ========== Hooks for common user customizations ============== -->
  16. <!-- The following two templates are available for anybody who needs
  17. to put out an token at the start or end of a link, such as an
  18. icon to indicate links to PDF files or external web addresses. -->
  19. <xsl:template match="*" mode="add-link-highlight-at-start"/>
  20. <xsl:template match="*" mode="add-link-highlight-at-end"/>
  21. <xsl:template match="*" mode="add-xref-highlight-at-start"/>
  22. <xsl:template match="*" mode="add-xref-highlight-at-end"/>
  23. <!-- Override this template to add any standard link attributes.
  24. Called for all links. -->
  25. <xsl:template match="*" mode="add-custom-link-attributes"/>
  26. <!-- Override these templates to place some a prefix before generated
  27. child links, such as "Optional" for optional child links. Called
  28. for all child links. -->
  29. <xsl:template match="*" mode="related-links:ordered.child.prefix"/>
  30. <xsl:template match="*" mode="related-links:unordered.child.prefix"/>
  31. <!-- ========== End hooks for common user customizations ========== -->
  32. <!--template for xref-->
  33. <xsl:template match="*[contains(@class,' topic/xref ')]" name="topic.xref">
  34. <xsl:choose>
  35. <xsl:when test="@href and normalize-space(@href)!=''">
  36. <xsl:apply-templates select="." mode="add-xref-highlight-at-start"/>
  37. <a>
  38. <xsl:apply-templates select="." mode="add-linking-attributes"/>
  39. <xsl:apply-templates select="." mode="add-desc-as-hoverhelp"/>
  40. <!-- if there is text or sub element other than desc, apply templates to them
  41. otherwise, use the href as the value of link text. -->
  42. <xsl:choose>
  43. <xsl:when test="@type='fn'">
  44. <sup>
  45. <xsl:choose>
  46. <xsl:when test="*[not(contains(@class,' topic/desc '))]|text()">
  47. <xsl:apply-templates select="*[not(contains(@class,' topic/desc '))]|text()"/>
  48. <!--use xref content-->
  49. </xsl:when>
  50. <xsl:otherwise>
  51. <xsl:call-template name="href"/><!--use href text-->
  52. </xsl:otherwise>
  53. </xsl:choose>
  54. </sup>
  55. </xsl:when>
  56. <xsl:otherwise>
  57. <xsl:choose>
  58. <xsl:when test="*[not(contains(@class,' topic/desc '))]|text()">
  59. <xsl:apply-templates select="*[not(contains(@class,' topic/desc '))]|text()"/>
  60. <!--use xref content-->
  61. </xsl:when>
  62. <xsl:otherwise>
  63. <xsl:call-template name="href"/><!--use href text-->
  64. </xsl:otherwise>
  65. </xsl:choose>
  66. </xsl:otherwise>
  67. </xsl:choose>
  68. </a>
  69. <xsl:apply-templates select="." mode="add-xref-highlight-at-end"/>
  70. </xsl:when>
  71. <xsl:otherwise>
  72. <xsl:apply-templates select="*|text()|comment()|processing-instruction()"/>
  73. </xsl:otherwise>
  74. </xsl:choose>
  75. </xsl:template>
  76. <!--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-->
  77. <xsl:template match="*[contains(@class,' topic/related-links ')]" mode="breadcrumb">
  78. <xsl:for-each select="descendant-or-self::*[contains(@class,' topic/related-links ') or contains(@class,' topic/linkpool ')][child::*[@role='ancestor']]">
  79. <xsl:value-of select="$newline"/><div class="breadcrumb">
  80. <xsl:choose>
  81. <!--output previous link first, if it exists-->
  82. <xsl:when test="*[@href][@role='previous']">
  83. <xsl:apply-templates select="*[@href][@role='previous'][1]" mode="breadcrumb"/>
  84. </xsl:when>
  85. <xsl:otherwise/>
  86. </xsl:choose>
  87. <!--if both previous and next links exist, output a separator bar-->
  88. <xsl:if test="*[@href][@role='next'] and *[@href][@role='previous']">
  89. <xsl:text> | </xsl:text>
  90. </xsl:if>
  91. <xsl:choose>
  92. <!--output next link, if it exists-->
  93. <xsl:when test="*[@href][@role='next']">
  94. <xsl:apply-templates select="*[@href][@role='next'][1]" mode="breadcrumb"/>
  95. </xsl:when>
  96. <xsl:otherwise/>
  97. </xsl:choose>
  98. <!--if we have either next or previous, plus ancestors, separate the next/prev from the ancestors with a vertical bar-->
  99. <xsl:if test="(*[@href][@role='next'] or *[@href][@role='previous']) and *[@href][@role='ancestor']">
  100. <xsl:text> | </xsl:text>
  101. </xsl:if>
  102. <!--if ancestors exist, output them, and include a greater-than symbol after each one, including a trailing one-->
  103. <xsl:if test="*[@href][@role='ancestor']">
  104. <xsl:for-each select="*[@href][@role='ancestor']">
  105. <xsl:apply-templates select="."/> &gt;
  106. </xsl:for-each>
  107. </xsl:if>
  108. </div><xsl:value-of select="$newline"/>
  109. </xsl:for-each>
  110. </xsl:template>
  111. <!--create prerequisite links with all dups eliminated. -->
  112. <xsl:template match="*[contains(@class,' topic/related-links ')]" mode="prereqs">
  113. <!--if there are any prereqs create a list with dups-->
  114. <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')]">
  115. <xsl:value-of select="$newline"/><dl class="prereqlinks"><xsl:value-of select="$newline"/>
  116. <dt class="prereq">
  117. <xsl:call-template name="getVariable">
  118. <xsl:with-param name="id" select="'Prerequisites'"/>
  119. </xsl:call-template>
  120. </dt><xsl:value-of select="$newline"/>
  121. <!--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-->
  122. <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, normalize-space(string-join(*, ' '))))[1])]
  123. [@href]
  124. [@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='previous' or @role='cousin')]
  125. [not(ancestor::*[contains(@class, ' topic/linklist ')])]"/>
  126. </dl><xsl:value-of select="$newline"/>
  127. </xsl:if>
  128. </xsl:template>
  129. <!-- Omit prereq links from unordered related-links (handled by mode="prereqs" template). -->
  130. <xsl:key name="omit-from-unordered-links" match="*[@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='cousin')]" use="1"/>
  131. <!--main template for setting up all links after the body - applied to the related-links container-->
  132. <xsl:template match="*[contains(@class,' topic/related-links ')]" name="topic.related-links">
  133. <div>
  134. <xsl:call-template name="ul-child-links"/><!--handle child/descendants outside of linklists in collection-type=unordered or choice-->
  135. <xsl:call-template name="ol-child-links"/><!--handle child/descendants outside of linklists in collection-type=ordered/sequence-->
  136. <xsl:call-template name="next-prev-parent-links"/><!--handle next and previous links-->
  137. <!-- Calls to typed links deprecated. Grouping instead performed by related-links:group-unordered-links template. -->
  138. <!--<xsl:call-template name="concept-links"/>--><!--sort remaining concept links by type-->
  139. <!--<xsl:call-template name="task-links"/>--><!--sort remaining task links by type-->
  140. <!--<xsl:call-template name="reference-links"/>--><!--sort remaining reference links by type-->
  141. <!--<xsl:call-template name="relinfo-links"/>--><!--handle remaining untyped and unknown-type links-->
  142. <!-- Group all unordered links (which have not already been handled by prior sections). Skip duplicate links. -->
  143. <!-- NOTE: The actual grouping code for related-links:group-unordered-links is common between
  144. transform types, and is located in ../common/related-links.xsl. Actual code for
  145. creating group titles and formatting links is located in XSL files specific to each type. -->
  146. <xsl:apply-templates select="." mode="related-links:group-unordered-links">
  147. <xsl:with-param name="nodes" select="descendant::*[contains(@class, ' topic/link ')]
  148. [count(. | key('omit-from-unordered-links', 1)) != count(key('omit-from-unordered-links', 1))]
  149. [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(string-join(*, ' ')))))[1])]"/>
  150. </xsl:apply-templates>
  151. <!--linklists - last but not least, create all the linklists and their links, with no sorting or re-ordering-->
  152. <xsl:apply-templates select="*[contains(@class,' topic/linklist ')]"/>
  153. </div>
  154. </xsl:template>
  155. <!--children links - handle all child or descendant links except those in linklists or ordered collection-types.
  156. 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.-->
  157. <xsl:template name="ul-child-links">
  158. <xsl:if test="descendant::*[contains(@class, ' topic/link ')][@role='child' or @role='descendant'][not(parent::*/@collection-type='sequence')][not(ancestor::*[contains(@class, ' topic/linklist ')])]">
  159. <xsl:value-of select="$newline"/><ul class="ullinks"><xsl:value-of select="$newline"/>
  160. <!--once you've tested that at least one child/descendant exists, apply templates to only the unique ones-->
  161. <xsl:apply-templates select="descendant::*
  162. [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, normalize-space(string-join(*, ' '))))[1])]
  163. [contains(@class, ' topic/link ')]
  164. [@role='child' or @role='descendant']
  165. [not(parent::*/@collection-type='sequence')]
  166. [not(ancestor::*[contains(@class, ' topic/linklist ')])]"/>
  167. </ul><xsl:value-of select="$newline"/>
  168. </xsl:if>
  169. </xsl:template>
  170. <!--children links - handle all child or descendant links in ordered collection-types.
  171. Children are displayed in a numbered list, with the target title as the cmd and the shortdesc as info, like a task.
  172. -->
  173. <xsl:template name="ol-child-links">
  174. <xsl:if test="descendant::*[contains(@class, ' topic/link ')][@role='child' or @role='descendant'][parent::*/@collection-type='sequence'][not(ancestor::*[contains(@class, ' topic/linklist ')])]">
  175. <xsl:value-of select="$newline"/><ol class="olchildlinks"><xsl:value-of select="$newline"/>
  176. <!--once you've tested that at least one child/descendant exists, apply templates to only the unique ones-->
  177. <xsl:apply-templates select="descendant::*
  178. [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, normalize-space(string-join(*, ' '))))[1])]
  179. [contains(@class, ' topic/link ')]
  180. [@role='child' or @role='descendant']
  181. [parent::*/@collection-type='sequence']
  182. [not(ancestor-or-self::*[contains(@class, ' topic/linklist ')])]"/>
  183. </ol><xsl:value-of select="$newline"/>
  184. </xsl:if>
  185. </xsl:template>
  186. <!-- Omit child and descendant links from unordered related-links (handled by ul-child-links and ol-child-links). -->
  187. <xsl:key name="omit-from-unordered-links" match="*[@role='child']" use="1"/>
  188. <xsl:key name="omit-from-unordered-links" match="*[@role='descendant']" use="1"/>
  189. <!--create the next and previous links, with accompanying parent link if any; create group for each unique parent, as well as for any next and previous links that aren't in the same group as a parent-->
  190. <xsl:template name="next-prev-parent-links">
  191. <xsl:for-each select="descendant::*
  192. [contains(@class, ' topic/link ')]
  193. [(@role='parent' and
  194. 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, normalize-space(string-join(*, ' '))))[1])
  195. ) or (@role='next' and
  196. 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, normalize-space(string-join(*, ' '))))[1])
  197. ) or (@role='previous' and
  198. 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, normalize-space(string-join(*, ' '))))[1])
  199. )]/parent::*">
  200. <xsl:value-of select="$newline"/><div class="familylinks"><xsl:value-of select="$newline"/>
  201. <xsl:if test="$NOPARENTLINK='no'">
  202. <xsl:choose>
  203. <xsl:when test="*[@href][@role='parent']">
  204. <xsl:for-each select="*[@href][@role='parent']">
  205. <div class="parentlink"><xsl:apply-templates select="."/></div><xsl:value-of select="$newline"/>
  206. </xsl:for-each>
  207. </xsl:when>
  208. <xsl:otherwise>
  209. <xsl:for-each select="*[@href][@role='ancestor'][last()]">
  210. <div class="parentlink"><xsl:call-template name="parentlink"/></div><xsl:value-of select="$newline"/>
  211. </xsl:for-each>
  212. </xsl:otherwise>
  213. </xsl:choose>
  214. </xsl:if>
  215. <xsl:for-each select="*[@href][@role='previous']">
  216. <div class="previouslink"><xsl:apply-templates select="."/></div><xsl:value-of select="$newline"/>
  217. </xsl:for-each>
  218. <xsl:for-each select="*[@href][@role='next']">
  219. <div class="nextlink"><xsl:apply-templates select="."/></div><xsl:value-of select="$newline"/>
  220. </xsl:for-each>
  221. </div><xsl:value-of select="$newline"/>
  222. </xsl:for-each>
  223. </xsl:template>
  224. <!-- Omit child and descendant links from unordered related-links (handled by next-prev-parent-links). -->
  225. <xsl:key name="omit-from-unordered-links" match="*[@role='next']" use="1"/>
  226. <xsl:key name="omit-from-unordered-links" match="*[@role='previous']" use="1"/>
  227. <xsl:key name="omit-from-unordered-links" match="*[@role='parent']" use="1"/>
  228. <!--type templates: concept, task, reference, relinfo-->
  229. <!-- Deprecated! Use related-links:group-unordered-links template instead. -->
  230. <xsl:template name="concept-links">
  231. <!-- Deprecated! Use related-links:group-unordered-links template instead. -->
  232. <!--related concepts - all the related concept links that haven't already been covered as a child/descendant/ancestor/next/previous/prerequisite, and aren't in a linklist-->
  233. <xsl:if test="descendant::*[contains(@class, ' topic/link ')]
  234. [not(ancestor::*[contains(@class,' topic/linklist ')])]
  235. [not(@role='child' or @role='descendant' or @role='ancestor' or @role='parent' or @role='next' or @role='previous')]
  236. [not(@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='cousin'))]
  237. [@type='concept']">
  238. <div class="relconcepts">
  239. <strong>
  240. <xsl:call-template name="getVariable">
  241. <xsl:with-param name="id" select="'Related concepts'"/>
  242. </xsl:call-template>
  243. </strong><br/><xsl:value-of select="$newline"/>
  244. <!--once the related concepts section is set up, sort links by role within the section, using a shared sorting routine so that it's consistent across sections-->
  245. <xsl:call-template name="sort-links-by-role"><xsl:with-param name="type">concept</xsl:with-param></xsl:call-template>
  246. </div><xsl:value-of select="$newline"/>
  247. </xsl:if>
  248. </xsl:template>
  249. <xsl:template name="task-links">
  250. <!-- Deprecated! Use related-links:group-unordered-links template instead. -->
  251. <!--related tasks - all the related task links that haven't already been covered as a child/descendant/ancestor/next/previous/prerequisite, and aren't in a linklist-->
  252. <xsl:if test="descendant::*[contains(@class, ' topic/link ')]
  253. [not(ancestor::*[contains(@class,' topic/linklist ')])]
  254. [not(@role='child' or @role='descendant' or @role='ancestor' or @role='parent' or @role='next' or @role='previous')]
  255. [not(@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='cousin'))]
  256. [@type='task']">
  257. <div class="reltasks">
  258. <strong>
  259. <xsl:call-template name="getVariable">
  260. <xsl:with-param name="id" select="'Related tasks'"/>
  261. </xsl:call-template>
  262. </strong><br/><xsl:value-of select="$newline"/>
  263. <!--once the related tasks section is set up, sort links by role within the section, using a shared sorting routine so that it's consistent across sections-->
  264. <xsl:call-template name="sort-links-by-role"><xsl:with-param name="type">task</xsl:with-param></xsl:call-template>
  265. </div><xsl:value-of select="$newline"/>
  266. </xsl:if>
  267. </xsl:template>
  268. <xsl:template name="reference-links">
  269. <!-- Deprecated! Use related-links:group-unordered-links template instead. -->
  270. <!--related reference - all the related reference links that haven't already been covered as a child/descendant/ancestor/next/previous/prerequisite, and aren't in a linklist-->
  271. <xsl:if test="descendant::*
  272. [contains(@class, ' topic/link ')]
  273. [not(ancestor::*[contains(@class,' topic/linklist ')])]
  274. [not(@role='child' or @role='descendant' or @role='ancestor' or @role='parent' or @role='next' or @role='previous')]
  275. [not(@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='cousin'))]
  276. [@type='reference']">
  277. <div class="relref">
  278. <strong>
  279. <xsl:call-template name="getVariable">
  280. <xsl:with-param name="id" select="'Related reference'"/>
  281. </xsl:call-template>
  282. </strong><br/><xsl:value-of select="$newline"/>
  283. <!--once the related reference section is set up, sort links by role within the section, using a shared sorting routine so that it's consistent across sections-->
  284. <xsl:call-template name="sort-links-by-role"><xsl:with-param name="type">reference</xsl:with-param></xsl:call-template>
  285. </div><xsl:value-of select="$newline"/>
  286. </xsl:if>
  287. </xsl:template>
  288. <xsl:template name="relinfo-links">
  289. <!-- Deprecated! Use related-links:group-unordered-links template instead. -->
  290. <!--other info- - not currently sorting by role, since already mixing any number of types in here-->
  291. <!--if there are links not covered by any of the other routines - ie, not in a linklist, not a child or descendant, not a concept/task/reference, not ancestor/next/previous, not prerequisite - create a section for them and create the links-->
  292. <xsl:if test="descendant::*
  293. [contains(@class, ' topic/link ')]
  294. [not(ancestor::*[contains(@class,' topic/linklist ')])]
  295. [not(@role='child' or @role='descendant' or @role='ancestor' or @role='parent' or @role='next' or @role='previous' or @type='concept' or @type='task' or @type='reference')]
  296. [not(@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='cousin'))]">
  297. <div class="relinfo">
  298. <strong>
  299. <xsl:call-template name="getVariable">
  300. <xsl:with-param name="id" select="'Related information'"/>
  301. </xsl:call-template>
  302. </strong><br/><xsl:value-of select="$newline"/>
  303. <!--once section is created, create the links, using the same rules as bove plus a uniqueness check-->
  304. <xsl:for-each select="descendant::*
  305. [not(ancestor::*[contains(@class,' topic/linklist ')])]
  306. [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, normalize-space(string-join(*, ' '))))[1])]
  307. [contains(@class, ' topic/link ')]
  308. [not(@role='child' or @role='descendant' or @role='ancestor' or @role='parent' or @role='next' or @role='previous' or @type='concept' or @type='task' or @type='reference')]
  309. [not(@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='cousin'))]">
  310. <xsl:apply-templates select="."/>
  311. </xsl:for-each>
  312. </div><xsl:value-of select="$newline"/>
  313. </xsl:if>
  314. </xsl:template>
  315. <!--template used within concept/task/reference sections to sort links-->
  316. <xsl:template name="sort-links-by-role">
  317. <!-- Deprecated! Use related-links:group-unordered-links template instead. -->
  318. <xsl:param name="type">topic</xsl:param>
  319. <!--create all sibling links of the specified type-->
  320. <xsl:call-template name="create-links"><xsl:with-param name="role">sibling</xsl:with-param><xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param></xsl:call-template>
  321. <!--create all cousin links of the specified type-->
  322. <xsl:call-template name="create-links"><xsl:with-param name="role">cousin</xsl:with-param><xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param></xsl:call-template>
  323. <!--create all friend links of the specified type-->
  324. <xsl:call-template name="create-links"><xsl:with-param name="role">friend</xsl:with-param><xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param></xsl:call-template>
  325. <!--create all links with role="other" of the specified type-->
  326. <xsl:call-template name="create-links"><xsl:with-param name="role">other</xsl:with-param><xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param></xsl:call-template>
  327. <!--create all links with no role of the specified type-->
  328. <xsl:call-template name="create-links"><xsl:with-param name="role">#none#</xsl:with-param><xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param></xsl:call-template>
  329. </xsl:template>
  330. <xsl:template name="create-links">
  331. <!-- Deprecated! Use related-links:group-unordered-links template instead. -->
  332. <!--create links of the specified type and role-->
  333. <xsl:param name="type">topic</xsl:param>
  334. <xsl:param name="role">friend</xsl:param>
  335. <xsl:choose>
  336. <!--when processing links with no role, apply templates to links that are unique, not in a linklist, don't have a role attribute, match the specified type, and aren't prerequisites-->
  337. <xsl:when test="$role='#none#'">
  338. <xsl:for-each select="descendant::*
  339. [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, normalize-space(string-join(*, ' '))))[1])]
  340. [contains(@class, ' topic/link ')]
  341. [not(ancestor::*[contains(@class,' topic/linklist ')])]
  342. [not(@role)]
  343. [@type=$type]
  344. [not(@importance='required')]">
  345. <xsl:apply-templates select="."/>
  346. </xsl:for-each>
  347. </xsl:when>
  348. <!--when processing links with a specified role, apply templates to links that are unique, not in a linklist, match the specified role and type, and aren't prerequisites-->
  349. <xsl:otherwise>
  350. <xsl:for-each select="descendant::*
  351. [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, normalize-space(string-join(*, ' '))))[1])]
  352. [not(ancestor::*[contains(@class,' topic/linklist ')])]
  353. [contains(@class, ' topic/link ')]
  354. [@role=$role]
  355. [@type=$type]
  356. [not(@importance='required' and (@role='sibling' or @role='friend' or @role='previous' or @role='cousin'))]">
  357. <xsl:apply-templates select="."/>
  358. </xsl:for-each>
  359. </xsl:otherwise>
  360. </xsl:choose>
  361. </xsl:template>
  362. <!-- Override no-name group wrapper template for HTML: output "Related Information" in a <div>. -->
  363. <xsl:template match="*[contains(@class, ' topic/link ')]" mode="related-links:result-group" name="related-links:group-result.">
  364. <xsl:param name="links"/>
  365. <div class="relinfo">
  366. <strong>
  367. <xsl:call-template name="getVariable">
  368. <xsl:with-param name="id" select="'Related information'"/>
  369. </xsl:call-template>
  370. </strong><br/><xsl:value-of select="$newline"/>
  371. <xsl:copy-of select="$links"/>
  372. </div><xsl:value-of select="$newline"/>
  373. </xsl:template>
  374. <!-- Links with @type="topic" belong in no-name group. -->
  375. <xsl:template match="*[contains(@class, ' topic/link ')][@type='topic']" mode="related-links:get-group-priority" name="related-links:group-priority.topic" priority="2">
  376. <xsl:call-template name="related-links:group-priority."></xsl:call-template>
  377. </xsl:template>
  378. <xsl:template match="*[contains(@class, ' topic/link ')][@type='topic']" mode="related-links:get-group" name="related-links:group.topic" priority="2">
  379. <xsl:call-template name="related-links:group."></xsl:call-template>
  380. </xsl:template>
  381. <xsl:template match="*[contains(@class, ' topic/link ')][@type='topic']" mode="related-links:result-group" name="related-links:group-result.topic" priority="2">
  382. <xsl:param name="links"/>
  383. <xsl:call-template name="related-links:group-result.">
  384. <xsl:with-param name="links" select="$links"></xsl:with-param>
  385. </xsl:call-template>
  386. </xsl:template>
  387. <!--calculate href-->
  388. <xsl:template name="href">
  389. <xsl:apply-templates select="." mode="determine-final-href"/>
  390. </xsl:template>
  391. <xsl:template match="*" mode="determine-final-href">
  392. <xsl:choose>
  393. <xsl:when test="normalize-space(@href)='' or not(@href)"/>
  394. <!-- For non-DITA formats - use the href as is -->
  395. <xsl:when test="(not(@format) and (@type='external' or @scope='external')) or (@format and not(@format='dita'))">
  396. <xsl:value-of select="@href"/>
  397. </xsl:when>
  398. <!-- For DITA - process the internal href -->
  399. <xsl:when test="starts-with(@href,'#')">
  400. <xsl:call-template name="parsehref">
  401. <xsl:with-param name="href" select="@href"/>
  402. </xsl:call-template>
  403. </xsl:when>
  404. <!-- It's to a DITA file - process the file name (adding the html extension)
  405. and process the rest of the href -->
  406. <xsl:when test="(not(@scope) or @scope='local' or @scope='peer') and (not(@format) or @format='dita')">
  407. <xsl:call-template name="replace-extension">
  408. <xsl:with-param name="filename" select="@href"/>
  409. <xsl:with-param name="extension" select="$OUTEXT"/>
  410. <xsl:with-param name="ignore-fragment" select="true()"/>
  411. </xsl:call-template>
  412. <xsl:if test="contains(@href, '#')">
  413. <xsl:text>#</xsl:text>
  414. <xsl:call-template name="parsehref">
  415. <xsl:with-param name="href" select="substring-after(@href, '#')"/>
  416. </xsl:call-template>
  417. </xsl:if>
  418. </xsl:when>
  419. <xsl:otherwise>
  420. <xsl:apply-templates select="." mode="ditamsg:unknown-extension"/>
  421. <xsl:value-of select="@href"/>
  422. </xsl:otherwise>
  423. </xsl:choose>
  424. </xsl:template>
  425. <!-- "/" is not legal in IDs - need to swap it with two underscores -->
  426. <xsl:template name="parsehref">
  427. <xsl:param name="href"/>
  428. <xsl:choose>
  429. <xsl:when test="contains($href,'/')">
  430. <xsl:value-of select="substring-before($href,'/')"/>__<xsl:value-of select="substring-after($href,'/')"/>
  431. </xsl:when>
  432. <xsl:otherwise>
  433. <xsl:value-of select="$href"/>
  434. </xsl:otherwise>
  435. </xsl:choose>
  436. </xsl:template>
  437. <!--breadcrumb template: next, prev-->
  438. <xsl:template match="*[contains(@class, ' topic/link ')][@role='next' or @role='previous']" mode="breadcrumb">
  439. <a>
  440. <xsl:apply-templates select="." mode="add-linking-attributes"/>
  441. <xsl:apply-templates select="." mode="add-title-as-hoverhelp"/>
  442. <!-- Allow for unknown metadata (future-proofing) -->
  443. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  444. <!--use string as output link text for now, use image eventually-->
  445. <xsl:choose>
  446. <xsl:when test="@role='next'">
  447. <xsl:call-template name="getVariable">
  448. <xsl:with-param name="id" select="'Next topic'"/>
  449. </xsl:call-template>
  450. </xsl:when>
  451. <xsl:when test="@role='previous'">
  452. <xsl:call-template name="getVariable">
  453. <xsl:with-param name="id" select="'Previous topic'"/>
  454. </xsl:call-template>
  455. </xsl:when>
  456. <xsl:otherwise><!--both role values tested - no otherwise--></xsl:otherwise>
  457. </xsl:choose>
  458. </a>
  459. </xsl:template>
  460. <!--prereq template-->
  461. <xsl:template mode="prereqs" match="*[contains(@class, ' topic/link ')]" priority="2">
  462. <dd>
  463. <!-- Allow for unknown metadata (future-proofing) -->
  464. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  465. <xsl:call-template name="makelink"/>
  466. </dd><xsl:value-of select="$newline"/>
  467. </xsl:template>
  468. <!--plain templates: next, prev, ancestor/parent, children, everything else-->
  469. <xsl:template name="nextlink" match="*[contains(@class, ' topic/link ')][@role='next']" priority="2">
  470. <strong>
  471. <!-- Allow for unknown metadata (future-proofing) -->
  472. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  473. <xsl:call-template name="getVariable">
  474. <xsl:with-param name="id" select="'Next topic'"/>
  475. </xsl:call-template>
  476. <xsl:call-template name="getVariable">
  477. <xsl:with-param name="id" select="'ColonSymbol'"/>
  478. </xsl:call-template>
  479. </strong><xsl:text> </xsl:text>
  480. <xsl:call-template name="makelink"/>
  481. </xsl:template>
  482. <xsl:template name="prevlink" match="*[contains(@class, ' topic/link ')][@role='previous']" priority="2">
  483. <strong>
  484. <!-- Allow for unknown metadata (future-proofing) -->
  485. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  486. <xsl:call-template name="getVariable">
  487. <xsl:with-param name="id" select="'Previous topic'"/>
  488. </xsl:call-template>
  489. <xsl:call-template name="getVariable">
  490. <xsl:with-param name="id" select="'ColonSymbol'"/>
  491. </xsl:call-template>
  492. </strong><xsl:text> </xsl:text>
  493. <xsl:call-template name="makelink"/>
  494. </xsl:template>
  495. <xsl:template name="parentlink" match="*[contains(@class, ' topic/link ')][@role='parent']" priority="2">
  496. <strong>
  497. <!-- Allow for unknown metadata (future-proofing) -->
  498. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  499. <xsl:call-template name="getVariable">
  500. <xsl:with-param name="id" select="'Parent topic'"/>
  501. </xsl:call-template>
  502. <xsl:call-template name="getVariable">
  503. <xsl:with-param name="id" select="'ColonSymbol'"/>
  504. </xsl:call-template>
  505. </strong><xsl:text> </xsl:text>
  506. <xsl:call-template name="makelink"/>
  507. </xsl:template>
  508. <!--basic child processing-->
  509. <xsl:template match="*[contains(@class, ' topic/link ')][@role='child' or @role='descendant']" priority="2" name="topic.link_child">
  510. <xsl:variable name="el-name">
  511. <xsl:choose>
  512. <xsl:when test="contains(../@class,' topic/linklist ')">div</xsl:when>
  513. <xsl:otherwise>li</xsl:otherwise>
  514. </xsl:choose>
  515. </xsl:variable>
  516. <xsl:element name="{$el-name}">
  517. <xsl:attribute name="class">ulchildlink</xsl:attribute>
  518. <!-- Allow for unknown metadata (future-proofing) -->
  519. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  520. <strong>
  521. <xsl:apply-templates select="." mode="related-links:unordered.child.prefix"/>
  522. <xsl:apply-templates select="." mode="add-link-highlight-at-start"/>
  523. <a>
  524. <xsl:apply-templates select="." mode="add-linking-attributes"/>
  525. <xsl:apply-templates select="." mode="add-hoverhelp-to-child-links"/>
  526. <!--use linktext as linktext if it exists, otherwise use href as linktext-->
  527. <xsl:choose>
  528. <xsl:when test="*[contains(@class, ' topic/linktext ')]"><xsl:apply-templates select="*[contains(@class, ' topic/linktext ')]"/></xsl:when>
  529. <xsl:otherwise><!--use href--><xsl:call-template name="href"/></xsl:otherwise>
  530. </xsl:choose>
  531. </a>
  532. <xsl:apply-templates select="." mode="add-link-highlight-at-end"/>
  533. </strong>
  534. <br/><xsl:value-of select="$newline"/>
  535. <!--add the description on the next line, like a summary-->
  536. <xsl:apply-templates select="*[contains(@class, ' topic/desc ')]"/>
  537. </xsl:element><xsl:value-of select="$newline"/>
  538. </xsl:template>
  539. <!--ordered child processing-->
  540. <xsl:template match="*[@collection-type='sequence']/*[contains(@class, ' topic/link ')][@role='child' or @role='descendant']" priority="3" name="topic.link_orderedchild">
  541. <xsl:variable name="el-name">
  542. <xsl:choose>
  543. <xsl:when test="contains(../@class,' topic/linklist ')">div</xsl:when>
  544. <xsl:otherwise>li</xsl:otherwise>
  545. </xsl:choose>
  546. </xsl:variable>
  547. <xsl:element name="{$el-name}">
  548. <xsl:attribute name="class">olchildlink</xsl:attribute>
  549. <!-- Allow for unknown metadata (future-proofing) -->
  550. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  551. <xsl:apply-templates select="." mode="related-links:ordered.child.prefix"/>
  552. <xsl:apply-templates select="." mode="add-link-highlight-at-start"/>
  553. <a>
  554. <xsl:apply-templates select="." mode="add-linking-attributes"/>
  555. <xsl:apply-templates select="." mode="add-hoverhelp-to-child-links"/>
  556. <!--use linktext as linktext if it exists, otherwise use href as linktext-->
  557. <xsl:choose>
  558. <xsl:when test="*[contains(@class, ' topic/linktext ')]"><xsl:apply-templates select="*[contains(@class, ' topic/linktext ')]"/></xsl:when>
  559. <xsl:otherwise><!--use href--><xsl:call-template name="href"/></xsl:otherwise>
  560. </xsl:choose>
  561. </a>
  562. <xsl:apply-templates select="." mode="add-link-highlight-at-end"/>
  563. <br/><xsl:value-of select="$newline"/>
  564. <!--add the description on a new line, unlike an info, to avoid issues with punctuation (adding a period)-->
  565. <xsl:apply-templates select="*[contains(@class, ' topic/desc ')]"/>
  566. </xsl:element><xsl:value-of select="$newline"/>
  567. </xsl:template>
  568. <xsl:template match="*[contains(@class, ' topic/link ')]" name="topic.link">
  569. <xsl:choose>
  570. <!-- Linklist links put out <br/> in "processlinklist" -->
  571. <xsl:when test="ancestor::*[contains(@class,' topic/linklist ')]">
  572. <xsl:call-template name="makelink"/>
  573. </xsl:when>
  574. <!-- Ancestor links go in the breadcrumb trail, and should not get a <br/> -->
  575. <xsl:when test="@role='ancestor'">
  576. <xsl:call-template name="makelink"/>
  577. </xsl:when>
  578. <!-- Items with these roles should always go to output, and are not included in the hideduplicates key. -->
  579. <xsl:when test="@role and not(@role='cousin' or @role='external' or @role='friend' or @role='other' or @role='sample' or @role='sibling')">
  580. <div><xsl:call-template name="makelink"/></div><xsl:value-of select="$newline"/>
  581. </xsl:when>
  582. <!-- If roles do not match, but nearly everything else does, skip the link. -->
  583. <xsl:when test="(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(string-join(*, ' ')))))[2]">
  584. <xsl:choose>
  585. <xsl:when test="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(string-join(*, ' ')))))[1])">
  586. <div><xsl:call-template name="makelink"/></div><xsl:value-of select="$newline"/>
  587. </xsl:when>
  588. <!-- If this is filtered out, we may need the duplicate link message anyway. -->
  589. <xsl:otherwise><xsl:call-template name="linkdupinfo"/></xsl:otherwise>
  590. </xsl:choose>
  591. </xsl:when>
  592. <xsl:otherwise><div><xsl:call-template name="makelink"/></div><xsl:value-of select="$newline"/></xsl:otherwise>
  593. </xsl:choose>
  594. </xsl:template>
  595. <!--creating the actual link-->
  596. <xsl:template name="makelink">
  597. <xsl:call-template name="linkdupinfo"/>
  598. <xsl:apply-templates select="." mode="add-link-highlight-at-start"/>
  599. <a>
  600. <xsl:apply-templates select="." mode="add-linking-attributes"/>
  601. <xsl:apply-templates select="." mode="add-desc-as-hoverhelp"/>
  602. <!-- Allow for unknown metadata (future-proofing) -->
  603. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  604. <!--use linktext as linktext if it exists, otherwise use href as linktext-->
  605. <xsl:choose>
  606. <xsl:when test="*[contains(@class, ' topic/linktext ')]"><xsl:apply-templates select="*[contains(@class, ' topic/linktext ')]"/></xsl:when>
  607. <xsl:otherwise><!--use href--><xsl:call-template name="href"/></xsl:otherwise>
  608. </xsl:choose>
  609. </a>
  610. <xsl:apply-templates select="." mode="add-link-highlight-at-end"/>
  611. </xsl:template>
  612. <!--process linktext elements by explicitly ignoring them and applying templates to their content; otherwise flagged as unprocessed content by the dit2htm transform-->
  613. <xsl:template match="*[contains(@class, ' topic/linktext ')]" name="topic.linktext">
  614. <xsl:apply-templates select="*|text()"/>
  615. </xsl:template>
  616. <!--process link desc by explicitly ignoring them and applying templates to their content; otherwise flagged as unprocessed content by the dit2htm transform-->
  617. <xsl:template match="*[contains(@class, ' topic/link ')]/*[contains(@class, ' topic/desc ')]" name="topic.link_desc">
  618. <xsl:apply-templates select="*|text()"/>
  619. </xsl:template>
  620. <!--linklists-->
  621. <xsl:template match="*[contains(@class,' topic/linklist ')]" name="topic.linklist">
  622. <xsl:value-of select="$newline"/>
  623. <xsl:choose>
  624. <!--if this is a first-level linklist with no child links in it, put it in a div (flush left)-->
  625. <xsl:when test="parent::*[contains(@class,' topic/related-links ')] and not(child::*[contains(@class,' topic/link ')][@role='child' or @role='descendant'])">
  626. <div class="linklist"><xsl:apply-templates select="." mode="processlinklist"/></div>
  627. </xsl:when>
  628. <!-- When it contains children, indent with child class -->
  629. <xsl:when test="child::*[contains(@class,' topic/link ')][@role='child' or @role='descendant']">
  630. <div class="linklistwithchild">
  631. <xsl:apply-templates select="." mode="processlinklist">
  632. <xsl:with-param name="default-list-type" select="'linklistwithchild'"/>
  633. </xsl:apply-templates>
  634. </div>
  635. </xsl:when>
  636. <!-- It is a nested linklist, indent with other class -->
  637. <xsl:otherwise>
  638. <div class="sublinklist">
  639. <xsl:apply-templates select="." mode="processlinklist">
  640. <xsl:with-param name="default-list-type" select="'sublinklist'"/>
  641. </xsl:apply-templates>
  642. </div>
  643. </xsl:otherwise>
  644. </xsl:choose>
  645. <xsl:value-of select="$newline"/>
  646. </xsl:template>
  647. <!-- Omit any descendants of linklist from unordered related links (handled by topic.linklist template). -->
  648. <xsl:key name="omit-from-unordered-links" match="*[ancestor::*[contains(@class,' topic/linklist ')]]" use="1"/>
  649. <xsl:template name="processlinklist">
  650. <xsl:apply-templates select="." mode="processlinklist"/>
  651. </xsl:template>
  652. <xsl:template match="*" mode="processlinklist">
  653. <xsl:param name="default-list-type" select="'linklist'"/>
  654. <xsl:apply-templates select="*[contains(@class, ' topic/title ')]"/>
  655. <xsl:apply-templates select="*[contains(@class,' topic/desc ')]"/>
  656. <xsl:for-each select="*[contains(@class,' topic/linklist ')]|*[contains(@class,' topic/link ')]">
  657. <xsl:choose>
  658. <!-- for children, div wrapper is created in main template -->
  659. <xsl:when test="contains(@class,' topic/link ') and (@role='child' or @role='descendant')">
  660. <xsl:value-of select="$newline"/><xsl:apply-templates select="."/>
  661. </xsl:when>
  662. <xsl:when test="contains(@class,' topic/link ')">
  663. <xsl:value-of select="$newline"/><div><xsl:apply-templates select="."/></div>
  664. </xsl:when>
  665. <xsl:otherwise> <!-- nested linklist -->
  666. <xsl:apply-templates select="."/>
  667. </xsl:otherwise>
  668. </xsl:choose>
  669. </xsl:for-each>
  670. <xsl:apply-templates select="*[contains(@class,' topic/linkinfo ')]"/>
  671. </xsl:template>
  672. <xsl:template match="*[contains(@class,' topic/linkinfo ')]" name="topic.linkinfo">
  673. <xsl:apply-templates/><br/><xsl:value-of select="$newline"/>
  674. </xsl:template>
  675. <xsl:template match="*[contains(@class, ' topic/linklist ')]/*[contains(@class, ' topic/title ')]" name="topic.linklist_title">
  676. <strong><xsl:apply-templates/></strong><br/><xsl:value-of select="$newline"/>
  677. </xsl:template>
  678. <xsl:template match="*[contains(@class, ' topic/linklist ')]/*[contains(@class, ' topic/desc ')]" name="topic.linklist_desc">
  679. <xsl:apply-templates/><br/><xsl:value-of select="$newline"/>
  680. </xsl:template>
  681. <xsl:template name="linkdupinfo">
  682. <xsl:if test="(key('linkdup', concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ', @href)))[2]">
  683. <xsl:if test="generate-id(.)=generate-id((key('linkdup', concat(ancestor::*[contains(@class, ' topic/related-links ')]/parent::*[contains(@class, ' topic/topic ')]/@id, ' ', @href)))[1])">
  684. <!-- If the link is exactly the same, do not output message. The duplicate will automatically be removed. -->
  685. <xsl:if test="not(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, normalize-space(string-join(*, ' '))))[2])">
  686. <xsl:apply-templates select="." mode="ditamsg:link-may-be-duplicate"/>
  687. </xsl:if>
  688. </xsl:if>
  689. </xsl:if>
  690. </xsl:template>
  691. <!-- Match an xref or link and add hover help.
  692. Normal treatment: if desc is present and not empty, create hovertext.
  693. Using title (for next/previous links, etc): always create, use title or target. -->
  694. <xsl:template match="*" mode="add-desc-as-hoverhelp">
  695. <xsl:if test="*[contains(@class,' topic/desc ')]">
  696. <xsl:variable name="hovertext">
  697. <xsl:apply-templates select="*[contains(@class,' topic/desc ')][1]" mode="text-only"/>
  698. </xsl:variable>
  699. <xsl:if test="normalize-space($hovertext)!=''">
  700. <xsl:attribute name="title">
  701. <xsl:value-of select="normalize-space($hovertext)"/>
  702. </xsl:attribute>
  703. </xsl:if>
  704. </xsl:if>
  705. </xsl:template>
  706. <xsl:template match="*" mode="add-title-as-hoverhelp">
  707. <!--use link element's linktext as hoverhelp-->
  708. <xsl:attribute name="title">
  709. <xsl:choose>
  710. <xsl:when test="*[contains(@class, ' topic/linktext ')]"><xsl:value-of select="normalize-space(*[contains(@class, ' topic/linktext ')])"/></xsl:when>
  711. <xsl:otherwise><xsl:call-template name="href"/></xsl:otherwise>
  712. </xsl:choose>
  713. </xsl:attribute>
  714. </xsl:template>
  715. <xsl:template match="*" mode="add-hoverhelp-to-child-links">
  716. <!-- By default, desc comes out inline, so no hover help is added.
  717. Can override this template to add hover help to child links. -->
  718. </xsl:template>
  719. <!-- DEPRECATED: use mode template instead -->
  720. <xsl:template name="add-linking-attributes">
  721. <xsl:if test="@href and normalize-space(@href)!=''">
  722. <xsl:attribute name="href">
  723. <xsl:call-template name="href" />
  724. </xsl:attribute>
  725. </xsl:if>
  726. <xsl:call-template name="add-link-target-attribute" />
  727. <xsl:call-template name="add-user-link-attributes" />
  728. </xsl:template>
  729. <!-- this template is dedicated to linking based attributes, and
  730. allows the common linking set to be used when commonattributes
  731. already exists for an ancestor. -->
  732. <xsl:template match="*" mode="add-linking-attributes">
  733. <xsl:apply-templates select="." mode="add-href-attribute"/>
  734. <xsl:apply-templates select="." mode="add-link-target-attribute"/>
  735. <xsl:apply-templates select="." mode="add-custom-link-attributes"/>
  736. </xsl:template>
  737. <xsl:template match="*" mode="add-href-attribute">
  738. <xsl:if test="@href and normalize-space(@href)!=''">
  739. <xsl:attribute name="href">
  740. <xsl:apply-templates select="." mode="determine-final-href"/>
  741. </xsl:attribute>
  742. </xsl:if>
  743. </xsl:template>
  744. <xsl:template name="add-link-target-attribute">
  745. <!-- DEPRECATED: use mode template -->
  746. <xsl:apply-templates select="." mode="add-link-target-attribute"/>
  747. </xsl:template>
  748. <xsl:template match="*" mode="add-link-target-attribute">
  749. <xsl:if test="@scope='external' or @type='external' or ((@format='PDF' or @format='pdf') and not(@scope='local'))">
  750. <xsl:attribute name="target">_blank</xsl:attribute>
  751. </xsl:if>
  752. </xsl:template>
  753. <xsl:template name="add-user-link-attributes">
  754. <!-- stub for user values. DEPRECATED - use mode template instead. -->
  755. <xsl:apply-templates select="." mode="add-custom-link-attributes"/>
  756. </xsl:template>
  757. <xsl:template match="*" mode="ditamsg:unknown-extension">
  758. <xsl:param name="href" select="@href"/>
  759. <xsl:call-template name="output-message">
  760. <xsl:with-param name="id" select="'DOTX006E'"/>
  761. <xsl:with-param name="msgparams">%1=<xsl:value-of select="$href"/></xsl:with-param>
  762. </xsl:call-template>
  763. </xsl:template>
  764. <xsl:template match="*" mode="ditamsg:link-may-be-duplicate">
  765. <xsl:param name="href" select="@href"/>
  766. <xsl:param name="outfile">
  767. <xsl:call-template name="replace-extension">
  768. <xsl:with-param name="filename" select="$FILENAME"/>
  769. <xsl:with-param name="extension" select="$OUTEXT"/>
  770. <xsl:with-param name="ignore-fragment" select="true()"/>
  771. </xsl:call-template>
  772. </xsl:param>
  773. <xsl:call-template name="output-message">
  774. <xsl:with-param name="id" select="'DOTX043I'"/>
  775. <xsl:with-param name="msgparams">%1=<xsl:value-of select="$href"/>;%2=<xsl:value-of select="$outfile"/></xsl:with-param>
  776. </xsl:call-template>
  777. </xsl:template>
  778. </xsl:stylesheet>