xref.xsl 45 KB

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