xref.xsl 44 KB

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