xref.xsl 45 KB

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