rel-links.xsl 49 KB

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