xref.xsl 49 KB

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