dita2odt-links.xsl 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- This file is part of the DITA Open Toolkit project.
  3. See the accompanying license.txt file for applicable licenses. -->
  4. <!-- (c) Copyright IBM Corp. 2005, 2006 All Rights Reserved. -->
  5. <xsl:stylesheet
  6. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  8. xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  9. xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  10. xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  11. xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  12. xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  13. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"
  14. xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  15. xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
  16. xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  17. xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  18. xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  19. xmlns:math="http://www.w3.org/1998/Math/MathML"
  20. xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  21. xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  22. xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"
  23. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  24. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  25. xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
  26. xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
  27. xmlns:prodtools="http://www.ibm.com/xmlns/prodtools"
  28. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  29. xmlns:opentopic-mapmerge="http://www.idiominc.com/opentopic/mapmerge"
  30. xmlns:opentopic-func="http://www.idiominc.com/opentopic/exsl/function"
  31. exclude-result-prefixes="opentopic-mapmerge opentopic-func dita-ot"
  32. version="2.0">
  33. <xsl:import href="plugin:org.dita.base:xsl/common/output-message.xsl"/>
  34. <xsl:variable name="msgprefix">DOTX</xsl:variable>
  35. <!--
  36. <xsl:include href="../../cfg/fo/attrs/links-attr.xsl"/>
  37. -->
  38. <xsl:param name="chapterLayout" select="''"/>
  39. <xsl:key name="key_anchor" match="*[@id][not(contains(@class,' map/topicref '))]" use="@id"/>
  40. <!--[not(contains(@class,' map/topicref '))]-->
  41. <xsl:template name="insertLinkShortDesc">
  42. <xsl:param name="destination"/>
  43. <xsl:param name="element"/>
  44. <xsl:param name="linkScope"/>
  45. <xsl:choose>
  46. <!-- User specified description (from map or topic): use that. -->
  47. <xsl:when test="*[contains(@class,' topic/desc ')] and processing-instruction()[name()='ditaot'][.='usershortdesc']">
  48. <text:p text:style-name="Default_20_Text">
  49. <xsl:apply-templates select="*[contains(@class, ' topic/desc ')]"/>
  50. </text:p>
  51. </xsl:when>
  52. <!-- External: do not attempt to retrieve. -->
  53. <xsl:when test="$linkScope='external'">
  54. </xsl:when>
  55. <!-- When the target has a short description and no local override, use the target -->
  56. <xsl:when test="$element/*[contains(@class, ' topic/shortdesc ')]">
  57. <text:line-break/>
  58. <text:tab/>
  59. <xsl:apply-templates select="$element/*[contains(@class, ' topic/shortdesc ')]" mode="dita-ot:text-only"/>
  60. </xsl:when>
  61. </xsl:choose>
  62. </xsl:template>
  63. <xsl:template name="insertLinkDesc">
  64. <text:line-break>
  65. <text:tab>
  66. <xsl:apply-templates select="*[contains(@class,' topic/desc ')]" mode="insert-description"/>
  67. </text:tab>
  68. </text:line-break>
  69. </xsl:template>
  70. <xsl:template match="*[contains(@class,' topic/xref ') or contains(@class, ' topic/link ')]/*[contains(@class,' topic/desc ')]" priority="1"/>
  71. <xsl:template match="*[contains(@class,' topic/desc ')]" mode="insert-description">
  72. <xsl:apply-templates/>
  73. </xsl:template>
  74. <!-- The insertReferenceTitle template is called from <xref> and <link> and is
  75. used to build link contents (using full FO syntax, not just the text). -->
  76. <xsl:template name="insertReferenceTitle">
  77. <xsl:param name="href"/>
  78. <xsl:param name="titlePrefix"/>
  79. <xsl:param name="destination"/>
  80. <xsl:param name="element"/>
  81. <xsl:apply-templates select="." mode="insertReferenceTitle">
  82. <xsl:with-param name="href" select="$href"/>
  83. <xsl:with-param name="titlePrefix" select="$titlePrefix"/>
  84. <xsl:with-param name="destination" select="$destination"/>
  85. <xsl:with-param name="element" select="$element"/>
  86. </xsl:apply-templates>
  87. </xsl:template>
  88. <!-- Process any cross reference or link with author-specified text.
  89. The specified text is used as the link text. Added by RDA for
  90. SourceForge bug 1880097. -->
  91. <xsl:template match="*[processing-instruction()[name()='ditaot'][.='usertext']]" mode="insertReferenceTitle">
  92. <xsl:apply-templates select="*[not(contains(@class,' topic/desc '))]|text()"/>
  93. </xsl:template>
  94. <!-- Process any cross reference or link with no content, or with content
  95. generated by the DITA-OT preprocess. The title will be retrieved from
  96. the target element, and combined with generated text such as Figure N. -->
  97. <xsl:template match="*" mode="insertReferenceTitle">
  98. <xsl:param name="href"/>
  99. <xsl:param name="titlePrefix"/>
  100. <xsl:param name="destination"/>
  101. <xsl:param name="element"/>
  102. <xsl:variable name="referenceContent">
  103. <xsl:choose>
  104. <xsl:when test="not($element) or ($destination = '')">
  105. <xsl:text>#none#</xsl:text>
  106. </xsl:when>
  107. <xsl:when test="contains($element/@class,' topic/li ') and contains($element/parent::*/@class,' topic/ol ')">
  108. <!-- SF Bug 1839827: This causes preprocessor text to be used for links to OL/LI -->
  109. <xsl:text>#none#</xsl:text>
  110. </xsl:when>
  111. <xsl:otherwise>
  112. <xsl:apply-templates select="$element" mode="retrieveReferenceTitle"/>
  113. </xsl:otherwise>
  114. </xsl:choose>
  115. </xsl:variable>
  116. <xsl:if test="not($titlePrefix = '')">
  117. <!--
  118. <xsl:call-template name="getVariable">
  119. <xsl:with-param name="id" select="$titlePrefix"/>
  120. </xsl:call-template>
  121. -->
  122. </xsl:if>
  123. <xsl:choose>
  124. <xsl:when test="not($element) or ($destination = '') or $referenceContent='#none#'">
  125. <xsl:choose>
  126. <xsl:when test="*[not(contains(@class,' topic/desc '))] | text()">
  127. <xsl:apply-templates select="*[not(contains(@class,' topic/desc '))] | text()"/>
  128. </xsl:when>
  129. <xsl:otherwise>
  130. <xsl:value-of select="$href"/>
  131. </xsl:otherwise>
  132. </xsl:choose>
  133. </xsl:when>
  134. <xsl:otherwise>
  135. <xsl:copy-of select="$referenceContent"/>
  136. </xsl:otherwise>
  137. </xsl:choose>
  138. </xsl:template>
  139. <xsl:template match="*[contains(@class, ' topic/fig ')][*[contains(@class, ' topic/title ')]]" mode="retrieveReferenceTitle">
  140. <!--
  141. <xsl:call-template name="getVariable">
  142. <xsl:with-param name="id" select="'Figure'"/>
  143. <xsl:with-param name="params">
  144. <text:span>
  145. <xsl:value-of select="count(preceding::*[contains(@class, ' topic/fig ')][child::*[contains(@class, ' topic/title ')]]) + 1"/>
  146. </text:span>
  147. <text:h>
  148. <xsl:apply-templates select="*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  149. </text:h>
  150. </xsl:with-param>
  151. </xsl:call-template>
  152. -->
  153. <text:span>
  154. <xsl:value-of select="count(preceding::*[contains(@class, ' topic/fig ')][child::*[contains(@class, ' topic/title ')]]) + 1"/>
  155. </text:span>
  156. <text:h>
  157. <xsl:apply-templates select="*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  158. </text:h>
  159. </xsl:template>
  160. <xsl:template match="*[contains(@class, ' topic/section ')][*[contains(@class, ' topic/title ')]]" mode="retrieveReferenceTitle">
  161. <xsl:variable name="title">
  162. <xsl:apply-templates select="*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  163. </xsl:variable>
  164. <xsl:value-of select="normalize-space($title)"/>
  165. </xsl:template>
  166. <xsl:template match="*[contains(@class, ' topic/table ')][*[contains(@class, ' topic/title ')]]" mode="retrieveReferenceTitle">
  167. <!--
  168. <xsl:call-template name="getVariable">
  169. <xsl:with-param name="id" select="'Table'"/>
  170. <xsl:with-param name="params">
  171. <text:span>
  172. <xsl:value-of select="count(preceding::*[contains(@class, ' topic/table ')][child::*[contains(@class, ' topic/title ')]]) + 1"/>
  173. </text:span>
  174. <text:h>
  175. <xsl:apply-templates select="*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  176. </text:h>
  177. </xsl:with-param>
  178. </xsl:call-template>
  179. -->
  180. <text:span>
  181. <xsl:value-of select="count(preceding::*[contains(@class, ' topic/table ')][child::*[contains(@class, ' topic/title ')]]) + 1"/>
  182. </text:span>
  183. <text:h>
  184. <xsl:apply-templates select="*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  185. </text:h>
  186. </xsl:template>
  187. <xsl:template match="*[contains(@class, ' topic/li ')]" mode="retrieveReferenceTitle">
  188. <!--
  189. <xsl:call-template name="getVariable">
  190. <xsl:with-param name="id" select="'List item'"/>
  191. </xsl:call-template>
  192. -->
  193. <text:p text:style-name="Default_20_Text">
  194. <text:span text:style-name="bold">
  195. <xsl:call-template name="getVariable">
  196. <xsl:with-param name="id" select="'List item'"/>
  197. </xsl:call-template>
  198. </text:span>
  199. </text:p>
  200. </xsl:template>
  201. <xsl:template match="*[contains(@class, ' topic/fn ')]" mode="retrieveReferenceTitle">
  202. <!--
  203. <xsl:call-template name="getVariable">
  204. <xsl:with-param name="id" select="'Foot note'"/>
  205. </xsl:call-template>
  206. -->
  207. <text:p text:style-name="Default_20_Text">
  208. <text:span text:style-name="bold">
  209. <xsl:call-template name="getVariable">
  210. <xsl:with-param name="id" select="'Foot note'"/>
  211. </xsl:call-template>
  212. </text:span>
  213. </text:p>
  214. </xsl:template>
  215. <!-- Default rule: if element has a title, use that, otherwise return '#none#' -->
  216. <xsl:template match="*" mode="retrieveReferenceTitle">
  217. <xsl:choose>
  218. <xsl:when test="*[contains(@class,' topic/title ')]">
  219. <xsl:value-of select="string(*[contains(@class, ' topic/title ')])"/>
  220. </xsl:when>
  221. <xsl:otherwise>
  222. <xsl:text>#none#</xsl:text>
  223. </xsl:otherwise>
  224. </xsl:choose>
  225. </xsl:template>
  226. <xsl:template match="*[contains(@class,' topic/xref ')]">
  227. <xsl:variable name="destination" select="opentopic-func:getDestinationId(@href)"/>
  228. <xsl:variable name="element" select="key('key_anchor',$destination)[1]"/>
  229. <xsl:variable name="referenceTitle">
  230. <xsl:call-template name="insertReferenceTitle">
  231. <xsl:with-param name="href" select="@href"/>
  232. <xsl:with-param name="titlePrefix" select="''"/>
  233. <xsl:with-param name="destination" select="$destination"/>
  234. <xsl:with-param name="element" select="$element"/>
  235. </xsl:call-template>
  236. </xsl:variable>
  237. <xsl:if test="parent::*[contains(@class,' topic/li ')]">
  238. <xsl:text disable-output-escaping="yes">&lt;text:p&gt;</xsl:text>
  239. </xsl:if>
  240. <text:a>
  241. <xsl:call-template name="buildBasicLinkDestination">
  242. <xsl:with-param name="scope" select="@scope"/>
  243. <xsl:with-param name="href" select="@href"/>
  244. </xsl:call-template>
  245. <xsl:choose>
  246. <xsl:when test="not(@scope = 'external') and not($referenceTitle = '')">
  247. <xsl:copy-of select="$referenceTitle"/>
  248. </xsl:when>
  249. <xsl:when test="not(@scope = 'external')">
  250. <xsl:call-template name="insertPageNumberCitation">
  251. <xsl:with-param name="isTitleEmpty" select="'yes'"/>
  252. <xsl:with-param name="destination" select="$destination"/>
  253. <xsl:with-param name="element" select="$element"/>
  254. </xsl:call-template>
  255. </xsl:when>
  256. <xsl:otherwise>
  257. <xsl:choose>
  258. <xsl:when test="*[not(contains(@class,' topic/desc '))] | text()">
  259. <xsl:apply-templates select="*[not(contains(@class,' topic/desc '))] | text()"/>
  260. </xsl:when>
  261. <xsl:otherwise>
  262. <xsl:value-of select="@href"/>
  263. </xsl:otherwise>
  264. </xsl:choose>
  265. </xsl:otherwise>
  266. </xsl:choose>
  267. </text:a>
  268. <!--
  269. Disable because of the CQ#8102 bug
  270. <xsl:if test="*[contains(@class,' topic/desc ')]">
  271. <xsl:call-template name="insertLinkDesc"/>
  272. </xsl:if>
  273. -->
  274. <xsl:if test="not(@scope = 'external') and not($referenceTitle = '') and not($element[contains(@class, ' topic/fn ')])">
  275. <!-- SourceForge bug 1880097: should not include page number when xref includes author specified text -->
  276. <xsl:if test="not(processing-instruction()[name()='ditaot'][.='usertext'])">
  277. <xsl:call-template name="insertPageNumberCitation">
  278. <xsl:with-param name="destination" select="$destination"/>
  279. <xsl:with-param name="element" select="$element"/>
  280. </xsl:call-template>
  281. </xsl:if>
  282. </xsl:if>
  283. <xsl:if test="parent::*[contains(@class,' topic/li ')]">
  284. <xsl:text disable-output-escaping="yes">&lt;/text:p&gt;</xsl:text>
  285. </xsl:if>
  286. </xsl:template>
  287. <!-- xref to footnote makes a callout. -->
  288. <xsl:template match="*[contains(@class,' topic/xref ')][@type='fn']" priority="2">
  289. <xsl:variable name="href-fragment" select="substring-after(@href, '#')"/>
  290. <xsl:variable name="footnote-target" select="//*[contains(@class, ' topic/fn ')][@id = substring-after($href-fragment, '/')][ancestor::*[contains(@class, ' topic/topic ')][1]/@id = substring-before($href-fragment, '/')]"/>
  291. <xsl:apply-templates select="$footnote-target" mode="footnote-callout"/>
  292. </xsl:template>
  293. <xsl:template match="*[contains(@class, ' topic/fn ')]" mode="footnote-callout">
  294. <text:tab/>
  295. <xsl:choose>
  296. <xsl:when test="@callout">
  297. <xsl:value-of select="@callout"/>
  298. </xsl:when>
  299. <xsl:otherwise>
  300. <xsl:number level="any" count="*[contains(@class,' topic/fn ') and not(@callout)]"/>
  301. </xsl:otherwise>
  302. </xsl:choose>
  303. </xsl:template>
  304. <xsl:template match="*[contains(@class,' topic/related-links ')]">
  305. <xsl:if test="normalize-space($includeRelatedLinkRoles)">
  306. <xsl:variable name="topicType">
  307. <xsl:for-each select="parent::*">
  308. <xsl:call-template name="determineTopicType"/>
  309. </xsl:for-each>
  310. </xsl:variable>
  311. <xsl:variable name="collectedLinks">
  312. <xsl:apply-templates mode="processLink">
  313. <xsl:with-param name="topicType" select="$topicType"/>
  314. </xsl:apply-templates>
  315. </xsl:variable>
  316. <xsl:variable name="linkTextContent" select="$collectedLinks"/>
  317. <xsl:if test="normalize-space($linkTextContent)!=''">
  318. <text:p text:style-name="Default_20_Text">
  319. <!--
  320. <xsl:call-template name="getVariable">
  321. <xsl:with-param name="id" select="'Related Links'"/>
  322. </xsl:call-template>
  323. -->
  324. <text:span text:style-name="bold">
  325. <xsl:call-template name="getVariable">
  326. <xsl:with-param name="id" select="'Related Links'"/>
  327. </xsl:call-template>
  328. </text:span>
  329. <!--
  330. <text:line-break/>
  331. <text:tab/>
  332. -->
  333. <!--
  334. <xsl:copy-of select="$collectedLinks"/>
  335. -->
  336. <!--
  337. <xsl:value-of select="$collectedLinks" disable-output-escaping="yes"/>
  338. -->
  339. <xsl:apply-templates mode="processLink">
  340. <xsl:with-param name="topicType" select="$topicType"/>
  341. </xsl:apply-templates>
  342. </text:p>
  343. </xsl:if>
  344. </xsl:if>
  345. </xsl:template>
  346. <xsl:template name="getLinkScope">
  347. <xsl:choose>
  348. <xsl:when test="@scope">
  349. <xsl:value-of select="@scope"/>
  350. </xsl:when>
  351. <xsl:when test="contains(@class, ' topic/related-links ')">
  352. <xsl:value-of select="'local'"/>
  353. </xsl:when>
  354. <xsl:otherwise>
  355. <xsl:for-each select="..">
  356. <xsl:call-template name="getLinkScope"/>
  357. </xsl:for-each>
  358. </xsl:otherwise>
  359. </xsl:choose>
  360. </xsl:template>
  361. <!-- 20100323: Update to be aware of new includeRelatedLinks parameter.
  362. Move main processing of link into a mode template; this allows customized
  363. code to easily match links without the need to copy processing logic. -->
  364. <xsl:template match="*[contains(@class,' topic/link ')]" mode="processLink">
  365. <xsl:param name="topicType">
  366. <xsl:for-each select="ancestor::*[contains(@class,' topic/topic ')][1]">
  367. <xsl:call-template name="determineTopicType"/>
  368. </xsl:for-each>
  369. </xsl:param>
  370. <xsl:choose>
  371. <xsl:when test="(@role and not(contains($includeRelatedLinkRoles, concat(' ', @role, ' ')))) or (not(@role) and not(contains($includeRelatedLinkRoles, ' #default ')))"/>
  372. <xsl:when test="@role='child' and $chapterLayout='MINITOC' and ($topicType='topicChapter' or $topicType='topicAppendix' or $topicType='topicPart')">
  373. <!-- When a minitoc already links to children, do not add them here -->
  374. </xsl:when>
  375. <xsl:otherwise>
  376. <xsl:apply-templates select="." mode="processLinks"/>
  377. </xsl:otherwise>
  378. </xsl:choose>
  379. </xsl:template>
  380. <xsl:template match="*[contains(@class,' topic/link ')]" mode="processLinks">
  381. <xsl:variable name="destination" select="opentopic-func:getDestinationId(@href)"/>
  382. <xsl:variable name="element" select="key('key_anchor',$destination)[1]"/>
  383. <xsl:variable name="referenceTitle">
  384. <xsl:call-template name="insertReferenceTitle">
  385. <xsl:with-param name="href" select="@href"/>
  386. <xsl:with-param name="titlePrefix" select="''"/>
  387. <xsl:with-param name="destination" select="$destination"/>
  388. <xsl:with-param name="element" select="$element"/>
  389. </xsl:call-template>
  390. </xsl:variable>
  391. <xsl:variable name="linkScope">
  392. <xsl:call-template name="getLinkScope"/>
  393. </xsl:variable>
  394. <!--<xsl:text>&#x2022; </xsl:text>-->
  395. <text:line-break/>
  396. <text:tab/>
  397. <text:a>
  398. <xsl:call-template name="buildBasicLinkDestination">
  399. <xsl:with-param name="scope" select="$linkScope"/>
  400. <xsl:with-param name="href" select="@href"/>
  401. </xsl:call-template>
  402. <xsl:choose>
  403. <xsl:when test="not($linkScope = 'external') and not($referenceTitle = '')">
  404. <xsl:copy-of select="$referenceTitle"/>
  405. </xsl:when>
  406. <xsl:when test="not($linkScope = 'external')">
  407. <xsl:call-template name="insertPageNumberCitation">
  408. <xsl:with-param name="isTitleEmpty" select="'yes'"/>
  409. <xsl:with-param name="destination" select="$destination"/>
  410. <xsl:with-param name="element" select="$element"/>
  411. </xsl:call-template>
  412. </xsl:when>
  413. <xsl:otherwise>
  414. <xsl:apply-templates/>
  415. </xsl:otherwise>
  416. </xsl:choose>
  417. </text:a>
  418. <xsl:if test="not($linkScope = 'external') and not($referenceTitle = '')">
  419. <xsl:call-template name="insertPageNumberCitation">
  420. <xsl:with-param name="destination" select="$destination"/>
  421. <xsl:with-param name="element" select="$element"/>
  422. </xsl:call-template>
  423. </xsl:if>
  424. <!--
  425. Disable because of the CQ#8102 bug
  426. <xsl:if test="*[contains(@class, ' topic/desc ')]">
  427. <xsl:call-template name="insertLinkDesc"/>
  428. </xsl:if>
  429. -->
  430. <!-- Previously: skip if linkSope = external. New processing: pass
  431. linkscope to the template, let the template decide. -->
  432. <!--<xsl:if test="not($linkScope = 'external')">-->
  433. <xsl:call-template name="insertLinkShortDesc">
  434. <xsl:with-param name="destination" select="$destination"/>
  435. <xsl:with-param name="element" select="$element"/>
  436. <xsl:with-param name="linkScope" select="$linkScope"/>
  437. </xsl:call-template>
  438. <!--</xsl:if>-->
  439. </xsl:template>
  440. <xsl:template name="buildBasicLinkDestination">
  441. <xsl:param name="scope"/>
  442. <xsl:param name="href"/>
  443. <xsl:choose>
  444. <xsl:when test="(contains(@href, '://') and not(starts-with(@href, 'file://'))) or starts-with(@href, '/') or $scope = 'external'">
  445. <xsl:attribute name="xlink:href">
  446. <xsl:value-of select="$href"/>
  447. </xsl:attribute>
  448. </xsl:when>
  449. <xsl:when test="$scope = 'peer'">
  450. <xsl:attribute name="xlink:href">
  451. <xsl:value-of select="$href"/>
  452. </xsl:attribute>
  453. </xsl:when>
  454. <xsl:when test="contains($href, '#')">
  455. <xsl:attribute name="xlink:href">
  456. <xsl:value-of select="$href"/>
  457. </xsl:attribute>
  458. </xsl:when>
  459. <xsl:otherwise>
  460. <xsl:attribute name="xlink:href">
  461. <xsl:value-of select="$href"/>
  462. </xsl:attribute>
  463. <xsl:call-template name="brokenLinks">
  464. <xsl:with-param name="href" select="$href"/>
  465. </xsl:call-template>
  466. </xsl:otherwise>
  467. <!--xsl:otherwise>
  468. <xsl:attribute name="internal-destination">
  469. <xsl:value-of select="opentopic-func:getDestinationId($href)"/>
  470. </xsl:attribute>
  471. </xsl:otherwise-->
  472. </xsl:choose>
  473. </xsl:template>
  474. <xsl:template name="insertPageNumberCitation">
  475. <xsl:param name="isTitleEmpty"/>
  476. <xsl:param name="destination"/>
  477. <xsl:param name="element"/>
  478. <xsl:choose>
  479. <xsl:when test="not($element) or ($destination = '')"/>
  480. <xsl:when test="$isTitleEmpty">
  481. <!--
  482. <xsl:call-template name="getVariable">
  483. <xsl:with-param name="id" select="'Page'"/>
  484. <xsl:with-param name="params">
  485. <pagenum>
  486. <fo:inline>
  487. <fo:page-number-citation ref-id="{$destination}"/>
  488. </fo:inline>
  489. </pagenum>
  490. </xsl:with-param>
  491. </xsl:call-template>
  492. -->
  493. <text:s/>
  494. <xsl:call-template name="getVariable">
  495. <xsl:with-param name="id" select="'Page'"/>
  496. </xsl:call-template>
  497. <text:s/>
  498. <text:bookmark-ref text:reference-format="page" text:ref-name="{$destination}">
  499. </text:bookmark-ref>
  500. </xsl:when>
  501. <xsl:otherwise>
  502. <!--
  503. <xsl:call-template name="getVariable">
  504. <xsl:with-param name="id" select="'On the page'"/>
  505. <xsl:with-param name="params">
  506. <xsl:element name="text:bookmark-ref">
  507. <xsl:attribute name="text:reference-format">page</xsl:attribute>
  508. <xsl:attribute name="text:ref-name"><xsl:value-of select="$destination"/></xsl:attribute>
  509. </xsl:element>
  510. </xsl:with-param>
  511. </xsl:call-template>
  512. -->
  513. <text:s/>
  514. <xsl:call-template name="getVariable">
  515. <xsl:with-param name="id" select="'On the page'"/>
  516. </xsl:call-template>
  517. <text:s/>
  518. <text:bookmark-ref text:reference-format="page" text:ref-name="{$destination}">
  519. </text:bookmark-ref>
  520. </xsl:otherwise>
  521. </xsl:choose>
  522. </xsl:template>
  523. <xsl:template match="*[contains(@class,' topic/linktext ')]" mode="processLink">
  524. <xsl:value-of select="*[contains(@class,' topic/linktext ')]"/>
  525. </xsl:template>
  526. <xsl:template match="*[contains(@class, ' topic/linklist ')]" mode="processLink">
  527. <text:line-break/>
  528. <xsl:apply-templates mode="processLink"/>
  529. </xsl:template>
  530. <xsl:template match="*[contains(@class,' topic/linkinfo ')]" mode="processLink">
  531. <text:line-break/>
  532. <xsl:apply-templates/>
  533. </xsl:template>
  534. <xsl:template match="*[contains(@class,' topic/linkpool ')]" mode="processLink">
  535. <xsl:param name="topicType"/>
  536. <xsl:apply-templates mode="processLink">
  537. <xsl:with-param name="topicType" select="$topicType"/>
  538. </xsl:apply-templates>
  539. </xsl:template>
  540. <xsl:function name="opentopic-func:getDestinationId">
  541. <xsl:param name="href"/>
  542. <xsl:call-template name="getDestinationIdImpl">
  543. <xsl:with-param name="href" select="$href"/>
  544. </xsl:call-template>
  545. </xsl:function>
  546. <xsl:template name="getDestinationIdImpl">
  547. <xsl:param name="href"/>
  548. <xsl:variable name="topic-id" select="substring-after($href, '#')"/>
  549. <xsl:variable name="element-id" select="substring-after($topic-id, '/')"/>
  550. <xsl:choose>
  551. <xsl:when test="$element-id = ''">
  552. <xsl:value-of select="$topic-id"/>
  553. </xsl:when>
  554. <xsl:otherwise>
  555. <xsl:value-of select="$element-id"/>
  556. </xsl:otherwise>
  557. </xsl:choose>
  558. </xsl:template>
  559. <!--Related links-->
  560. <xsl:template name="buildRelationships">
  561. <xsl:apply-templates select="." mode="buildRelationships"/>
  562. </xsl:template>
  563. <xsl:template match="*" mode="buildRelationships">
  564. <!--
  565. <xsl:param name="context" select="."/>
  566. <xsl:for-each select=".">
  567. </xsl:for-each>
  568. -->
  569. <xsl:if test="normalize-space($includeRelatedLinkRoles)">
  570. <xsl:variable name="parentCollectionType">
  571. <xsl:call-template name="getCollectionType">
  572. <xsl:with-param name="nodeType" select="'parent'"/>
  573. </xsl:call-template>
  574. </xsl:variable>
  575. <xsl:variable name="selfCollectionType">
  576. <xsl:call-template name="getCollectionType">
  577. <xsl:with-param name="nodeType" select="'self'"/>
  578. </xsl:call-template>
  579. </xsl:variable>
  580. <xsl:variable name="relatedConceptsTitle">
  581. <!--
  582. <xsl:call-template name="getVariable">
  583. <xsl:with-param name="id" select="'Related concepts'"/>
  584. </xsl:call-template>
  585. -->
  586. <text:p text:style-name="Default_20_Text">
  587. <text:span text:style-name="bold">
  588. <xsl:call-template name="getVariable">
  589. <xsl:with-param name="id" select="'Related concepts'"/>
  590. </xsl:call-template>
  591. </text:span>
  592. </text:p>
  593. </xsl:variable>
  594. <xsl:variable name="relatedTasksTitle">
  595. <!--
  596. <xsl:call-template name="getVariable">
  597. <xsl:with-param name="id" select="'Related tasks'"/>
  598. </xsl:call-template>
  599. -->
  600. <text:p text:style-name="Default_20_Text">
  601. <text:span text:style-name="bold">
  602. <xsl:call-template name="getVariable">
  603. <xsl:with-param name="id" select="'Related tasks'"/>
  604. </xsl:call-template>
  605. </text:span>
  606. </text:p>
  607. </xsl:variable>
  608. <xsl:variable name="relatedReferencesTitle">
  609. <!--
  610. <xsl:call-template name="getVariable">
  611. <xsl:with-param name="id" select="'Related references'"/>
  612. </xsl:call-template>
  613. -->
  614. <text:p text:style-name="Default_20_Text">
  615. <text:span text:style-name="bold">
  616. <xsl:call-template name="getVariable">
  617. <xsl:with-param name="id" select="'Related references'"/>
  618. </xsl:call-template>
  619. </text:span>
  620. </text:p>
  621. </xsl:variable>
  622. <xsl:variable name="relatedInformationTitle">
  623. <!--
  624. <xsl:call-template name="getVariable">
  625. <xsl:with-param name="id" select="'Related information'"/>
  626. </xsl:call-template>
  627. -->
  628. <text:p text:style-name="Default_20_Text">
  629. <text:span text:style-name="bold">
  630. <xsl:call-template name="getVariable">
  631. <xsl:with-param name="id" select="'Related information'"/>
  632. </xsl:call-template>
  633. </text:span>
  634. </text:p>
  635. </xsl:variable>
  636. <xsl:choose>
  637. <xsl:when test="$selfCollectionType = 'none'">
  638. <xsl:call-template name="linkToChilds">
  639. <xsl:with-param name="listType" select="'none'"/>
  640. </xsl:call-template>
  641. </xsl:when>
  642. <xsl:when test="($selfCollectionType = 'unordered') or ($selfCollectionType = 'choice') or ($selfCollectionType = 'family')">
  643. <xsl:call-template name="linkToChilds">
  644. <xsl:with-param name="listType" select="'bulleted'"/>
  645. </xsl:call-template>
  646. </xsl:when>
  647. <xsl:when test="$selfCollectionType = 'sequence'">
  648. <xsl:call-template name="linkToChilds">
  649. <xsl:with-param name="listType" select="'numbered'"/>
  650. </xsl:call-template>
  651. </xsl:when>
  652. </xsl:choose>
  653. <xsl:choose>
  654. <xsl:when test="($parentCollectionType = 'none') or ($parentCollectionType = 'unordered') or ($parentCollectionType = 'choice')">
  655. <xsl:call-template name="linkToParent"/>
  656. <!-- Creating relationships to the concepts -->
  657. <xsl:call-template name="createRelatedLinks">
  658. <xsl:with-param name="linkType" select="'concept'"/>
  659. <xsl:with-param name="title" select="$relatedConceptsTitle"/>
  660. </xsl:call-template>
  661. <!-- Creating relationships to the tasks -->
  662. <xsl:call-template name="createRelatedLinks">
  663. <xsl:with-param name="linkType" select="'task'"/>
  664. <xsl:with-param name="title" select="$relatedTasksTitle"/>
  665. </xsl:call-template>
  666. <!-- Creating relationships to the references -->
  667. <xsl:call-template name="createRelatedLinks">
  668. <xsl:with-param name="linkType" select="'reference'"/>
  669. <xsl:with-param name="title" select="$relatedReferencesTitle"/>
  670. </xsl:call-template>
  671. <!-- Creating relationships to the topics -->
  672. <xsl:call-template name="createRelatedLinks">
  673. <xsl:with-param name="linkType" select="'topic'"/>
  674. <xsl:with-param name="title" select="$relatedInformationTitle"/>
  675. </xsl:call-template>
  676. </xsl:when>
  677. <xsl:when test="$parentCollectionType = 'sequence'">
  678. <xsl:call-template name="linkToParent"/>
  679. <xsl:call-template name="linkToPrevious"/>
  680. <xsl:call-template name="linkToNext"/>
  681. <!-- Creating relationships to the concepts -->
  682. <xsl:call-template name="createRelatedLinks">
  683. <xsl:with-param name="linkType" select="'concept'"/>
  684. <xsl:with-param name="title" select="$relatedConceptsTitle"/>
  685. </xsl:call-template>
  686. <!-- Creating relationships to the tasks -->
  687. <xsl:call-template name="createRelatedLinks">
  688. <xsl:with-param name="linkType" select="'task'"/>
  689. <xsl:with-param name="title" select="$relatedTasksTitle"/>
  690. </xsl:call-template>
  691. <!-- Creating relationships to the references -->
  692. <xsl:call-template name="createRelatedLinks">
  693. <xsl:with-param name="linkType" select="'reference'"/>
  694. <xsl:with-param name="title" select="$relatedReferencesTitle"/>
  695. </xsl:call-template>
  696. <!-- Creating relationships to the topics -->
  697. <xsl:call-template name="createRelatedLinks">
  698. <xsl:with-param name="linkType" select="'topic'"/>
  699. <xsl:with-param name="title" select="$relatedInformationTitle"/>
  700. </xsl:call-template>
  701. </xsl:when>
  702. <xsl:when test="$parentCollectionType = 'family'">
  703. <xsl:call-template name="linkToParent"/>
  704. <!-- Creating relationships to the concepts -->
  705. <xsl:variable name="siblingConcepts" select="preceding-sibling::*[contains(@class, ' concept/concept ') and not(contains(@class, ' bkinfo/bkinfo '))] | following-sibling::*[contains(@class, ' concept/concept ') and not(contains(@class, ' bkinfo/bkinfo '))]"/>
  706. <xsl:call-template name="createMapLinks">
  707. <xsl:with-param name="nodeSet" select="$siblingConcepts"/>
  708. <xsl:with-param name="title" select="$relatedConceptsTitle"/>
  709. </xsl:call-template>
  710. <xsl:choose>
  711. <xsl:when test="$siblingConcepts">
  712. <xsl:call-template name="createRelatedLinks">
  713. <xsl:with-param name="linkType" select="'concept'"/>
  714. </xsl:call-template>
  715. </xsl:when>
  716. <xsl:otherwise>
  717. <xsl:call-template name="createRelatedLinks">
  718. <xsl:with-param name="linkType" select="'concept'"/>
  719. <xsl:with-param name="title" select="$relatedConceptsTitle"/>
  720. </xsl:call-template>
  721. </xsl:otherwise>
  722. </xsl:choose>
  723. <!-- Creating relationships to the tasks -->
  724. <xsl:variable name="siblingTasks" select="preceding-sibling::*[contains(@class, ' task/task ') and not(contains(@class, ' bkinfo/bkinfo '))] | following-sibling::*[contains(@class, ' task/task ') and not(contains(@class, ' bkinfo/bkinfo '))]"/>
  725. <xsl:call-template name="createMapLinks">
  726. <xsl:with-param name="nodeSet" select="$siblingTasks"/>
  727. <xsl:with-param name="title" select="$relatedTasksTitle"/>
  728. </xsl:call-template>
  729. <xsl:choose>
  730. <xsl:when test="$siblingTasks">
  731. <xsl:call-template name="createRelatedLinks">
  732. <xsl:with-param name="linkType" select="'task'"/>
  733. </xsl:call-template>
  734. </xsl:when>
  735. <xsl:otherwise>
  736. <xsl:call-template name="createRelatedLinks">
  737. <xsl:with-param name="linkType" select="'task'"/>
  738. <xsl:with-param name="title" select="$relatedTasksTitle"/>
  739. </xsl:call-template>
  740. </xsl:otherwise>
  741. </xsl:choose>
  742. <!-- Creating relationships to the references -->
  743. <xsl:variable name="siblingReferences" select="preceding-sibling::*[contains(@class, ' reference/reference ') and not(contains(@class, ' bkinfo/bkinfo '))] | following-sibling::*[contains(@class, ' reference/reference ') and not(contains(@class, ' bkinfo/bkinfo '))]"/>
  744. <xsl:call-template name="createMapLinks">
  745. <xsl:with-param name="nodeSet" select="$siblingReferences"/>
  746. <xsl:with-param name="title" select="$relatedReferencesTitle"/>
  747. </xsl:call-template>
  748. <xsl:choose>
  749. <xsl:when test="$siblingReferences">
  750. <xsl:call-template name="createRelatedLinks">
  751. <xsl:with-param name="linkType" select="'reference'"/>
  752. </xsl:call-template>
  753. </xsl:when>
  754. <xsl:otherwise>
  755. <xsl:call-template name="createRelatedLinks">
  756. <xsl:with-param name="linkType" select="'reference'"/>
  757. <xsl:with-param name="title" select="$relatedReferencesTitle"/>
  758. </xsl:call-template>
  759. </xsl:otherwise>
  760. </xsl:choose>
  761. <!-- Creating relationships to the topics -->
  762. <xsl:variable name="siblingTopics" select="preceding-sibling::*[contains(@class, ' topic/topic ') and not(contains(@class, ' bkinfo/bkinfo ') or contains(@class, ' concept/concept ') or contains(@class, ' task/task ') or contains(@class, ' reference/reference '))] | following-sibling::*[contains(@class, ' topic/topic ') and not(contains(@class, ' bkinfo/bkinfo ') or contains(@class, ' concept/concept ') or contains(@class, ' task/task ') or contains(@class, ' reference/reference '))]"/>
  763. <xsl:call-template name="createMapLinks">
  764. <xsl:with-param name="nodeSet" select="$siblingTopics"/>
  765. <xsl:with-param name="title" select="$relatedInformationTitle"/>
  766. </xsl:call-template>
  767. <xsl:choose>
  768. <xsl:when test="$siblingTopics">
  769. <xsl:call-template name="createRelatedLinks">
  770. <xsl:with-param name="linkType" select="'topic'"/>
  771. </xsl:call-template>
  772. </xsl:when>
  773. <xsl:otherwise>
  774. <xsl:call-template name="createRelatedLinks">
  775. <xsl:with-param name="linkType" select="'topic'"/>
  776. <xsl:with-param name="title" select="$relatedInformationTitle"/>
  777. </xsl:call-template>
  778. </xsl:otherwise>
  779. </xsl:choose>
  780. </xsl:when>
  781. </xsl:choose>
  782. </xsl:if>
  783. </xsl:template>
  784. <xsl:template name="getCollectionType">
  785. <xsl:param name="nodeType"/>
  786. <xsl:variable name="collectionType">
  787. <xsl:choose>
  788. <xsl:when test="$nodeType = 'parent'">
  789. <xsl:value-of select="parent::*/@collection-type"/>
  790. </xsl:when>
  791. <xsl:when test="$nodeType = 'self'">
  792. <xsl:value-of select="@collection-type"/>
  793. </xsl:when>
  794. </xsl:choose>
  795. </xsl:variable>
  796. <xsl:choose>
  797. <xsl:when test="$collectionType = 'unordered'">
  798. <xsl:value-of select="'none'"/>
  799. </xsl:when>
  800. <xsl:when test="$collectionType">
  801. <xsl:value-of select="$collectionType"/>
  802. </xsl:when>
  803. <xsl:otherwise>
  804. <xsl:value-of select="'none'"/>
  805. </xsl:otherwise>
  806. </xsl:choose>
  807. </xsl:template>
  808. <xsl:template name="linkToParent">
  809. <!-- Creating relationships to the parent -->
  810. <xsl:variable name="linksTitle">
  811. <!--
  812. <xsl:call-template name="getVariable">
  813. <xsl:with-param name="id" select="'Parent topic'"/>
  814. </xsl:call-template>
  815. -->
  816. <text:p text:style-name="Default_20_Text">
  817. <text:span text:style-name="bold">
  818. <xsl:call-template name="getVariable">
  819. <xsl:with-param name="id" select="'Parent topic'"/>
  820. </xsl:call-template>
  821. </text:span>
  822. </text:p>
  823. </xsl:variable>
  824. <xsl:call-template name="createMapLinks">
  825. <xsl:with-param name="nodeSet" select="parent::*[contains(@class, ' topic/topic ')]"/>
  826. <xsl:with-param name="title" select="$linksTitle"/>
  827. </xsl:call-template>
  828. </xsl:template>
  829. <xsl:template name="linkToNext">
  830. <!-- Creating relationships to the next sibling -->
  831. <xsl:variable name="linksTitle">
  832. <!--
  833. <xsl:call-template name="getVariable">
  834. <xsl:with-param name="id" select="'Next topic'"/>
  835. </xsl:call-template>
  836. -->
  837. <text:p text:style-name="Default_20_Text">
  838. <text:span text:style-name="bold">
  839. <xsl:call-template name="getVariable">
  840. <xsl:with-param name="id" select="'Next topic'"/>
  841. </xsl:call-template>
  842. </text:span>
  843. </text:p>
  844. </xsl:variable>
  845. <xsl:call-template name="createMapLinks">
  846. <xsl:with-param name="nodeSet" select="following-sibling::*[contains(@class, ' topic/topic ')][1]"/>
  847. <xsl:with-param name="title" select="$linksTitle"/>
  848. </xsl:call-template>
  849. </xsl:template>
  850. <xsl:template name="linkToPrevious">
  851. <!-- Creating relationships to the previous sibling -->
  852. <xsl:variable name="linksTitle">
  853. <!--
  854. <xsl:call-template name="getVariable">
  855. <xsl:with-param name="id" select="'Previous topic'"/>
  856. </xsl:call-template>
  857. -->
  858. <text:p text:style-name="Default_20_Text">
  859. <text:span text:style-name="bold">
  860. <xsl:call-template name="getVariable">
  861. <xsl:with-param name="id" select="'Previous topic'"/>
  862. </xsl:call-template>
  863. </text:span>
  864. </text:p>
  865. </xsl:variable>
  866. <xsl:call-template name="createMapLinks">
  867. <xsl:with-param name="nodeSet" select="preceding-sibling::*[contains(@class, ' topic/topic ')][1]"/>
  868. <xsl:with-param name="title" select="$linksTitle"/>
  869. </xsl:call-template>
  870. </xsl:template>
  871. <xsl:template name="linkToChilds">
  872. <!-- Creating relationships to the childs -->
  873. <xsl:param name="listType"/>
  874. <xsl:variable name="linksTitle">
  875. <!--
  876. <xsl:call-template name="getVariable">
  877. <xsl:with-param name="id" select="'Child topics'"/>
  878. </xsl:call-template>
  879. -->
  880. <text:p text:style-name="Default_20_Text">
  881. <text:span text:style-name="bold">
  882. <xsl:call-template name="getVariable">
  883. <xsl:with-param name="id" select="'Child topics'"/>
  884. </xsl:call-template>
  885. </text:span>
  886. </text:p>
  887. </xsl:variable>
  888. <xsl:call-template name="createMapLinks">
  889. <xsl:with-param name="nodeSet" select="*[contains(@class, ' topic/topic ')] | *[contains(@class,' topic/dita ')]/*[contains(@class, ' topic/topic ')]"/>
  890. <xsl:with-param name="title" select="$linksTitle"/>
  891. <xsl:with-param name="listType" select="$listType"/>
  892. </xsl:call-template>
  893. </xsl:template>
  894. <xsl:template name="createMapLinks">
  895. <xsl:param name="nodeSet"/>
  896. <xsl:param name="title"/>
  897. <xsl:param name="listType" select="'none'"/>
  898. <xsl:variable name="linkNodes">
  899. <xsl:if test="$nodeSet">
  900. <xsl:choose>
  901. <xsl:when test="$listType = 'bulleted'">
  902. <xsl:call-template name="createMapLinksUnordered">
  903. <xsl:with-param name="nodeSet" select="$nodeSet"/>
  904. </xsl:call-template>
  905. </xsl:when>
  906. <xsl:when test="$listType = 'numbered'">
  907. <xsl:call-template name="createMapLinksOrdered">
  908. <xsl:with-param name="nodeSet" select="$nodeSet"/>
  909. </xsl:call-template>
  910. </xsl:when>
  911. <xsl:when test="$listType = 'none'">
  912. <text:p text:style-name="Default_20_Text">
  913. <xsl:for-each select="$nodeSet">
  914. <text:a xlink:href="concat('#', @id)">
  915. <xsl:apply-templates select="child::*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  916. </text:a>
  917. <text:line-break/>
  918. </xsl:for-each>
  919. </text:p>
  920. </xsl:when>
  921. </xsl:choose>
  922. </xsl:if>
  923. </xsl:variable>
  924. <xsl:if test="($linkNodes//text:list) or ($linkNodes//text:p)">
  925. <xsl:if test="$title">
  926. <xsl:value-of select="$title"/>
  927. </xsl:if>
  928. <xsl:copy-of select="$linkNodes"/>
  929. </xsl:if>
  930. </xsl:template>
  931. <xsl:template name="createMapLinksUnordered">
  932. <xsl:param name="nodeSet"/>
  933. <text:list text:style-name="list_style">
  934. <xsl:for-each select="$nodeSet">
  935. <text:list-item>
  936. <!--
  937. <xsl:call-template name="getVariable">
  938. <xsl:with-param name="id" select="'Unordered List bullet'"/>
  939. </xsl:call-template>
  940. -->
  941. <text:p text:style-name="Default_20_Text">
  942. <text:span text:style-name="bold">
  943. <xsl:call-template name="getVariable">
  944. <xsl:with-param name="id" select="'Unordered List bullet'"/>
  945. </xsl:call-template>
  946. </text:span>
  947. </text:p>
  948. <text:p text:style-name="Default_20_Text">
  949. <text:a xlink:href="concat('#' , @id)">
  950. <xsl:apply-templates select="child::*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  951. </text:a>
  952. </text:p>
  953. </text:list-item>
  954. </xsl:for-each>
  955. </text:list>
  956. </xsl:template>
  957. <xsl:template name="createMapLinksOrdered">
  958. <xsl:param name="nodeSet"/>
  959. <text:list text:style-nam="ordered_list_style">
  960. <xsl:for-each select="$nodeSet">
  961. <text:list-item>
  962. <text:p text:style-name="Default_20_Text">
  963. <xsl:value-of select="count(preceding-sibling::*[contains(@class,' topic/topic ')])"/>
  964. </text:p>
  965. <text:p text:style-name="Default_20_Text">
  966. <text:a xlink:href="concat('#', @id)">
  967. <xsl:apply-templates select="child::*[contains(@class, ' topic/title ')]" mode="insert-text"/>
  968. </text:a>
  969. </text:p>
  970. </text:list-item>
  971. </xsl:for-each>
  972. </text:list>
  973. </xsl:template>
  974. <xsl:template name="createRelatedLinks">
  975. <xsl:param name="linkType"/>
  976. <xsl:param name="title"/>
  977. <xsl:variable name="id" select="@id"/>
  978. <xsl:if test="$relatedTopicrefs/@id = $id">
  979. <xsl:variable name="resultLinks">
  980. <xsl:for-each select="$relatedTopicrefs[@id = $id]">
  981. <xsl:choose>
  982. <xsl:when test="ancestor::*[contains(@class, ' map/reltable ')]/*[contains(@class, ' map/relheader ')]">
  983. <xsl:variable name="topicTypeCellSpec" select="ancestor::*[contains(@class, ' map/reltable ')]/*[contains(@class, ' map/relheader ')]/*[contains(@class, ' map/relcolspec ')][@type = $linkType]"/>
  984. <xsl:if test="$topicTypeCellSpec">
  985. <xsl:variable name="currPosition" select="count(ancestor::*[contains(@class, ' map/relcell ')][1]/preceding-sibling::*) + 1"/>
  986. <xsl:variable name="position">
  987. <xsl:for-each select="$topicTypeCellSpec">
  988. <xsl:value-of select="count(preceding-sibling::*) + 1"/>
  989. </xsl:for-each>
  990. </xsl:variable>
  991. <xsl:if test="not($currPosition = $position)">
  992. <xsl:for-each select="ancestor::*[contains(@class, ' map/relrow ')]/*[contains(@class, ' map/relcell ')][position() = $position]//*[contains(@class, ' map/topicref ')]">
  993. <xsl:variable name="relatedTopic" select="key('key_anchor',@id)[1]"/>
  994. <text:p text:style-name="Default_20_Text">
  995. <text:a xlink:href="concat('#', $id)">
  996. <xsl:apply-templates select="$relatedTopic/*[contains(@class,' topic/title ')]" mode="insert-text"/>
  997. </text:a>
  998. </text:p>
  999. </xsl:for-each>
  1000. </xsl:if>
  1001. </xsl:if>
  1002. </xsl:when>
  1003. <xsl:otherwise>
  1004. <xsl:for-each select="ancestor::*[contains(@class, ' map/relcell ')][1]/preceding-sibling::*//*[contains(@class, ' map/topicref ')] | ancestor::*[contains(@class, ' map/relcell ')][1]/following-sibling::*//*[contains(@class, ' map/topicref ')]">
  1005. <xsl:variable name="relatedTopic" select="key('key_anchor',@id)[1]"/>
  1006. <xsl:choose>
  1007. <xsl:when test="$linkType = 'topic'">
  1008. <xsl:if test="contains($relatedTopic/@class, ' topic/topic ') and not(contains($relatedTopic/@class, ' concept/concept ') or contains($relatedTopic/@class, ' task/task ') or contains($relatedTopic/@class, ' reference/reference '))">
  1009. <text:p text:style-name="Default_20_Text">
  1010. <text:a xlink:href="concat('#', $id)">
  1011. <xsl:apply-templates select="$relatedTopic/*[contains(@class,' topic/title ')]" mode="insert-text"/>
  1012. </text:a>
  1013. </text:p>
  1014. </xsl:if>
  1015. </xsl:when>
  1016. <xsl:when test="$linkType = 'task'">
  1017. <xsl:if test="contains($relatedTopic/@class, ' task/task ')">
  1018. <text:p text:style-name="Default_20_Text">
  1019. <text:a xlink:href="concat('#', $id)">
  1020. <xsl:apply-templates select="$relatedTopic/*[contains(@class,' topic/title ')]" mode="insert-text"/>
  1021. </text:a>
  1022. </text:p>
  1023. </xsl:if>
  1024. </xsl:when>
  1025. <xsl:when test="$linkType = 'concept'">
  1026. <xsl:if test="contains($relatedTopic/@class, ' concept/concept ')">
  1027. <text:p text:style-name="Default_20_Text">
  1028. <text:a xlink:href="concat('#', $id)">
  1029. <xsl:apply-templates select="$relatedTopic/*[contains(@class,' topic/title ')]" mode="insert-text"/>
  1030. </text:a>
  1031. </text:p>
  1032. </xsl:if>
  1033. </xsl:when>
  1034. <xsl:when test="$linkType = 'reference'">
  1035. <xsl:if test="contains($relatedTopic/@class, ' reference/reference ')">
  1036. <text:p text:style-name="Default_20_Text">
  1037. <text:a xlink:href="concat('#', $id)">
  1038. <xsl:apply-templates select="$relatedTopic/*[contains(@class,' topic/title ')]" mode="insert-text"/>
  1039. </text:a>
  1040. </text:p>
  1041. </xsl:if>
  1042. </xsl:when>
  1043. </xsl:choose>
  1044. </xsl:for-each>
  1045. </xsl:otherwise>
  1046. </xsl:choose>
  1047. </xsl:for-each>
  1048. </xsl:variable>
  1049. <xsl:if test="$resultLinks/*">
  1050. <xsl:if test="$title">
  1051. <text:p text:style-name="Default_20_Text">
  1052. <xsl:value-of select="$title"/>
  1053. </text:p>
  1054. </xsl:if>
  1055. <xsl:copy-of select="$resultLinks"/>
  1056. </xsl:if>
  1057. </xsl:if>
  1058. </xsl:template>
  1059. <xsl:template name="brokenLinks">
  1060. <xsl:param name="href"/>
  1061. <xsl:call-template name="output-message">
  1062. <xsl:with-param name="id" select="'DOTX063W'"/>
  1063. <xsl:with-param name="msgparams">%1=<xsl:value-of select="$href"/></xsl:with-param>
  1064. </xsl:call-template>
  1065. </xsl:template>
  1066. <!--create prerequisite links with all dups eliminated. -->
  1067. <!-- Omit prereq links from unordered related-links (handled by mode="prereqs" template). -->
  1068. <xsl:key name="omit-from-unordered-links" match="*[@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='cousin')]" use="1"/>
  1069. <xsl:template match="*[contains(@class,' topic/related-links ')]" mode="prereqs">
  1070. <!--if there are any prereqs create a list with dups-->
  1071. <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')]">
  1072. <text:p>
  1073. <text:span text:style-name="default_text_style">
  1074. <xsl:call-template name="getVariable">
  1075. <xsl:with-param name="id" select="'Prerequisites'"/>
  1076. </xsl:call-template>
  1077. </text:span>
  1078. </text:p>
  1079. <!--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-->
  1080. <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(child::*[1])))[1])] [@href] [@importance='required' and (not(@role) or @role='sibling' or @role='friend' or @role='previous' or @role='cousin')] [not(ancestor::*[contains(@class, ' topic/linklist ')])]"/>
  1081. </xsl:if>
  1082. </xsl:template>
  1083. <xsl:template mode="prereqs" match="*[contains(@class, ' topic/link ')]" priority="2">
  1084. <!-- Allow for unknown metadata (future-proofing) -->
  1085. <xsl:apply-templates select="*[contains(@class,' topic/data ') or contains(@class,' topic/foreign ')]"/>
  1086. <xsl:variable name="samefile">
  1087. <xsl:call-template name="check_file_location"/>
  1088. </xsl:variable>
  1089. <xsl:variable name="href-value">
  1090. <xsl:call-template name="format_href_value"/>
  1091. </xsl:variable>
  1092. <text:p text:style-name="Default_20_Text">
  1093. <xsl:call-template name="create_related_links">
  1094. <xsl:with-param name="samefile" select="$samefile"/>
  1095. <xsl:with-param name="href-value" select="$href-value"/>
  1096. </xsl:call-template>
  1097. </text:p>
  1098. </xsl:template>
  1099. </xsl:stylesheet>