xref.xsl 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288
  1. <?xml version="1.0" encoding="ASCII"?>
  2. <!--This file was created automatically by html2xhtml-->
  3. <!--from the HTML stylesheets.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:suwl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.UnwrapLinks" xmlns:exsl="http://exslt.org/common" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="suwl exsl xlink" version="1.0">
  5. <!-- ********************************************************************
  6. $Id$
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <!-- Use internal variable for olink xlink role for consistency -->
  13. <xsl:variable name="xolink.role">http://docbook.org/xlink/role/olink</xsl:variable>
  14. <!-- ==================================================================== -->
  15. <xsl:template match="anchor">
  16. <xsl:call-template name="anchor"/>
  17. </xsl:template>
  18. <!-- ==================================================================== -->
  19. <xsl:template match="xref" name="xref">
  20. <xsl:param name="xhref" select="@xlink:href"/>
  21. <!-- is the @xlink:href a local idref link? -->
  22. <xsl:param name="xlink.idref">
  23. <xsl:if test="starts-with($xhref,'#') and (not(contains($xhref,'(')) or starts-with($xhref, '#xpointer(id('))">
  24. <xsl:call-template name="xpointer.idref">
  25. <xsl:with-param name="xpointer" select="$xhref"/>
  26. </xsl:call-template>
  27. </xsl:if>
  28. </xsl:param>
  29. <xsl:param name="xlink.targets" select="key('id',$xlink.idref)"/>
  30. <xsl:param name="linkend.targets" select="key('id',@linkend)"/>
  31. <xsl:param name="target" select="($xlink.targets | $linkend.targets)[1]"/>
  32. <xsl:variable name="xrefstyle">
  33. <xsl:choose>
  34. <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
  35. <xsl:value-of select="@role"/>
  36. </xsl:when>
  37. <xsl:otherwise>
  38. <xsl:value-of select="@xrefstyle"/>
  39. </xsl:otherwise>
  40. </xsl:choose>
  41. </xsl:variable>
  42. <xsl:call-template name="anchor"/>
  43. <xsl:variable name="content">
  44. <xsl:choose>
  45. <xsl:when test="@endterm">
  46. <xsl:variable name="etargets" select="key('id',@endterm)"/>
  47. <xsl:variable name="etarget" select="$etargets[1]"/>
  48. <xsl:choose>
  49. <xsl:when test="count($etarget) = 0">
  50. <xsl:message>
  51. <xsl:value-of select="count($etargets)"/>
  52. <xsl:text>Endterm points to nonexistent ID: </xsl:text>
  53. <xsl:value-of select="@endterm"/>
  54. </xsl:message>
  55. <xsl:text>???</xsl:text>
  56. </xsl:when>
  57. <xsl:otherwise>
  58. <xsl:apply-templates select="$etarget" mode="endterm"/>
  59. </xsl:otherwise>
  60. </xsl:choose>
  61. </xsl:when>
  62. <xsl:when test="$target/@xreflabel">
  63. <xsl:call-template name="xref.xreflabel">
  64. <xsl:with-param name="target" select="$target"/>
  65. </xsl:call-template>
  66. </xsl:when>
  67. <xsl:when test="$target">
  68. <xsl:if test="not(parent::citation)">
  69. <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
  70. </xsl:if>
  71. <xsl:apply-templates select="$target" mode="xref-to">
  72. <xsl:with-param name="referrer" select="."/>
  73. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  74. </xsl:apply-templates>
  75. <xsl:if test="not(parent::citation)">
  76. <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
  77. </xsl:if>
  78. </xsl:when>
  79. <xsl:otherwise>
  80. <xsl:message>
  81. <xsl:text>ERROR: xref linking to </xsl:text>
  82. <xsl:value-of select="@linkend|@xlink:href"/>
  83. <xsl:text> has no generated link text.</xsl:text>
  84. </xsl:message>
  85. <xsl:text>???</xsl:text>
  86. </xsl:otherwise>
  87. </xsl:choose>
  88. </xsl:variable>
  89. <xsl:call-template name="simple.xlink">
  90. <xsl:with-param name="content" select="$content"/>
  91. </xsl:call-template>
  92. </xsl:template>
  93. <!-- ==================================================================== -->
  94. <!-- biblioref handled largely like an xref -->
  95. <!-- To be done: add support for begin, end, and units attributes -->
  96. <xsl:template match="biblioref">
  97. <xsl:variable name="targets" select="key('id',@linkend)"/>
  98. <xsl:variable name="target" select="$targets[1]"/>
  99. <xsl:variable name="refelem" select="local-name($target)"/>
  100. <xsl:call-template name="check.id.unique">
  101. <xsl:with-param name="linkend" select="@linkend"/>
  102. </xsl:call-template>
  103. <xsl:call-template name="anchor"/>
  104. <xsl:choose>
  105. <xsl:when test="count($target) = 0">
  106. <xsl:message>
  107. <xsl:text>XRef to nonexistent id: </xsl:text>
  108. <xsl:value-of select="@linkend"/>
  109. </xsl:message>
  110. <xsl:text>???</xsl:text>
  111. </xsl:when>
  112. <xsl:when test="@endterm">
  113. <xsl:variable name="href">
  114. <xsl:call-template name="href.target">
  115. <xsl:with-param name="object" select="$target"/>
  116. </xsl:call-template>
  117. </xsl:variable>
  118. <xsl:variable name="etargets" select="key('id',@endterm)"/>
  119. <xsl:variable name="etarget" select="$etargets[1]"/>
  120. <xsl:choose>
  121. <xsl:when test="count($etarget) = 0">
  122. <xsl:message>
  123. <xsl:value-of select="count($etargets)"/>
  124. <xsl:text>Endterm points to nonexistent ID: </xsl:text>
  125. <xsl:value-of select="@endterm"/>
  126. </xsl:message>
  127. <a href="{$href}">
  128. <xsl:apply-templates select="." mode="class.attribute"/>
  129. <xsl:text>???</xsl:text>
  130. </a>
  131. </xsl:when>
  132. <xsl:otherwise>
  133. <a href="{$href}">
  134. <xsl:apply-templates select="." mode="class.attribute"/>
  135. <xsl:apply-templates select="$etarget" mode="endterm"/>
  136. </a>
  137. </xsl:otherwise>
  138. </xsl:choose>
  139. </xsl:when>
  140. <xsl:when test="$target/@xreflabel">
  141. <a>
  142. <xsl:apply-templates select="." mode="class.attribute"/>
  143. <xsl:attribute name="href">
  144. <xsl:call-template name="href.target">
  145. <xsl:with-param name="object" select="$target"/>
  146. </xsl:call-template>
  147. </xsl:attribute>
  148. <xsl:call-template name="xref.xreflabel">
  149. <xsl:with-param name="target" select="$target"/>
  150. </xsl:call-template>
  151. </a>
  152. </xsl:when>
  153. <xsl:otherwise>
  154. <xsl:variable name="href">
  155. <xsl:call-template name="href.target">
  156. <xsl:with-param name="object" select="$target"/>
  157. </xsl:call-template>
  158. </xsl:variable>
  159. <xsl:if test="not(parent::citation)">
  160. <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
  161. </xsl:if>
  162. <a href="{$href}">
  163. <xsl:apply-templates select="." mode="class.attribute"/>
  164. <xsl:if test="$target/title or $target/*/title">
  165. <xsl:attribute name="title">
  166. <xsl:apply-templates select="$target" mode="xref-title"/>
  167. </xsl:attribute>
  168. </xsl:if>
  169. <xsl:apply-templates select="$target" mode="xref-to">
  170. <xsl:with-param name="referrer" select="."/>
  171. <xsl:with-param name="xrefstyle">
  172. <xsl:choose>
  173. <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
  174. <xsl:value-of select="@role"/>
  175. </xsl:when>
  176. <xsl:otherwise>
  177. <xsl:value-of select="@xrefstyle"/>
  178. </xsl:otherwise>
  179. </xsl:choose>
  180. </xsl:with-param>
  181. </xsl:apply-templates>
  182. </a>
  183. <xsl:if test="not(parent::citation)">
  184. <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
  185. </xsl:if>
  186. </xsl:otherwise>
  187. </xsl:choose>
  188. </xsl:template>
  189. <!-- ==================================================================== -->
  190. <xsl:template match="*" mode="endterm">
  191. <!-- Process the children of the endterm element -->
  192. <xsl:variable name="endterm">
  193. <xsl:apply-templates select="child::node()"/>
  194. </xsl:variable>
  195. <xsl:choose>
  196. <xsl:when test="function-available('exsl:node-set')">
  197. <xsl:apply-templates select="exsl:node-set($endterm)" mode="remove-ids"/>
  198. </xsl:when>
  199. <xsl:otherwise>
  200. <xsl:copy-of select="$endterm"/>
  201. </xsl:otherwise>
  202. </xsl:choose>
  203. </xsl:template>
  204. <xsl:template match="*" mode="remove-ids">
  205. <xsl:choose>
  206. <!-- handle html or xhtml -->
  207. <xsl:when test="local-name(.) = 'a' and (namespace-uri(.) = '' or namespace-uri(.) = 'http://www.w3.org/1999/xhtml')">
  208. <xsl:choose>
  209. <xsl:when test="(@name and count(@*) = 1) or (@id and count(@*) = 1) or (@xml:id and count(@*) = 1) or (@xml:id and @name and count(@*) = 2) or (@id and @name and count(@*) = 2)">
  210. <xsl:message>suppress anchor</xsl:message>
  211. <!-- suppress the whole thing -->
  212. </xsl:when>
  213. <xsl:otherwise>
  214. <xsl:copy>
  215. <xsl:for-each select="@*">
  216. <xsl:choose>
  217. <xsl:when test="local-name(.) != 'name' and local-name(.) != 'id'">
  218. <xsl:copy/>
  219. </xsl:when>
  220. <xsl:otherwise>
  221. <xsl:message>removing <xsl:value-of select="local-name(.)"/></xsl:message>
  222. </xsl:otherwise>
  223. </xsl:choose>
  224. </xsl:for-each>
  225. </xsl:copy>
  226. <xsl:apply-templates mode="remove-ids"/>
  227. </xsl:otherwise>
  228. </xsl:choose>
  229. </xsl:when>
  230. <xsl:otherwise>
  231. <xsl:copy>
  232. <xsl:for-each select="@*">
  233. <xsl:choose>
  234. <xsl:when test="local-name(.) != 'id'">
  235. <xsl:copy/>
  236. </xsl:when>
  237. <xsl:otherwise>
  238. <xsl:message>removing <xsl:value-of select="local-name(.)"/></xsl:message>
  239. </xsl:otherwise>
  240. </xsl:choose>
  241. </xsl:for-each>
  242. <xsl:apply-templates mode="remove-ids"/>
  243. </xsl:copy>
  244. </xsl:otherwise>
  245. </xsl:choose>
  246. </xsl:template>
  247. <!-- ==================================================================== -->
  248. <xsl:template match="*" mode="xref-to-prefix"/>
  249. <xsl:template match="*" mode="xref-to-suffix"/>
  250. <xsl:template match="*" mode="xref-to">
  251. <xsl:param name="referrer"/>
  252. <xsl:param name="xrefstyle"/>
  253. <xsl:param name="verbose" select="1"/>
  254. <xsl:if test="$verbose">
  255. <xsl:message>
  256. <xsl:text>Don't know what gentext to create for xref to: "</xsl:text>
  257. <xsl:value-of select="name(.)"/>
  258. <xsl:text>", ("</xsl:text>
  259. <xsl:value-of select="(@id|@xml:id)[1]"/>
  260. <xsl:text>")</xsl:text>
  261. </xsl:message>
  262. </xsl:if>
  263. <xsl:text>???</xsl:text>
  264. </xsl:template>
  265. <xsl:template match="title" mode="xref-to">
  266. <xsl:param name="referrer"/>
  267. <xsl:param name="xrefstyle"/>
  268. <xsl:param name="verbose" select="1"/>
  269. <!-- if you xref to a title, xref to the parent... -->
  270. <xsl:choose>
  271. <!-- FIXME: how reliable is this? -->
  272. <xsl:when test="contains(local-name(parent::*), 'info')">
  273. <xsl:apply-templates select="parent::*[2]" mode="xref-to">
  274. <xsl:with-param name="referrer" select="$referrer"/>
  275. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  276. <xsl:with-param name="verbose" select="$verbose"/>
  277. </xsl:apply-templates>
  278. </xsl:when>
  279. <xsl:otherwise>
  280. <xsl:apply-templates select="parent::*" mode="xref-to">
  281. <xsl:with-param name="referrer" select="$referrer"/>
  282. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  283. <xsl:with-param name="verbose" select="$verbose"/>
  284. </xsl:apply-templates>
  285. </xsl:otherwise>
  286. </xsl:choose>
  287. </xsl:template>
  288. <xsl:template match="abstract|authorblurb|personblurb|bibliodiv|bibliomset |biblioset|blockquote|calloutlist|caution|colophon |constraintdef|formalpara|glossdiv|important|indexdiv |itemizedlist|legalnotice|lot|msg|msgexplan|msgmain |msgrel|msgset|msgsub|note|orderedlist|partintro |productionset|qandadiv|refsynopsisdiv|segmentedlist |set|setindex|sidebar|tip|toc|variablelist|warning" mode="xref-to">
  289. <xsl:param name="referrer"/>
  290. <xsl:param name="xrefstyle"/>
  291. <xsl:param name="verbose" select="1"/>
  292. <!-- catch-all for things with (possibly optional) titles -->
  293. <xsl:apply-templates select="." mode="object.xref.markup">
  294. <xsl:with-param name="purpose" select="'xref'"/>
  295. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  296. <xsl:with-param name="referrer" select="$referrer"/>
  297. <xsl:with-param name="verbose" select="$verbose"/>
  298. </xsl:apply-templates>
  299. </xsl:template>
  300. <xsl:template match="author|editor|othercredit|personname" mode="xref-to">
  301. <xsl:param name="referrer"/>
  302. <xsl:param name="xrefstyle"/>
  303. <xsl:call-template name="person.name"/>
  304. </xsl:template>
  305. <xsl:template match="authorgroup" mode="xref-to">
  306. <xsl:param name="referrer"/>
  307. <xsl:param name="xrefstyle"/>
  308. <xsl:call-template name="person.name.list"/>
  309. </xsl:template>
  310. <xsl:template match="figure|example|table|equation" mode="xref-to">
  311. <xsl:param name="referrer"/>
  312. <xsl:param name="xrefstyle"/>
  313. <xsl:param name="verbose" select="1"/>
  314. <xsl:apply-templates select="." mode="object.xref.markup">
  315. <xsl:with-param name="purpose" select="'xref'"/>
  316. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  317. <xsl:with-param name="referrer" select="$referrer"/>
  318. <xsl:with-param name="verbose" select="$verbose"/>
  319. </xsl:apply-templates>
  320. </xsl:template>
  321. <xsl:template match="procedure" mode="xref-to">
  322. <xsl:param name="referrer"/>
  323. <xsl:param name="xrefstyle"/>
  324. <xsl:param name="verbose"/>
  325. <xsl:apply-templates select="." mode="object.xref.markup">
  326. <xsl:with-param name="purpose" select="'xref'"/>
  327. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  328. <xsl:with-param name="referrer" select="$referrer"/>
  329. <xsl:with-param name="verbose" select="$verbose"/>
  330. </xsl:apply-templates>
  331. </xsl:template>
  332. <xsl:template match="task" mode="xref-to">
  333. <xsl:param name="referrer"/>
  334. <xsl:param name="xrefstyle"/>
  335. <xsl:param name="verbose"/>
  336. <xsl:apply-templates select="." mode="object.xref.markup">
  337. <xsl:with-param name="purpose" select="'xref'"/>
  338. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  339. <xsl:with-param name="referrer" select="$referrer"/>
  340. <xsl:with-param name="verbose" select="$verbose"/>
  341. </xsl:apply-templates>
  342. </xsl:template>
  343. <xsl:template match="cmdsynopsis" mode="xref-to">
  344. <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
  345. </xsl:template>
  346. <xsl:template match="funcsynopsis" mode="xref-to">
  347. <xsl:apply-templates select="(.//function)[1]" mode="xref"/>
  348. </xsl:template>
  349. <xsl:template match="dedication|preface|chapter|appendix|article" mode="xref-to">
  350. <xsl:param name="referrer"/>
  351. <xsl:param name="xrefstyle"/>
  352. <xsl:param name="verbose" select="1"/>
  353. <xsl:apply-templates select="." mode="object.xref.markup">
  354. <xsl:with-param name="purpose" select="'xref'"/>
  355. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  356. <xsl:with-param name="referrer" select="$referrer"/>
  357. <xsl:with-param name="verbose" select="$verbose"/>
  358. </xsl:apply-templates>
  359. </xsl:template>
  360. <xsl:template match="bibliography" mode="xref-to">
  361. <xsl:param name="referrer"/>
  362. <xsl:param name="xrefstyle"/>
  363. <xsl:param name="verbose" select="1"/>
  364. <xsl:apply-templates select="." mode="object.xref.markup">
  365. <xsl:with-param name="purpose" select="'xref'"/>
  366. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  367. <xsl:with-param name="referrer" select="$referrer"/>
  368. <xsl:with-param name="verbose" select="$verbose"/>
  369. </xsl:apply-templates>
  370. </xsl:template>
  371. <xsl:template match="biblioentry|bibliomixed" mode="xref-to-prefix">
  372. <xsl:text>[</xsl:text>
  373. </xsl:template>
  374. <xsl:template match="biblioentry|bibliomixed" mode="xref-to-suffix">
  375. <xsl:text>]</xsl:text>
  376. </xsl:template>
  377. <xsl:template match="biblioentry|bibliomixed" mode="xref-to">
  378. <xsl:param name="referrer"/>
  379. <xsl:param name="xrefstyle"/>
  380. <xsl:param name="verbose" select="1"/>
  381. <!-- handles both biblioentry and bibliomixed -->
  382. <xsl:choose>
  383. <xsl:when test="string(.) = ''">
  384. <xsl:variable name="bib" select="document($bibliography.collection,.)"/>
  385. <xsl:variable name="id" select="(@id|@xml:id)[1]"/>
  386. <xsl:variable name="entry" select="$bib/bibliography/ *[@id=$id or @xml:id=$id][1]"/>
  387. <xsl:choose>
  388. <xsl:when test="$entry">
  389. <xsl:choose>
  390. <xsl:when test="$bibliography.numbered != 0">
  391. <xsl:number from="bibliography" count="biblioentry|bibliomixed" level="any" format="1"/>
  392. </xsl:when>
  393. <xsl:when test="local-name($entry/*[1]) = 'abbrev'">
  394. <xsl:apply-templates select="$entry/*[1]"/>
  395. </xsl:when>
  396. <xsl:otherwise>
  397. <xsl:value-of select="(@id|@xml:id)[1]"/>
  398. </xsl:otherwise>
  399. </xsl:choose>
  400. </xsl:when>
  401. <xsl:otherwise>
  402. <xsl:message>
  403. <xsl:text>No bibliography entry: </xsl:text>
  404. <xsl:value-of select="$id"/>
  405. <xsl:text> found in </xsl:text>
  406. <xsl:value-of select="$bibliography.collection"/>
  407. </xsl:message>
  408. <xsl:value-of select="(@id|@xml:id)[1]"/>
  409. </xsl:otherwise>
  410. </xsl:choose>
  411. </xsl:when>
  412. <xsl:otherwise>
  413. <xsl:choose>
  414. <xsl:when test="$bibliography.numbered != 0">
  415. <xsl:number from="bibliography" count="biblioentry|bibliomixed" level="any" format="1"/>
  416. </xsl:when>
  417. <xsl:when test="local-name(*[1]) = 'abbrev'">
  418. <xsl:apply-templates select="*[1]"/>
  419. </xsl:when>
  420. <xsl:otherwise>
  421. <xsl:value-of select="(@id|@xml:id)[1]"/>
  422. </xsl:otherwise>
  423. </xsl:choose>
  424. </xsl:otherwise>
  425. </xsl:choose>
  426. </xsl:template>
  427. <xsl:template match="glossary" mode="xref-to">
  428. <xsl:param name="referrer"/>
  429. <xsl:param name="xrefstyle"/>
  430. <xsl:param name="verbose" select="1"/>
  431. <xsl:apply-templates select="." mode="object.xref.markup">
  432. <xsl:with-param name="purpose" select="'xref'"/>
  433. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  434. <xsl:with-param name="referrer" select="$referrer"/>
  435. <xsl:with-param name="verbose" select="$verbose"/>
  436. </xsl:apply-templates>
  437. </xsl:template>
  438. <xsl:template match="glossentry" mode="xref-to">
  439. <xsl:param name="referrer"/>
  440. <xsl:param name="xrefstyle"/>
  441. <xsl:param name="verbose" select="1"/>
  442. <xsl:choose>
  443. <xsl:when test="$glossentry.show.acronym = 'primary'">
  444. <xsl:choose>
  445. <xsl:when test="acronym|abbrev">
  446. <xsl:apply-templates select="(acronym|abbrev)[1]"/>
  447. </xsl:when>
  448. <xsl:otherwise>
  449. <xsl:apply-templates select="glossterm[1]" mode="xref-to">
  450. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  451. <xsl:with-param name="referrer" select="$referrer"/>
  452. <xsl:with-param name="verbose" select="$verbose"/>
  453. </xsl:apply-templates>
  454. </xsl:otherwise>
  455. </xsl:choose>
  456. </xsl:when>
  457. <xsl:otherwise>
  458. <xsl:apply-templates select="glossterm[1]" mode="xref-to">
  459. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  460. <xsl:with-param name="referrer" select="$referrer"/>
  461. <xsl:with-param name="verbose" select="$verbose"/>
  462. </xsl:apply-templates>
  463. </xsl:otherwise>
  464. </xsl:choose>
  465. </xsl:template>
  466. <xsl:template match="glossterm" mode="xref-to">
  467. <xsl:apply-templates/>
  468. </xsl:template>
  469. <xsl:template match="index" mode="xref-to">
  470. <xsl:param name="referrer"/>
  471. <xsl:param name="xrefstyle"/>
  472. <xsl:param name="verbose" select="1"/>
  473. <xsl:apply-templates select="." mode="object.xref.markup">
  474. <xsl:with-param name="purpose" select="'xref'"/>
  475. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  476. <xsl:with-param name="referrer" select="$referrer"/>
  477. <xsl:with-param name="verbose" select="$verbose"/>
  478. </xsl:apply-templates>
  479. </xsl:template>
  480. <xsl:template match="listitem" mode="xref-to">
  481. <xsl:param name="referrer"/>
  482. <xsl:param name="xrefstyle"/>
  483. <xsl:param name="verbose"/>
  484. <xsl:apply-templates select="." mode="object.xref.markup">
  485. <xsl:with-param name="purpose" select="'xref'"/>
  486. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  487. <xsl:with-param name="referrer" select="$referrer"/>
  488. <xsl:with-param name="verbose" select="$verbose"/>
  489. </xsl:apply-templates>
  490. </xsl:template>
  491. <xsl:template match="section|simplesect |sect1|sect2|sect3|sect4|sect5 |refsect1|refsect2|refsect3|refsection" mode="xref-to">
  492. <xsl:param name="referrer"/>
  493. <xsl:param name="xrefstyle"/>
  494. <xsl:param name="verbose" select="1"/>
  495. <xsl:apply-templates select="." mode="object.xref.markup">
  496. <xsl:with-param name="purpose" select="'xref'"/>
  497. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  498. <xsl:with-param name="referrer" select="$referrer"/>
  499. <xsl:with-param name="verbose" select="$verbose"/>
  500. </xsl:apply-templates>
  501. <!-- FIXME: What about "in Chapter X"? -->
  502. </xsl:template>
  503. <xsl:template match="bridgehead" mode="xref-to">
  504. <xsl:param name="referrer"/>
  505. <xsl:param name="xrefstyle"/>
  506. <xsl:param name="verbose" select="1"/>
  507. <xsl:apply-templates select="." mode="object.xref.markup">
  508. <xsl:with-param name="purpose" select="'xref'"/>
  509. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  510. <xsl:with-param name="referrer" select="$referrer"/>
  511. <xsl:with-param name="verbose" select="$verbose"/>
  512. </xsl:apply-templates>
  513. <!-- FIXME: What about "in Chapter X"? -->
  514. </xsl:template>
  515. <xsl:template match="qandaset" mode="xref-to">
  516. <xsl:param name="referrer"/>
  517. <xsl:param name="xrefstyle"/>
  518. <xsl:param name="verbose" select="1"/>
  519. <xsl:apply-templates select="." mode="object.xref.markup">
  520. <xsl:with-param name="purpose" select="'xref'"/>
  521. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  522. <xsl:with-param name="referrer" select="$referrer"/>
  523. <xsl:with-param name="verbose" select="$verbose"/>
  524. </xsl:apply-templates>
  525. </xsl:template>
  526. <xsl:template match="qandadiv" mode="xref-to">
  527. <xsl:param name="referrer"/>
  528. <xsl:param name="xrefstyle"/>
  529. <xsl:param name="verbose" select="1"/>
  530. <xsl:apply-templates select="." mode="object.xref.markup">
  531. <xsl:with-param name="purpose" select="'xref'"/>
  532. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  533. <xsl:with-param name="referrer" select="$referrer"/>
  534. <xsl:with-param name="verbose" select="$verbose"/>
  535. </xsl:apply-templates>
  536. </xsl:template>
  537. <xsl:template match="qandaentry" mode="xref-to">
  538. <xsl:param name="referrer"/>
  539. <xsl:param name="xrefstyle"/>
  540. <xsl:param name="verbose" select="1"/>
  541. <xsl:apply-templates select="question[1]" mode="object.xref.markup">
  542. <xsl:with-param name="purpose" select="'xref'"/>
  543. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  544. <xsl:with-param name="referrer" select="$referrer"/>
  545. <xsl:with-param name="verbose" select="$verbose"/>
  546. </xsl:apply-templates>
  547. </xsl:template>
  548. <xsl:template match="question|answer" mode="xref-to">
  549. <xsl:param name="referrer"/>
  550. <xsl:param name="xrefstyle"/>
  551. <xsl:param name="verbose" select="1"/>
  552. <xsl:apply-templates select="." mode="object.xref.markup">
  553. <xsl:with-param name="purpose" select="'xref'"/>
  554. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  555. <xsl:with-param name="referrer" select="$referrer"/>
  556. <xsl:with-param name="verbose" select="$verbose"/>
  557. </xsl:apply-templates>
  558. </xsl:template>
  559. <xsl:template match="part|reference" mode="xref-to">
  560. <xsl:param name="referrer"/>
  561. <xsl:param name="xrefstyle"/>
  562. <xsl:param name="verbose" select="1"/>
  563. <xsl:apply-templates select="." mode="object.xref.markup">
  564. <xsl:with-param name="purpose" select="'xref'"/>
  565. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  566. <xsl:with-param name="referrer" select="$referrer"/>
  567. <xsl:with-param name="verbose" select="$verbose"/>
  568. </xsl:apply-templates>
  569. </xsl:template>
  570. <xsl:template match="refentry" mode="xref-to">
  571. <xsl:param name="referrer"/>
  572. <xsl:param name="xrefstyle"/>
  573. <xsl:choose>
  574. <xsl:when test="refmeta/refentrytitle">
  575. <xsl:apply-templates select="refmeta/refentrytitle"/>
  576. </xsl:when>
  577. <xsl:otherwise>
  578. <xsl:apply-templates select="refnamediv/refname[1]"/>
  579. </xsl:otherwise>
  580. </xsl:choose>
  581. <xsl:apply-templates select="refmeta/manvolnum"/>
  582. </xsl:template>
  583. <xsl:template match="refnamediv" mode="xref-to">
  584. <xsl:param name="referrer"/>
  585. <xsl:param name="xrefstyle"/>
  586. <xsl:param name="verbose" select="1"/>
  587. <xsl:apply-templates select="refname[1]" mode="xref-to">
  588. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  589. <xsl:with-param name="referrer" select="$referrer"/>
  590. <xsl:with-param name="verbose" select="$verbose"/>
  591. </xsl:apply-templates>
  592. </xsl:template>
  593. <xsl:template match="refname" mode="xref-to">
  594. <xsl:param name="referrer"/>
  595. <xsl:param name="xrefstyle"/>
  596. <xsl:param name="verbose" select="1"/>
  597. <xsl:apply-templates mode="xref-to"/>
  598. </xsl:template>
  599. <xsl:template match="step" mode="xref-to">
  600. <xsl:param name="referrer"/>
  601. <xsl:param name="xrefstyle"/>
  602. <xsl:call-template name="gentext">
  603. <xsl:with-param name="key" select="'Step'"/>
  604. </xsl:call-template>
  605. <xsl:text> </xsl:text>
  606. <xsl:apply-templates select="." mode="number"/>
  607. </xsl:template>
  608. <xsl:template match="varlistentry" mode="xref-to">
  609. <xsl:param name="referrer"/>
  610. <xsl:param name="xrefstyle"/>
  611. <xsl:param name="verbose" select="1"/>
  612. <xsl:apply-templates select="term[1]" mode="xref-to">
  613. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  614. <xsl:with-param name="referrer" select="$referrer"/>
  615. <xsl:with-param name="verbose" select="$verbose"/>
  616. </xsl:apply-templates>
  617. </xsl:template>
  618. <xsl:template match="varlistentry/term" mode="xref-to">
  619. <xsl:param name="referrer"/>
  620. <xsl:param name="xrefstyle"/>
  621. <!-- to avoid the comma that will be generated if there are several terms -->
  622. <xsl:apply-templates/>
  623. </xsl:template>
  624. <xsl:template match="co" mode="xref-to">
  625. <xsl:param name="referrer"/>
  626. <xsl:param name="xrefstyle"/>
  627. <xsl:apply-templates select="." mode="callout-bug"/>
  628. </xsl:template>
  629. <xsl:template match="area|areaset" mode="xref-to">
  630. <xsl:param name="referrer"/>
  631. <xsl:param name="xrefstyle"/>
  632. <xsl:call-template name="callout-bug">
  633. <xsl:with-param name="conum">
  634. <xsl:apply-templates select="." mode="conumber"/>
  635. </xsl:with-param>
  636. </xsl:call-template>
  637. </xsl:template>
  638. <xsl:template match="book" mode="xref-to">
  639. <xsl:param name="referrer"/>
  640. <xsl:param name="xrefstyle"/>
  641. <xsl:param name="verbose" select="1"/>
  642. <xsl:apply-templates select="." mode="object.xref.markup">
  643. <xsl:with-param name="purpose" select="'xref'"/>
  644. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  645. <xsl:with-param name="referrer" select="$referrer"/>
  646. <xsl:with-param name="verbose" select="$verbose"/>
  647. </xsl:apply-templates>
  648. </xsl:template>
  649. <xsl:template match="para" mode="xref-to">
  650. <xsl:param name="referrer"/>
  651. <xsl:param name="xrefstyle"/>
  652. <xsl:param name="verbose" select="1"/>
  653. <xsl:variable name="context" select="(ancestor::simplesect |ancestor::section |ancestor::sect1 |ancestor::sect2 |ancestor::sect3 |ancestor::sect4 |ancestor::sect5 |ancestor::refsection |ancestor::refsect1 |ancestor::refsect2 |ancestor::refsect3 |ancestor::chapter |ancestor::appendix |ancestor::preface |ancestor::partintro |ancestor::dedication |ancestor::colophon |ancestor::bibliography |ancestor::index |ancestor::glossary |ancestor::glossentry |ancestor::listitem |ancestor::varlistentry)[last()]"/>
  654. <xsl:apply-templates select="$context" mode="xref-to">
  655. <xsl:with-param name="purpose" select="'xref'"/>
  656. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  657. <xsl:with-param name="referrer" select="$referrer"/>
  658. <xsl:with-param name="verbose" select="$verbose"/>
  659. </xsl:apply-templates>
  660. </xsl:template>
  661. <!-- ==================================================================== -->
  662. <xsl:template match="*" mode="xref-title">
  663. <xsl:variable name="title">
  664. <xsl:apply-templates select="." mode="object.title.markup"/>
  665. </xsl:variable>
  666. <xsl:value-of select="$title"/>
  667. </xsl:template>
  668. <xsl:template match="author" mode="xref-title">
  669. <xsl:variable name="title">
  670. <xsl:call-template name="person.name"/>
  671. </xsl:variable>
  672. <xsl:value-of select="$title"/>
  673. </xsl:template>
  674. <xsl:template match="authorgroup" mode="xref-title">
  675. <xsl:variable name="title">
  676. <xsl:call-template name="person.name.list"/>
  677. </xsl:variable>
  678. <xsl:value-of select="$title"/>
  679. </xsl:template>
  680. <xsl:template match="cmdsynopsis" mode="xref-title">
  681. <xsl:variable name="title">
  682. <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
  683. </xsl:variable>
  684. <xsl:value-of select="$title"/>
  685. </xsl:template>
  686. <xsl:template match="funcsynopsis" mode="xref-title">
  687. <xsl:variable name="title">
  688. <xsl:apply-templates select="(.//function)[1]" mode="xref"/>
  689. </xsl:variable>
  690. <xsl:value-of select="$title"/>
  691. </xsl:template>
  692. <xsl:template match="biblioentry|bibliomixed" mode="xref-title">
  693. <!-- handles both biblioentry and bibliomixed -->
  694. <xsl:variable name="title">
  695. <xsl:text>[</xsl:text>
  696. <xsl:choose>
  697. <xsl:when test="local-name(*[1]) = 'abbrev'">
  698. <xsl:apply-templates select="*[1]"/>
  699. </xsl:when>
  700. <xsl:otherwise>
  701. <xsl:value-of select="(@id|@xml:id)[1]"/>
  702. </xsl:otherwise>
  703. </xsl:choose>
  704. <xsl:text>]</xsl:text>
  705. </xsl:variable>
  706. <xsl:value-of select="$title"/>
  707. </xsl:template>
  708. <xsl:template match="step" mode="xref-title">
  709. <xsl:call-template name="gentext">
  710. <xsl:with-param name="key" select="'Step'"/>
  711. </xsl:call-template>
  712. <xsl:text> </xsl:text>
  713. <xsl:apply-templates select="." mode="number"/>
  714. </xsl:template>
  715. <xsl:template match="step[not(./title)]" mode="title.markup">
  716. <xsl:call-template name="gentext">
  717. <xsl:with-param name="key" select="'Step'"/>
  718. </xsl:call-template>
  719. <xsl:text> </xsl:text>
  720. <xsl:apply-templates select="." mode="number"/>
  721. </xsl:template>
  722. <xsl:template match="co" mode="xref-title">
  723. <xsl:variable name="title">
  724. <xsl:apply-templates select="." mode="callout-bug"/>
  725. </xsl:variable>
  726. <xsl:value-of select="$title"/>
  727. </xsl:template>
  728. <!-- ==================================================================== -->
  729. <xsl:template match="link" name="link">
  730. <xsl:param name="linkend" select="@linkend"/>
  731. <xsl:param name="a.target"/>
  732. <xsl:param name="xhref" select="@xlink:href"/>
  733. <xsl:variable name="content">
  734. <xsl:call-template name="anchor"/>
  735. <xsl:choose>
  736. <xsl:when test="count(child::node()) &gt; 0">
  737. <!-- If it has content, use it -->
  738. <xsl:apply-templates/>
  739. </xsl:when>
  740. <!-- else look for an endterm -->
  741. <xsl:when test="@endterm">
  742. <xsl:variable name="etargets" select="key('id',@endterm)"/>
  743. <xsl:variable name="etarget" select="$etargets[1]"/>
  744. <xsl:choose>
  745. <xsl:when test="count($etarget) = 0">
  746. <xsl:message>
  747. <xsl:value-of select="count($etargets)"/>
  748. <xsl:text>Endterm points to nonexistent ID: </xsl:text>
  749. <xsl:value-of select="@endterm"/>
  750. </xsl:message>
  751. <xsl:text>???</xsl:text>
  752. </xsl:when>
  753. <xsl:otherwise>
  754. <xsl:apply-templates select="$etarget" mode="endterm"/>
  755. </xsl:otherwise>
  756. </xsl:choose>
  757. </xsl:when>
  758. <!-- Use the xlink:href if no other text -->
  759. <xsl:when test="@xlink:href">
  760. <xsl:value-of select="@xlink:href"/>
  761. </xsl:when>
  762. <xsl:otherwise>
  763. <xsl:message>
  764. <xsl:text>Link element has no content and no Endterm. </xsl:text>
  765. <xsl:text>Nothing to show in the link to </xsl:text>
  766. <xsl:value-of select="(@xlink:href|@linkend)[1]"/>
  767. </xsl:message>
  768. <xsl:text>???</xsl:text>
  769. </xsl:otherwise>
  770. </xsl:choose>
  771. </xsl:variable>
  772. <xsl:call-template name="simple.xlink">
  773. <xsl:with-param name="node" select="."/>
  774. <xsl:with-param name="linkend" select="$linkend"/>
  775. <xsl:with-param name="content" select="$content"/>
  776. <xsl:with-param name="a.target" select="$a.target"/>
  777. <xsl:with-param name="xhref" select="$xhref"/>
  778. </xsl:call-template>
  779. </xsl:template>
  780. <xsl:template match="ulink" name="ulink">
  781. <xsl:param name="url" select="@url"/>
  782. <xsl:variable name="link">
  783. <a>
  784. <xsl:apply-templates select="." mode="class.attribute"/>
  785. <xsl:if test="@id or @xml:id">
  786. <xsl:attribute name="id">
  787. <xsl:value-of select="(@id|@xml:id)[1]"/>
  788. </xsl:attribute>
  789. </xsl:if>
  790. <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
  791. <xsl:if test="$ulink.target != ''">
  792. <xsl:attribute name="target">
  793. <xsl:value-of select="$ulink.target"/>
  794. </xsl:attribute>
  795. </xsl:if>
  796. <xsl:choose>
  797. <xsl:when test="count(child::node())=0">
  798. <xsl:value-of select="$url"/>
  799. </xsl:when>
  800. <xsl:otherwise>
  801. <xsl:apply-templates/>
  802. </xsl:otherwise>
  803. </xsl:choose>
  804. </a>
  805. </xsl:variable>
  806. <xsl:choose>
  807. <xsl:when test="function-available('suwl:unwrapLinks')">
  808. <xsl:copy-of select="suwl:unwrapLinks($link)"/>
  809. </xsl:when>
  810. <xsl:otherwise>
  811. <xsl:copy-of select="$link"/>
  812. </xsl:otherwise>
  813. </xsl:choose>
  814. </xsl:template>
  815. <xsl:template match="olink" name="olink">
  816. <!-- olink content may be passed in from xlink olink -->
  817. <xsl:param name="content" select="NOTANELEMENT"/>
  818. <xsl:call-template name="anchor"/>
  819. <xsl:variable name="localinfo" select="@localinfo"/>
  820. <xsl:choose>
  821. <!-- olinks resolved by stylesheet and target database -->
  822. <xsl:when test="@targetdoc or @targetptr or (@xlink:role=$xolink.role and contains(@xlink:href, '#') )">
  823. <xsl:variable name="targetdoc.att">
  824. <xsl:choose>
  825. <xsl:when test="@targetdoc != ''">
  826. <xsl:value-of select="@targetdoc"/>
  827. </xsl:when>
  828. <xsl:when test="@xlink:role=$xolink.role and contains(@xlink:href, '#')">
  829. <xsl:value-of select="substring-before(@xlink:href, '#')"/>
  830. </xsl:when>
  831. </xsl:choose>
  832. </xsl:variable>
  833. <xsl:variable name="targetptr.att">
  834. <xsl:choose>
  835. <xsl:when test="@targetptr != ''">
  836. <xsl:value-of select="@targetptr"/>
  837. </xsl:when>
  838. <xsl:when test="@xlink:role=$xolink.role and contains(@xlink:href, '#')">
  839. <xsl:value-of select="substring-after(@xlink:href, '#')"/>
  840. </xsl:when>
  841. </xsl:choose>
  842. </xsl:variable>
  843. <xsl:variable name="olink.lang">
  844. <xsl:call-template name="l10n.language">
  845. <xsl:with-param name="xref-context" select="true()"/>
  846. </xsl:call-template>
  847. </xsl:variable>
  848. <xsl:variable name="target.database.filename">
  849. <xsl:call-template name="select.target.database">
  850. <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
  851. <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
  852. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  853. </xsl:call-template>
  854. </xsl:variable>
  855. <xsl:variable name="target.database" select="document($target.database.filename,/)"/>
  856. <xsl:if test="$olink.debug != 0">
  857. <xsl:message>
  858. <xsl:text>Olink debug: root element of target.database '</xsl:text>
  859. <xsl:value-of select="$target.database.filename"/>
  860. <xsl:text>' is '</xsl:text>
  861. <xsl:value-of select="local-name($target.database/*[1])"/>
  862. <xsl:text>'.</xsl:text>
  863. </xsl:message>
  864. </xsl:if>
  865. <xsl:variable name="olink.key">
  866. <xsl:call-template name="select.olink.key">
  867. <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
  868. <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
  869. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  870. <xsl:with-param name="target.database" select="$target.database"/>
  871. </xsl:call-template>
  872. </xsl:variable>
  873. <xsl:if test="string-length($olink.key) = 0">
  874. <xsl:message>
  875. <xsl:text>Error: unresolved olink: </xsl:text>
  876. <xsl:text>targetdoc/targetptr = '</xsl:text>
  877. <xsl:value-of select="$targetdoc.att"/>
  878. <xsl:text>/</xsl:text>
  879. <xsl:value-of select="$targetptr.att"/>
  880. <xsl:text>'.</xsl:text>
  881. </xsl:message>
  882. </xsl:if>
  883. <xsl:variable name="href">
  884. <xsl:call-template name="make.olink.href">
  885. <xsl:with-param name="olink.key" select="$olink.key"/>
  886. <xsl:with-param name="target.database" select="$target.database"/>
  887. </xsl:call-template>
  888. </xsl:variable>
  889. <xsl:variable name="hottext">
  890. <xsl:choose>
  891. <xsl:when test="$content">
  892. <xsl:copy-of select="$content"/>
  893. </xsl:when>
  894. <xsl:otherwise>
  895. <xsl:call-template name="olink.hottext">
  896. <xsl:with-param name="olink.key" select="$olink.key"/>
  897. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  898. <xsl:with-param name="target.database" select="$target.database"/>
  899. </xsl:call-template>
  900. </xsl:otherwise>
  901. </xsl:choose>
  902. </xsl:variable>
  903. <xsl:variable name="olink.docname.citation">
  904. <xsl:call-template name="olink.document.citation">
  905. <xsl:with-param name="olink.key" select="$olink.key"/>
  906. <xsl:with-param name="target.database" select="$target.database"/>
  907. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  908. </xsl:call-template>
  909. </xsl:variable>
  910. <xsl:variable name="olink.page.citation">
  911. <xsl:call-template name="olink.page.citation">
  912. <xsl:with-param name="olink.key" select="$olink.key"/>
  913. <xsl:with-param name="target.database" select="$target.database"/>
  914. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  915. </xsl:call-template>
  916. </xsl:variable>
  917. <xsl:choose>
  918. <xsl:when test="$href != ''">
  919. <a href="{$href}">
  920. <xsl:apply-templates select="." mode="class.attribute"/>
  921. <xsl:copy-of select="$hottext"/>
  922. </a>
  923. <xsl:copy-of select="$olink.page.citation"/>
  924. <xsl:copy-of select="$olink.docname.citation"/>
  925. </xsl:when>
  926. <xsl:otherwise>
  927. <span class="olink"><xsl:copy-of select="$hottext"/></span>
  928. <xsl:copy-of select="$olink.page.citation"/>
  929. <xsl:copy-of select="$olink.docname.citation"/>
  930. </xsl:otherwise>
  931. </xsl:choose>
  932. </xsl:when>
  933. <!-- Or use old olink mechanism -->
  934. <xsl:otherwise>
  935. <xsl:variable name="href">
  936. <xsl:choose>
  937. <xsl:when test="@linkmode">
  938. <!-- use the linkmode to get the base URI, use localinfo as fragid -->
  939. <xsl:variable name="modespec" select="key('id',@linkmode)"/>
  940. <xsl:if test="count($modespec) != 1 or local-name($modespec) != 'modespec'">
  941. <xsl:message>Warning: olink linkmode pointer is wrong.</xsl:message>
  942. </xsl:if>
  943. <xsl:value-of select="$modespec"/>
  944. <xsl:if test="@localinfo">
  945. <xsl:text>#</xsl:text>
  946. <xsl:value-of select="@localinfo"/>
  947. </xsl:if>
  948. </xsl:when>
  949. <xsl:when test="@type = 'href'">
  950. <xsl:call-template name="olink.outline">
  951. <xsl:with-param name="outline.base.uri" select="unparsed-entity-uri(@targetdocent)"/>
  952. <xsl:with-param name="localinfo" select="@localinfo"/>
  953. <xsl:with-param name="return" select="'href'"/>
  954. </xsl:call-template>
  955. </xsl:when>
  956. <xsl:otherwise>
  957. <xsl:value-of select="$olink.resolver"/>
  958. <xsl:text>?</xsl:text>
  959. <xsl:value-of select="$olink.sysid"/>
  960. <xsl:value-of select="unparsed-entity-uri(@targetdocent)"/>
  961. <!-- XSL gives no access to the public identifier (grumble...) -->
  962. <xsl:if test="@localinfo">
  963. <xsl:text>&amp;</xsl:text>
  964. <xsl:value-of select="$olink.fragid"/>
  965. <xsl:value-of select="@localinfo"/>
  966. </xsl:if>
  967. </xsl:otherwise>
  968. </xsl:choose>
  969. </xsl:variable>
  970. <xsl:choose>
  971. <xsl:when test="$href != ''">
  972. <a href="{$href}">
  973. <xsl:apply-templates select="." mode="class.attribute"/>
  974. <xsl:call-template name="olink.hottext"/>
  975. </a>
  976. </xsl:when>
  977. <xsl:otherwise>
  978. <xsl:call-template name="olink.hottext"/>
  979. </xsl:otherwise>
  980. </xsl:choose>
  981. </xsl:otherwise>
  982. </xsl:choose>
  983. </xsl:template>
  984. <xsl:template match="*" mode="pagenumber.markup">
  985. <!-- no-op in HTML -->
  986. </xsl:template>
  987. <xsl:template name="olink.outline">
  988. <xsl:param name="outline.base.uri"/>
  989. <xsl:param name="localinfo"/>
  990. <xsl:param name="return" select="href"/>
  991. <xsl:variable name="outline-file" select="concat($outline.base.uri, $olink.outline.ext)"/>
  992. <xsl:variable name="outline" select="document($outline-file,.)/div"/>
  993. <xsl:variable name="node-href">
  994. <xsl:choose>
  995. <xsl:when test="$localinfo != ''">
  996. <xsl:variable name="node" select="$outline// *[@id=$localinfo or @xml:id=$localinfo]"/>
  997. <xsl:value-of select="$node/@href"/>
  998. </xsl:when>
  999. <xsl:otherwise>
  1000. <xsl:value-of select="$outline/@href"/>
  1001. </xsl:otherwise>
  1002. </xsl:choose>
  1003. </xsl:variable>
  1004. <xsl:variable name="node-xref">
  1005. <xsl:choose>
  1006. <xsl:when test="$localinfo != ''">
  1007. <xsl:variable name="node" select="$outline// *[@id=$localinfo or @xml:id=$localinfo]"/>
  1008. <xsl:copy-of select="$node/xref"/>
  1009. </xsl:when>
  1010. <xsl:otherwise>
  1011. <xsl:value-of select="$outline/xref"/>
  1012. </xsl:otherwise>
  1013. </xsl:choose>
  1014. </xsl:variable>
  1015. <xsl:choose>
  1016. <xsl:when test="$return = 'href'">
  1017. <xsl:value-of select="$node-href"/>
  1018. </xsl:when>
  1019. <xsl:when test="$return = 'xref'">
  1020. <xsl:value-of select="$node-xref"/>
  1021. </xsl:when>
  1022. <xsl:otherwise>
  1023. <xsl:copy-of select="$node-xref"/>
  1024. </xsl:otherwise>
  1025. </xsl:choose>
  1026. </xsl:template>
  1027. <!-- ==================================================================== -->
  1028. <xsl:template name="xref.xreflabel">
  1029. <!-- called to process an xreflabel...you might use this to make -->
  1030. <!-- xreflabels come out in the right font for different targets, -->
  1031. <!-- for example. -->
  1032. <xsl:param name="target" select="."/>
  1033. <xsl:value-of select="$target/@xreflabel"/>
  1034. </xsl:template>
  1035. <!-- ==================================================================== -->
  1036. <xsl:template match="title" mode="xref">
  1037. <xsl:apply-templates/>
  1038. </xsl:template>
  1039. <xsl:template match="command" mode="xref">
  1040. <xsl:call-template name="inline.boldseq"/>
  1041. </xsl:template>
  1042. <xsl:template match="function" mode="xref">
  1043. <xsl:call-template name="inline.monoseq"/>
  1044. </xsl:template>
  1045. <!-- ==================================================================== -->
  1046. <xsl:template match="*" mode="insert.title.markup">
  1047. <xsl:param name="purpose"/>
  1048. <xsl:param name="xrefstyle"/>
  1049. <xsl:param name="title"/>
  1050. <xsl:choose>
  1051. <!-- FIXME: what about the case where titleabbrev is inside the info? -->
  1052. <xsl:when test="$purpose = 'xref' and titleabbrev">
  1053. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  1054. </xsl:when>
  1055. <xsl:otherwise>
  1056. <xsl:copy-of select="$title"/>
  1057. </xsl:otherwise>
  1058. </xsl:choose>
  1059. </xsl:template>
  1060. <xsl:template match="chapter|appendix" mode="insert.title.markup">
  1061. <xsl:param name="purpose"/>
  1062. <xsl:param name="xrefstyle"/>
  1063. <xsl:param name="title"/>
  1064. <xsl:choose>
  1065. <xsl:when test="$purpose = 'xref'">
  1066. <i>
  1067. <xsl:copy-of select="$title"/>
  1068. </i>
  1069. </xsl:when>
  1070. <xsl:otherwise>
  1071. <xsl:copy-of select="$title"/>
  1072. </xsl:otherwise>
  1073. </xsl:choose>
  1074. </xsl:template>
  1075. <xsl:template match="*" mode="insert.subtitle.markup">
  1076. <xsl:param name="purpose"/>
  1077. <xsl:param name="xrefstyle"/>
  1078. <xsl:param name="subtitle"/>
  1079. <xsl:copy-of select="$subtitle"/>
  1080. </xsl:template>
  1081. <xsl:template match="*" mode="insert.label.markup">
  1082. <xsl:param name="purpose"/>
  1083. <xsl:param name="xrefstyle"/>
  1084. <xsl:param name="label"/>
  1085. <xsl:copy-of select="$label"/>
  1086. </xsl:template>
  1087. <xsl:template match="*" mode="insert.pagenumber.markup">
  1088. <xsl:param name="purpose"/>
  1089. <xsl:param name="xrefstyle"/>
  1090. <xsl:param name="pagenumber"/>
  1091. <xsl:copy-of select="$pagenumber"/>
  1092. </xsl:template>
  1093. <xsl:template match="*" mode="insert.direction.markup">
  1094. <xsl:param name="purpose"/>
  1095. <xsl:param name="xrefstyle"/>
  1096. <xsl:param name="direction"/>
  1097. <xsl:copy-of select="$direction"/>
  1098. </xsl:template>
  1099. <xsl:template match="*" mode="insert.olink.docname.markup">
  1100. <xsl:param name="purpose"/>
  1101. <xsl:param name="xrefstyle"/>
  1102. <xsl:param name="docname"/>
  1103. <span class="olinkdocname">
  1104. <xsl:copy-of select="$docname"/>
  1105. </span>
  1106. </xsl:template>
  1107. </xsl:stylesheet>