xref.xsl 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  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:variable name="content">
  733. <xsl:call-template name="anchor"/>
  734. <xsl:choose>
  735. <xsl:when test="count(child::node()) &gt; 0">
  736. <!-- If it has content, use it -->
  737. <xsl:apply-templates/>
  738. </xsl:when>
  739. <!-- else look for an endterm -->
  740. <xsl:when test="@endterm">
  741. <xsl:variable name="etargets" select="key('id',@endterm)"/>
  742. <xsl:variable name="etarget" select="$etargets[1]"/>
  743. <xsl:choose>
  744. <xsl:when test="count($etarget) = 0">
  745. <xsl:message>
  746. <xsl:value-of select="count($etargets)"/>
  747. <xsl:text>Endterm points to nonexistent ID: </xsl:text>
  748. <xsl:value-of select="@endterm"/>
  749. </xsl:message>
  750. <xsl:text>???</xsl:text>
  751. </xsl:when>
  752. <xsl:otherwise>
  753. <xsl:apply-templates select="$etarget" mode="endterm"/>
  754. </xsl:otherwise>
  755. </xsl:choose>
  756. </xsl:when>
  757. <!-- Use the xlink:href if no other text -->
  758. <xsl:when test="@xlink:href">
  759. <xsl:value-of select="@xlink:href"/>
  760. </xsl:when>
  761. <xsl:otherwise>
  762. <xsl:message>
  763. <xsl:text>Link element has no content and no Endterm. </xsl:text>
  764. <xsl:text>Nothing to show in the link to </xsl:text>
  765. <xsl:value-of select="(@xlink:href|@linkend)[1]"/>
  766. </xsl:message>
  767. <xsl:text>???</xsl:text>
  768. </xsl:otherwise>
  769. </xsl:choose>
  770. </xsl:variable>
  771. <xsl:call-template name="simple.xlink">
  772. <xsl:with-param name="node" select="."/>
  773. <xsl:with-param name="linkend" select="$linkend"/>
  774. <xsl:with-param name="content" select="$content"/>
  775. <xsl:with-param name="a.target" select="$a.target"/>
  776. </xsl:call-template>
  777. </xsl:template>
  778. <xsl:template match="ulink" name="ulink">
  779. <xsl:param name="url" select="@url"/>
  780. <xsl:variable name="link">
  781. <a>
  782. <xsl:apply-templates select="." mode="class.attribute"/>
  783. <xsl:if test="@id or @xml:id">
  784. <xsl:attribute name="id">
  785. <xsl:value-of select="(@id|@xml:id)[1]"/>
  786. </xsl:attribute>
  787. </xsl:if>
  788. <xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
  789. <xsl:if test="$ulink.target != ''">
  790. <xsl:attribute name="target">
  791. <xsl:value-of select="$ulink.target"/>
  792. </xsl:attribute>
  793. </xsl:if>
  794. <xsl:choose>
  795. <xsl:when test="count(child::node())=0">
  796. <xsl:value-of select="$url"/>
  797. </xsl:when>
  798. <xsl:otherwise>
  799. <xsl:apply-templates/>
  800. </xsl:otherwise>
  801. </xsl:choose>
  802. </a>
  803. </xsl:variable>
  804. <xsl:choose>
  805. <xsl:when test="function-available('suwl:unwrapLinks')">
  806. <xsl:copy-of select="suwl:unwrapLinks($link)"/>
  807. </xsl:when>
  808. <xsl:otherwise>
  809. <xsl:copy-of select="$link"/>
  810. </xsl:otherwise>
  811. </xsl:choose>
  812. </xsl:template>
  813. <xsl:template match="olink" name="olink">
  814. <!-- olink content may be passed in from xlink olink -->
  815. <xsl:param name="content" select="NOTANELEMENT"/>
  816. <xsl:call-template name="anchor"/>
  817. <xsl:variable name="localinfo" select="@localinfo"/>
  818. <xsl:choose>
  819. <!-- olinks resolved by stylesheet and target database -->
  820. <xsl:when test="@targetdoc or @targetptr or (@xlink:role=$xolink.role and contains(@xlink:href, '#') )">
  821. <xsl:variable name="targetdoc.att">
  822. <xsl:choose>
  823. <xsl:when test="@targetdoc != ''">
  824. <xsl:value-of select="@targetdoc"/>
  825. </xsl:when>
  826. <xsl:when test="@xlink:role=$xolink.role and contains(@xlink:href, '#')">
  827. <xsl:value-of select="substring-before(@xlink:href, '#')"/>
  828. </xsl:when>
  829. </xsl:choose>
  830. </xsl:variable>
  831. <xsl:variable name="targetptr.att">
  832. <xsl:choose>
  833. <xsl:when test="@targetptr != ''">
  834. <xsl:value-of select="@targetptr"/>
  835. </xsl:when>
  836. <xsl:when test="@xlink:role=$xolink.role and contains(@xlink:href, '#')">
  837. <xsl:value-of select="substring-after(@xlink:href, '#')"/>
  838. </xsl:when>
  839. </xsl:choose>
  840. </xsl:variable>
  841. <xsl:variable name="olink.lang">
  842. <xsl:call-template name="l10n.language">
  843. <xsl:with-param name="xref-context" select="true()"/>
  844. </xsl:call-template>
  845. </xsl:variable>
  846. <xsl:variable name="target.database.filename">
  847. <xsl:call-template name="select.target.database">
  848. <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
  849. <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
  850. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  851. </xsl:call-template>
  852. </xsl:variable>
  853. <xsl:variable name="target.database" select="document($target.database.filename,/)"/>
  854. <xsl:if test="$olink.debug != 0">
  855. <xsl:message>
  856. <xsl:text>Olink debug: root element of target.database '</xsl:text>
  857. <xsl:value-of select="$target.database.filename"/>
  858. <xsl:text>' is '</xsl:text>
  859. <xsl:value-of select="local-name($target.database/*[1])"/>
  860. <xsl:text>'.</xsl:text>
  861. </xsl:message>
  862. </xsl:if>
  863. <xsl:variable name="olink.key">
  864. <xsl:call-template name="select.olink.key">
  865. <xsl:with-param name="targetdoc.att" select="$targetdoc.att"/>
  866. <xsl:with-param name="targetptr.att" select="$targetptr.att"/>
  867. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  868. <xsl:with-param name="target.database" select="$target.database"/>
  869. </xsl:call-template>
  870. </xsl:variable>
  871. <xsl:if test="string-length($olink.key) = 0">
  872. <xsl:message>
  873. <xsl:text>Error: unresolved olink: </xsl:text>
  874. <xsl:text>targetdoc/targetptr = '</xsl:text>
  875. <xsl:value-of select="$targetdoc.att"/>
  876. <xsl:text>/</xsl:text>
  877. <xsl:value-of select="$targetptr.att"/>
  878. <xsl:text>'.</xsl:text>
  879. </xsl:message>
  880. </xsl:if>
  881. <xsl:variable name="href">
  882. <xsl:call-template name="make.olink.href">
  883. <xsl:with-param name="olink.key" select="$olink.key"/>
  884. <xsl:with-param name="target.database" select="$target.database"/>
  885. </xsl:call-template>
  886. </xsl:variable>
  887. <xsl:variable name="hottext">
  888. <xsl:choose>
  889. <xsl:when test="$content">
  890. <xsl:copy-of select="$content"/>
  891. </xsl:when>
  892. <xsl:otherwise>
  893. <xsl:call-template name="olink.hottext">
  894. <xsl:with-param name="olink.key" select="$olink.key"/>
  895. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  896. <xsl:with-param name="target.database" select="$target.database"/>
  897. </xsl:call-template>
  898. </xsl:otherwise>
  899. </xsl:choose>
  900. </xsl:variable>
  901. <xsl:variable name="olink.docname.citation">
  902. <xsl:call-template name="olink.document.citation">
  903. <xsl:with-param name="olink.key" select="$olink.key"/>
  904. <xsl:with-param name="target.database" select="$target.database"/>
  905. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  906. </xsl:call-template>
  907. </xsl:variable>
  908. <xsl:variable name="olink.page.citation">
  909. <xsl:call-template name="olink.page.citation">
  910. <xsl:with-param name="olink.key" select="$olink.key"/>
  911. <xsl:with-param name="target.database" select="$target.database"/>
  912. <xsl:with-param name="olink.lang" select="$olink.lang"/>
  913. </xsl:call-template>
  914. </xsl:variable>
  915. <xsl:choose>
  916. <xsl:when test="$href != ''">
  917. <a href="{$href}">
  918. <xsl:apply-templates select="." mode="class.attribute"/>
  919. <xsl:copy-of select="$hottext"/>
  920. </a>
  921. <xsl:copy-of select="$olink.page.citation"/>
  922. <xsl:copy-of select="$olink.docname.citation"/>
  923. </xsl:when>
  924. <xsl:otherwise>
  925. <span class="olink"><xsl:copy-of select="$hottext"/></span>
  926. <xsl:copy-of select="$olink.page.citation"/>
  927. <xsl:copy-of select="$olink.docname.citation"/>
  928. </xsl:otherwise>
  929. </xsl:choose>
  930. </xsl:when>
  931. <!-- Or use old olink mechanism -->
  932. <xsl:otherwise>
  933. <xsl:variable name="href">
  934. <xsl:choose>
  935. <xsl:when test="@linkmode">
  936. <!-- use the linkmode to get the base URI, use localinfo as fragid -->
  937. <xsl:variable name="modespec" select="key('id',@linkmode)"/>
  938. <xsl:if test="count($modespec) != 1 or local-name($modespec) != 'modespec'">
  939. <xsl:message>Warning: olink linkmode pointer is wrong.</xsl:message>
  940. </xsl:if>
  941. <xsl:value-of select="$modespec"/>
  942. <xsl:if test="@localinfo">
  943. <xsl:text>#</xsl:text>
  944. <xsl:value-of select="@localinfo"/>
  945. </xsl:if>
  946. </xsl:when>
  947. <xsl:when test="@type = 'href'">
  948. <xsl:call-template name="olink.outline">
  949. <xsl:with-param name="outline.base.uri" select="unparsed-entity-uri(@targetdocent)"/>
  950. <xsl:with-param name="localinfo" select="@localinfo"/>
  951. <xsl:with-param name="return" select="'href'"/>
  952. </xsl:call-template>
  953. </xsl:when>
  954. <xsl:otherwise>
  955. <xsl:value-of select="$olink.resolver"/>
  956. <xsl:text>?</xsl:text>
  957. <xsl:value-of select="$olink.sysid"/>
  958. <xsl:value-of select="unparsed-entity-uri(@targetdocent)"/>
  959. <!-- XSL gives no access to the public identifier (grumble...) -->
  960. <xsl:if test="@localinfo">
  961. <xsl:text>&amp;</xsl:text>
  962. <xsl:value-of select="$olink.fragid"/>
  963. <xsl:value-of select="@localinfo"/>
  964. </xsl:if>
  965. </xsl:otherwise>
  966. </xsl:choose>
  967. </xsl:variable>
  968. <xsl:choose>
  969. <xsl:when test="$href != ''">
  970. <a href="{$href}">
  971. <xsl:apply-templates select="." mode="class.attribute"/>
  972. <xsl:call-template name="olink.hottext"/>
  973. </a>
  974. </xsl:when>
  975. <xsl:otherwise>
  976. <xsl:call-template name="olink.hottext"/>
  977. </xsl:otherwise>
  978. </xsl:choose>
  979. </xsl:otherwise>
  980. </xsl:choose>
  981. </xsl:template>
  982. <xsl:template match="*" mode="pagenumber.markup">
  983. <!-- no-op in HTML -->
  984. </xsl:template>
  985. <xsl:template name="olink.outline">
  986. <xsl:param name="outline.base.uri"/>
  987. <xsl:param name="localinfo"/>
  988. <xsl:param name="return" select="href"/>
  989. <xsl:variable name="outline-file" select="concat($outline.base.uri, $olink.outline.ext)"/>
  990. <xsl:variable name="outline" select="document($outline-file,.)/div"/>
  991. <xsl:variable name="node-href">
  992. <xsl:choose>
  993. <xsl:when test="$localinfo != ''">
  994. <xsl:variable name="node" select="$outline// *[@id=$localinfo or @xml:id=$localinfo]"/>
  995. <xsl:value-of select="$node/@href"/>
  996. </xsl:when>
  997. <xsl:otherwise>
  998. <xsl:value-of select="$outline/@href"/>
  999. </xsl:otherwise>
  1000. </xsl:choose>
  1001. </xsl:variable>
  1002. <xsl:variable name="node-xref">
  1003. <xsl:choose>
  1004. <xsl:when test="$localinfo != ''">
  1005. <xsl:variable name="node" select="$outline// *[@id=$localinfo or @xml:id=$localinfo]"/>
  1006. <xsl:copy-of select="$node/xref"/>
  1007. </xsl:when>
  1008. <xsl:otherwise>
  1009. <xsl:value-of select="$outline/xref"/>
  1010. </xsl:otherwise>
  1011. </xsl:choose>
  1012. </xsl:variable>
  1013. <xsl:choose>
  1014. <xsl:when test="$return = 'href'">
  1015. <xsl:value-of select="$node-href"/>
  1016. </xsl:when>
  1017. <xsl:when test="$return = 'xref'">
  1018. <xsl:value-of select="$node-xref"/>
  1019. </xsl:when>
  1020. <xsl:otherwise>
  1021. <xsl:copy-of select="$node-xref"/>
  1022. </xsl:otherwise>
  1023. </xsl:choose>
  1024. </xsl:template>
  1025. <!-- ==================================================================== -->
  1026. <xsl:template name="xref.xreflabel">
  1027. <!-- called to process an xreflabel...you might use this to make -->
  1028. <!-- xreflabels come out in the right font for different targets, -->
  1029. <!-- for example. -->
  1030. <xsl:param name="target" select="."/>
  1031. <xsl:value-of select="$target/@xreflabel"/>
  1032. </xsl:template>
  1033. <!-- ==================================================================== -->
  1034. <xsl:template match="title" mode="xref">
  1035. <xsl:apply-templates/>
  1036. </xsl:template>
  1037. <xsl:template match="command" mode="xref">
  1038. <xsl:call-template name="inline.boldseq"/>
  1039. </xsl:template>
  1040. <xsl:template match="function" mode="xref">
  1041. <xsl:call-template name="inline.monoseq"/>
  1042. </xsl:template>
  1043. <!-- ==================================================================== -->
  1044. <xsl:template match="*" mode="insert.title.markup">
  1045. <xsl:param name="purpose"/>
  1046. <xsl:param name="xrefstyle"/>
  1047. <xsl:param name="title"/>
  1048. <xsl:choose>
  1049. <!-- FIXME: what about the case where titleabbrev is inside the info? -->
  1050. <xsl:when test="$purpose = 'xref' and titleabbrev">
  1051. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  1052. </xsl:when>
  1053. <xsl:otherwise>
  1054. <xsl:copy-of select="$title"/>
  1055. </xsl:otherwise>
  1056. </xsl:choose>
  1057. </xsl:template>
  1058. <xsl:template match="chapter|appendix" mode="insert.title.markup">
  1059. <xsl:param name="purpose"/>
  1060. <xsl:param name="xrefstyle"/>
  1061. <xsl:param name="title"/>
  1062. <xsl:choose>
  1063. <xsl:when test="$purpose = 'xref'">
  1064. <i>
  1065. <xsl:copy-of select="$title"/>
  1066. </i>
  1067. </xsl:when>
  1068. <xsl:otherwise>
  1069. <xsl:copy-of select="$title"/>
  1070. </xsl:otherwise>
  1071. </xsl:choose>
  1072. </xsl:template>
  1073. <xsl:template match="*" mode="insert.subtitle.markup">
  1074. <xsl:param name="purpose"/>
  1075. <xsl:param name="xrefstyle"/>
  1076. <xsl:param name="subtitle"/>
  1077. <xsl:copy-of select="$subtitle"/>
  1078. </xsl:template>
  1079. <xsl:template match="*" mode="insert.label.markup">
  1080. <xsl:param name="purpose"/>
  1081. <xsl:param name="xrefstyle"/>
  1082. <xsl:param name="label"/>
  1083. <xsl:copy-of select="$label"/>
  1084. </xsl:template>
  1085. <xsl:template match="*" mode="insert.pagenumber.markup">
  1086. <xsl:param name="purpose"/>
  1087. <xsl:param name="xrefstyle"/>
  1088. <xsl:param name="pagenumber"/>
  1089. <xsl:copy-of select="$pagenumber"/>
  1090. </xsl:template>
  1091. <xsl:template match="*" mode="insert.direction.markup">
  1092. <xsl:param name="purpose"/>
  1093. <xsl:param name="xrefstyle"/>
  1094. <xsl:param name="direction"/>
  1095. <xsl:copy-of select="$direction"/>
  1096. </xsl:template>
  1097. <xsl:template match="*" mode="insert.olink.docname.markup">
  1098. <xsl:param name="purpose"/>
  1099. <xsl:param name="xrefstyle"/>
  1100. <xsl:param name="docname"/>
  1101. <span class="olinkdocname">
  1102. <xsl:copy-of select="$docname"/>
  1103. </span>
  1104. </xsl:template>
  1105. </xsl:stylesheet>