titles.xsl 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  4. xmlns:xlink="http://www.w3.org/1999/xlink"
  5. exclude-result-prefixes="doc"
  6. version='1.0'>
  7. <!-- ********************************************************************
  8. $Id: titles.xsl 9715 2013-01-24 00:16:57Z bobstayton $
  9. ********************************************************************
  10. This file is part of the XSL DocBook Stylesheet distribution.
  11. See ../README or http://docbook.sf.net/release/xsl/current/ for
  12. copyright and other information.
  13. ******************************************************************** -->
  14. <!-- ==================================================================== -->
  15. <!-- title markup -->
  16. <doc:mode mode="title.markup" xmlns="">
  17. <refpurpose>Provides access to element titles</refpurpose>
  18. <refdescription id="title.markup-desc">
  19. <para>Processing an element in the
  20. <literal role="mode">title.markup</literal> mode produces the
  21. title of the element. This does not include the label.
  22. </para>
  23. </refdescription>
  24. </doc:mode>
  25. <xsl:template match="*" mode="title.markup">
  26. <xsl:param name="allow-anchors" select="0"/>
  27. <xsl:param name="verbose" select="1"/>
  28. <xsl:choose>
  29. <!-- * FIXME: this should handle other *info elements as well -->
  30. <!-- * but this is good enough for now. -->
  31. <xsl:when test="title|info/title">
  32. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  33. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  34. </xsl:apply-templates>
  35. </xsl:when>
  36. <xsl:when test="local-name(.) = 'partintro'">
  37. <!-- partintro's don't have titles, use the parent (part or reference)
  38. title instead. -->
  39. <xsl:apply-templates select="parent::*" mode="title.markup"/>
  40. </xsl:when>
  41. <xsl:otherwise>
  42. <xsl:if test="$verbose != 0">
  43. <xsl:message>
  44. <xsl:text>Request for title of element with no title: </xsl:text>
  45. <xsl:value-of select="local-name(.)"/>
  46. <xsl:choose>
  47. <xsl:when test="@id">
  48. <xsl:text> (id="</xsl:text>
  49. <xsl:value-of select="@id"/>
  50. <xsl:text>")</xsl:text>
  51. </xsl:when>
  52. <xsl:when test="@xml:id">
  53. <xsl:text> (xml:id="</xsl:text>
  54. <xsl:value-of select="@xml:id"/>
  55. <xsl:text>")</xsl:text>
  56. </xsl:when>
  57. <xsl:otherwise>
  58. <xsl:text> (contained in </xsl:text>
  59. <xsl:value-of select="local-name(..)"/>
  60. <xsl:if test="../@id or ../@xml:id">
  61. <xsl:text> with id </xsl:text>
  62. <xsl:value-of select="../@id | ../@xml:id"/>
  63. </xsl:if>
  64. <xsl:text>)</xsl:text>
  65. </xsl:otherwise>
  66. </xsl:choose>
  67. </xsl:message>
  68. </xsl:if>
  69. <xsl:text>???TITLE???</xsl:text>
  70. </xsl:otherwise>
  71. </xsl:choose>
  72. </xsl:template>
  73. <xsl:template match="title" mode="title.markup">
  74. <xsl:param name="allow-anchors" select="0"/>
  75. <xsl:choose>
  76. <xsl:when test="$allow-anchors != 0">
  77. <xsl:apply-templates/>
  78. </xsl:when>
  79. <xsl:otherwise>
  80. <xsl:apply-templates mode="no.anchor.mode"/>
  81. </xsl:otherwise>
  82. </xsl:choose>
  83. </xsl:template>
  84. <!-- only occurs in HTML Tables! -->
  85. <xsl:template match="caption" mode="title.markup">
  86. <xsl:param name="allow-anchors" select="0"/>
  87. <xsl:choose>
  88. <xsl:when test="$allow-anchors != 0">
  89. <xsl:apply-templates/>
  90. </xsl:when>
  91. <xsl:otherwise>
  92. <xsl:apply-templates mode="no.anchor.mode"/>
  93. </xsl:otherwise>
  94. </xsl:choose>
  95. </xsl:template>
  96. <xsl:template match="set" mode="title.markup">
  97. <xsl:param name="allow-anchors" select="0"/>
  98. <xsl:apply-templates select="(setinfo/title|info/title|title)[1]"
  99. mode="title.markup">
  100. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  101. </xsl:apply-templates>
  102. </xsl:template>
  103. <xsl:template match="book" mode="title.markup">
  104. <xsl:param name="allow-anchors" select="0"/>
  105. <xsl:apply-templates select="(bookinfo/title|info/title|title)[1]"
  106. mode="title.markup">
  107. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  108. </xsl:apply-templates>
  109. </xsl:template>
  110. <xsl:template match="part" mode="title.markup">
  111. <xsl:param name="allow-anchors" select="0"/>
  112. <xsl:apply-templates select="(partinfo/title|info/title|docinfo/title|title)[1]"
  113. mode="title.markup">
  114. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  115. </xsl:apply-templates>
  116. </xsl:template>
  117. <xsl:template match="preface|chapter|appendix" mode="title.markup">
  118. <xsl:param name="allow-anchors" select="0"/>
  119. <!--
  120. <xsl:message>
  121. <xsl:value-of select="local-name(.)"/>
  122. <xsl:text> </xsl:text>
  123. <xsl:value-of select="$allow-anchors"/>
  124. </xsl:message>
  125. -->
  126. <xsl:variable name="title" select="(docinfo/title
  127. |info/title
  128. |prefaceinfo/title
  129. |chapterinfo/title
  130. |appendixinfo/title
  131. |title)[1]"/>
  132. <xsl:apply-templates select="$title" mode="title.markup">
  133. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  134. </xsl:apply-templates>
  135. </xsl:template>
  136. <xsl:template match="dedication" mode="title.markup">
  137. <xsl:param name="allow-anchors" select="0"/>
  138. <xsl:choose>
  139. <xsl:when test="title|info/title">
  140. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  141. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  142. </xsl:apply-templates>
  143. </xsl:when>
  144. <xsl:otherwise>
  145. <xsl:call-template name="gentext">
  146. <xsl:with-param name="key" select="'Dedication'"/>
  147. </xsl:call-template>
  148. </xsl:otherwise>
  149. </xsl:choose>
  150. </xsl:template>
  151. <xsl:template match="acknowledgements" mode="title.markup">
  152. <xsl:param name="allow-anchors" select="0"/>
  153. <xsl:choose>
  154. <xsl:when test="title|info/title">
  155. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  156. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  157. </xsl:apply-templates>
  158. </xsl:when>
  159. <xsl:otherwise>
  160. <xsl:call-template name="gentext">
  161. <xsl:with-param name="key" select="'Acknowledgements'"/>
  162. </xsl:call-template>
  163. </xsl:otherwise>
  164. </xsl:choose>
  165. </xsl:template>
  166. <xsl:template match="colophon" mode="title.markup">
  167. <xsl:param name="allow-anchors" select="0"/>
  168. <xsl:choose>
  169. <xsl:when test="title|info/title">
  170. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  171. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  172. </xsl:apply-templates>
  173. </xsl:when>
  174. <xsl:otherwise>
  175. <xsl:call-template name="gentext">
  176. <xsl:with-param name="key" select="'Colophon'"/>
  177. </xsl:call-template>
  178. </xsl:otherwise>
  179. </xsl:choose>
  180. </xsl:template>
  181. <xsl:template match="article" mode="title.markup">
  182. <xsl:param name="allow-anchors" select="0"/>
  183. <xsl:variable name="title" select="(artheader/title
  184. |articleinfo/title
  185. |info/title
  186. |title)[1]"/>
  187. <xsl:apply-templates select="$title" mode="title.markup">
  188. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  189. </xsl:apply-templates>
  190. </xsl:template>
  191. <xsl:template match="reference" mode="title.markup">
  192. <xsl:param name="allow-anchors" select="0"/>
  193. <xsl:apply-templates select="(referenceinfo/title|docinfo/title|info/title|title)[1]"
  194. mode="title.markup">
  195. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  196. </xsl:apply-templates>
  197. </xsl:template>
  198. <xsl:template match="refentry" mode="title.markup">
  199. <xsl:param name="allow-anchors" select="0"/>
  200. <xsl:variable name="refmeta" select=".//refmeta"/>
  201. <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
  202. <xsl:variable name="refnamediv" select=".//refnamediv"/>
  203. <xsl:variable name="refname" select="$refnamediv//refname"/>
  204. <xsl:variable name="refdesc" select="$refnamediv//refdescriptor"/>
  205. <xsl:variable name="title">
  206. <xsl:choose>
  207. <xsl:when test="$refentrytitle">
  208. <xsl:apply-templates select="$refentrytitle[1]" mode="title.markup"/>
  209. </xsl:when>
  210. <xsl:when test="$refdesc">
  211. <xsl:apply-templates select="$refdesc" mode="title.markup"/>
  212. </xsl:when>
  213. <xsl:when test="$refname">
  214. <xsl:apply-templates select="$refname[1]" mode="title.markup"/>
  215. </xsl:when>
  216. <xsl:otherwise>REFENTRY WITHOUT TITLE???</xsl:otherwise>
  217. </xsl:choose>
  218. </xsl:variable>
  219. <xsl:copy-of select="$title"/>
  220. </xsl:template>
  221. <xsl:template match="refentrytitle|refname|refdescriptor" mode="title.markup">
  222. <xsl:param name="allow-anchors" select="0"/>
  223. <xsl:choose>
  224. <xsl:when test="$allow-anchors != 0">
  225. <xsl:apply-templates/>
  226. </xsl:when>
  227. <xsl:otherwise>
  228. <xsl:apply-templates mode="no.anchor.mode"/>
  229. </xsl:otherwise>
  230. </xsl:choose>
  231. </xsl:template>
  232. <xsl:template match="section
  233. |sect1|sect2|sect3|sect4|sect5
  234. |refsect1|refsect2|refsect3|refsection
  235. |topic
  236. |simplesect"
  237. mode="title.markup">
  238. <xsl:param name="allow-anchors" select="0"/>
  239. <xsl:variable name="title" select="(info/title
  240. |sectioninfo/title
  241. |sect1info/title
  242. |sect2info/title
  243. |sect3info/title
  244. |sect4info/title
  245. |sect5info/title
  246. |refsect1info/title
  247. |refsect2info/title
  248. |refsect3info/title
  249. |refsectioninfo/title
  250. |title)[1]"/>
  251. <xsl:apply-templates select="$title" mode="title.markup">
  252. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  253. </xsl:apply-templates>
  254. </xsl:template>
  255. <xsl:template match="bridgehead" mode="title.markup">
  256. <xsl:apply-templates/>
  257. </xsl:template>
  258. <xsl:template match="refsynopsisdiv" mode="title.markup">
  259. <xsl:param name="allow-anchors" select="0"/>
  260. <xsl:choose>
  261. <xsl:when test="title|info/title">
  262. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  263. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  264. </xsl:apply-templates>
  265. </xsl:when>
  266. <xsl:otherwise>
  267. <xsl:call-template name="gentext">
  268. <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
  269. </xsl:call-template>
  270. </xsl:otherwise>
  271. </xsl:choose>
  272. </xsl:template>
  273. <xsl:template match="bibliography" mode="title.markup">
  274. <xsl:param name="allow-anchors" select="0"/>
  275. <xsl:variable name="title" select="(bibliographyinfo/title|info/title|title)[1]"/>
  276. <xsl:choose>
  277. <xsl:when test="$title">
  278. <xsl:apply-templates select="$title" mode="title.markup">
  279. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  280. </xsl:apply-templates>
  281. </xsl:when>
  282. <xsl:otherwise>
  283. <xsl:call-template name="gentext">
  284. <xsl:with-param name="key" select="'Bibliography'"/>
  285. </xsl:call-template>
  286. </xsl:otherwise>
  287. </xsl:choose>
  288. </xsl:template>
  289. <xsl:template match="glossary" mode="title.markup">
  290. <xsl:param name="allow-anchors" select="0"/>
  291. <xsl:variable name="title" select="(glossaryinfo/title|info/title|title)[1]"/>
  292. <xsl:choose>
  293. <xsl:when test="$title">
  294. <xsl:apply-templates select="$title" mode="title.markup">
  295. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  296. </xsl:apply-templates>
  297. </xsl:when>
  298. <xsl:otherwise>
  299. <xsl:call-template name="gentext.element.name">
  300. <xsl:with-param name="element.name" select="local-name(.)"/>
  301. </xsl:call-template>
  302. </xsl:otherwise>
  303. </xsl:choose>
  304. </xsl:template>
  305. <xsl:template match="glossdiv" mode="title.markup">
  306. <xsl:param name="allow-anchors" select="0"/>
  307. <xsl:variable name="title" select="(info/title|title)[1]"/>
  308. <xsl:choose>
  309. <xsl:when test="$title">
  310. <xsl:apply-templates select="$title" mode="title.markup">
  311. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  312. </xsl:apply-templates>
  313. </xsl:when>
  314. <xsl:otherwise>
  315. <xsl:message>ERROR: glossdiv missing its required title</xsl:message>
  316. </xsl:otherwise>
  317. </xsl:choose>
  318. </xsl:template>
  319. <xsl:template match="glossentry" mode="title.markup">
  320. <xsl:param name="allow-anchors" select="0"/>
  321. <xsl:apply-templates select="glossterm" mode="title.markup">
  322. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  323. </xsl:apply-templates>
  324. </xsl:template>
  325. <xsl:template match="glossterm|firstterm" mode="title.markup">
  326. <xsl:param name="allow-anchors" select="0"/>
  327. <xsl:choose>
  328. <xsl:when test="$allow-anchors != 0">
  329. <xsl:apply-templates/>
  330. </xsl:when>
  331. <xsl:otherwise>
  332. <xsl:apply-templates mode="no.anchor.mode"/>
  333. </xsl:otherwise>
  334. </xsl:choose>
  335. </xsl:template>
  336. <xsl:template match="index" mode="title.markup">
  337. <xsl:param name="allow-anchors" select="0"/>
  338. <xsl:variable name="title" select="(indexinfo/title|info/title|title)[1]"/>
  339. <xsl:choose>
  340. <xsl:when test="$title">
  341. <xsl:apply-templates select="$title" mode="title.markup">
  342. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  343. </xsl:apply-templates>
  344. </xsl:when>
  345. <xsl:otherwise>
  346. <xsl:call-template name="gentext">
  347. <xsl:with-param name="key" select="'Index'"/>
  348. </xsl:call-template>
  349. </xsl:otherwise>
  350. </xsl:choose>
  351. </xsl:template>
  352. <xsl:template match="setindex" mode="title.markup">
  353. <xsl:param name="allow-anchors" select="0"/>
  354. <xsl:variable name="title" select="(setindexinfo/title|info/title|title)[1]"/>
  355. <xsl:choose>
  356. <xsl:when test="$title">
  357. <xsl:apply-templates select="$title" mode="title.markup">
  358. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  359. </xsl:apply-templates>
  360. </xsl:when>
  361. <xsl:otherwise>
  362. <xsl:call-template name="gentext">
  363. <xsl:with-param name="key" select="'SetIndex'"/>
  364. </xsl:call-template>
  365. </xsl:otherwise>
  366. </xsl:choose>
  367. </xsl:template>
  368. <xsl:template match="figure|example|equation" mode="title.markup">
  369. <xsl:param name="allow-anchors" select="0"/>
  370. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  371. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  372. </xsl:apply-templates>
  373. </xsl:template>
  374. <xsl:template match="table" mode="title.markup">
  375. <xsl:param name="allow-anchors" select="0"/>
  376. <xsl:apply-templates select="(title|info/title|caption)[1]" mode="title.markup">
  377. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  378. </xsl:apply-templates>
  379. </xsl:template>
  380. <xsl:template match="procedure" mode="title.markup">
  381. <xsl:param name="allow-anchors" select="0"/>
  382. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  383. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  384. </xsl:apply-templates>
  385. </xsl:template>
  386. <xsl:template match="task" mode="title.markup">
  387. <xsl:param name="allow-anchors" select="0"/>
  388. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  389. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  390. </xsl:apply-templates>
  391. </xsl:template>
  392. <xsl:template match="sidebar" mode="title.markup">
  393. <xsl:param name="allow-anchors" select="0"/>
  394. <xsl:apply-templates select="(info/title|sidebarinfo/title|title)[1]"
  395. mode="title.markup">
  396. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  397. </xsl:apply-templates>
  398. </xsl:template>
  399. <xsl:template match="abstract" mode="title.markup">
  400. <xsl:param name="allow-anchors" select="0"/>
  401. <xsl:choose>
  402. <xsl:when test="title|info/title">
  403. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  404. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  405. </xsl:apply-templates>
  406. </xsl:when>
  407. <xsl:otherwise>
  408. <xsl:call-template name="gentext">
  409. <xsl:with-param name="key" select="'Abstract'"/>
  410. </xsl:call-template>
  411. </xsl:otherwise>
  412. </xsl:choose>
  413. </xsl:template>
  414. <xsl:template match="caution|tip|warning|important|note" mode="title.markup">
  415. <xsl:param name="allow-anchors" select="0"/>
  416. <xsl:variable name="title" select="(title|info/title)[1]"/>
  417. <xsl:choose>
  418. <xsl:when test="$title">
  419. <xsl:apply-templates select="$title" mode="title.markup">
  420. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  421. </xsl:apply-templates>
  422. </xsl:when>
  423. <xsl:otherwise>
  424. <xsl:call-template name="gentext">
  425. <xsl:with-param name="key">
  426. <xsl:choose>
  427. <xsl:when test="local-name(.)='note'">Note</xsl:when>
  428. <xsl:when test="local-name(.)='important'">Important</xsl:when>
  429. <xsl:when test="local-name(.)='caution'">Caution</xsl:when>
  430. <xsl:when test="local-name(.)='warning'">Warning</xsl:when>
  431. <xsl:when test="local-name(.)='tip'">Tip</xsl:when>
  432. </xsl:choose>
  433. </xsl:with-param>
  434. </xsl:call-template>
  435. </xsl:otherwise>
  436. </xsl:choose>
  437. </xsl:template>
  438. <xsl:template match="question" mode="title.markup">
  439. <!-- questions don't have titles -->
  440. <xsl:text>Question</xsl:text>
  441. </xsl:template>
  442. <xsl:template match="answer" mode="title.markup">
  443. <!-- answers don't have titles -->
  444. <xsl:text>Answer</xsl:text>
  445. </xsl:template>
  446. <xsl:template match="qandaentry" mode="title.markup">
  447. <!-- qandaentrys are represented by the first question in them -->
  448. <xsl:text>Question</xsl:text>
  449. </xsl:template>
  450. <xsl:template match="qandaset" mode="title.markup">
  451. <xsl:param name="allow-anchors" select="0"/>
  452. <xsl:variable name="title" select="(info/title|
  453. blockinfo/title|
  454. title)[1]"/>
  455. <xsl:choose>
  456. <xsl:when test="$title">
  457. <xsl:apply-templates select="$title" mode="title.markup">
  458. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  459. </xsl:apply-templates>
  460. </xsl:when>
  461. <xsl:otherwise>
  462. <xsl:call-template name="gentext">
  463. <xsl:with-param name="key" select="'QandASet'"/>
  464. </xsl:call-template>
  465. </xsl:otherwise>
  466. </xsl:choose>
  467. </xsl:template>
  468. <xsl:template match="legalnotice" mode="title.markup">
  469. <xsl:param name="allow-anchors" select="0"/>
  470. <xsl:choose>
  471. <xsl:when test="title|info/title">
  472. <xsl:apply-templates select="(title|info/title)[1]" mode="title.markup">
  473. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  474. </xsl:apply-templates>
  475. </xsl:when>
  476. <xsl:otherwise>
  477. <xsl:call-template name="gentext">
  478. <xsl:with-param name="key" select="'LegalNotice'"/>
  479. </xsl:call-template>
  480. </xsl:otherwise>
  481. </xsl:choose>
  482. </xsl:template>
  483. <!-- ============================================================ -->
  484. <!-- titleabbrev is always processed in a mode -->
  485. <xsl:template match="titleabbrev"/>
  486. <xsl:template match="*" mode="titleabbrev.markup">
  487. <xsl:param name="allow-anchors" select="0"/>
  488. <xsl:param name="verbose" select="1"/>
  489. <xsl:choose>
  490. <xsl:when test="titleabbrev">
  491. <xsl:apply-templates select="titleabbrev[1]" mode="title.markup">
  492. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  493. </xsl:apply-templates>
  494. </xsl:when>
  495. <xsl:when test="info/titleabbrev">
  496. <xsl:apply-templates select="info/titleabbrev[1]" mode="title.markup">
  497. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  498. </xsl:apply-templates>
  499. </xsl:when>
  500. <xsl:otherwise>
  501. <xsl:apply-templates select="." mode="title.markup">
  502. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  503. <xsl:with-param name="verbose" select="$verbose"/>
  504. </xsl:apply-templates>
  505. </xsl:otherwise>
  506. </xsl:choose>
  507. </xsl:template>
  508. <xsl:template match="book|part|set|preface|chapter|appendix" mode="titleabbrev.markup">
  509. <xsl:param name="allow-anchors" select="0"/>
  510. <xsl:param name="verbose" select="1"/>
  511. <xsl:variable name="titleabbrev" select="(docinfo/titleabbrev
  512. |bookinfo/titleabbrev
  513. |info/titleabbrev
  514. |prefaceinfo/titleabbrev
  515. |setinfo/titleabbrev
  516. |partinfo/titleabbrev
  517. |chapterinfo/titleabbrev
  518. |appendixinfo/titleabbrev
  519. |titleabbrev)[1]"/>
  520. <xsl:choose>
  521. <xsl:when test="$titleabbrev">
  522. <xsl:apply-templates select="$titleabbrev" mode="title.markup">
  523. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  524. </xsl:apply-templates>
  525. </xsl:when>
  526. <xsl:otherwise>
  527. <xsl:apply-templates select="." mode="title.markup">
  528. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  529. <xsl:with-param name="verbose" select="$verbose"/>
  530. </xsl:apply-templates>
  531. </xsl:otherwise>
  532. </xsl:choose>
  533. </xsl:template>
  534. <xsl:template match="article" mode="titleabbrev.markup">
  535. <xsl:param name="allow-anchors" select="0"/>
  536. <xsl:param name="verbose" select="1"/>
  537. <xsl:variable name="titleabbrev" select="(artheader/titleabbrev
  538. |articleinfo/titleabbrev
  539. |info/titleabbrev
  540. |titleabbrev)[1]"/>
  541. <xsl:choose>
  542. <xsl:when test="$titleabbrev">
  543. <xsl:apply-templates select="$titleabbrev" mode="title.markup">
  544. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  545. </xsl:apply-templates>
  546. </xsl:when>
  547. <xsl:otherwise>
  548. <xsl:apply-templates select="." mode="title.markup">
  549. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  550. <xsl:with-param name="verbose" select="$verbose"/>
  551. </xsl:apply-templates>
  552. </xsl:otherwise>
  553. </xsl:choose>
  554. </xsl:template>
  555. <xsl:template match="section
  556. |sect1|sect2|sect3|sect4|sect5
  557. |refsect1|refsect2|refsect3
  558. |topic
  559. |simplesect"
  560. mode="titleabbrev.markup">
  561. <xsl:param name="allow-anchors" select="0"/>
  562. <xsl:param name="verbose" select="1"/>
  563. <xsl:variable name="titleabbrev" select="(info/titleabbrev
  564. |sectioninfo/titleabbrev
  565. |sect1info/titleabbrev
  566. |sect2info/titleabbrev
  567. |sect3info/titleabbrev
  568. |sect4info/titleabbrev
  569. |sect5info/titleabbrev
  570. |refsect1info/titleabbrev
  571. |refsect2info/titleabbrev
  572. |refsect3info/titleabbrev
  573. |titleabbrev)[1]"/>
  574. <xsl:choose>
  575. <xsl:when test="$titleabbrev">
  576. <xsl:apply-templates select="$titleabbrev" mode="title.markup">
  577. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  578. </xsl:apply-templates>
  579. </xsl:when>
  580. <xsl:otherwise>
  581. <xsl:apply-templates select="." mode="title.markup">
  582. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  583. <xsl:with-param name="verbose" select="$verbose"/>
  584. </xsl:apply-templates>
  585. </xsl:otherwise>
  586. </xsl:choose>
  587. </xsl:template>
  588. <xsl:template match="titleabbrev" mode="title.markup">
  589. <xsl:param name="allow-anchors" select="0"/>
  590. <xsl:choose>
  591. <xsl:when test="$allow-anchors != 0">
  592. <xsl:apply-templates/>
  593. </xsl:when>
  594. <xsl:otherwise>
  595. <xsl:apply-templates mode="no.anchor.mode"/>
  596. </xsl:otherwise>
  597. </xsl:choose>
  598. </xsl:template>
  599. <!-- ============================================================ -->
  600. <xsl:template match="*" mode="no.anchor.mode">
  601. <!-- Switch to normal mode if no links -->
  602. <xsl:choose>
  603. <xsl:when test="descendant-or-self::footnote or
  604. descendant-or-self::anchor or
  605. descendant-or-self::ulink or
  606. descendant-or-self::link or
  607. descendant-or-self::olink or
  608. descendant-or-self::xref or
  609. descendant-or-self::indexterm or
  610. (ancestor::title and (@id or @xml:id))">
  611. <xsl:apply-templates mode="no.anchor.mode"/>
  612. </xsl:when>
  613. <xsl:otherwise>
  614. <xsl:apply-templates select="."/>
  615. </xsl:otherwise>
  616. </xsl:choose>
  617. </xsl:template>
  618. <xsl:template match="footnote" mode="no.anchor.mode">
  619. <!-- nop, suppressed -->
  620. </xsl:template>
  621. <xsl:template match="anchor" mode="no.anchor.mode">
  622. <!-- nop, suppressed -->
  623. </xsl:template>
  624. <xsl:template match="ulink" mode="no.anchor.mode">
  625. <xsl:apply-templates/>
  626. </xsl:template>
  627. <xsl:template match="link" mode="no.anchor.mode">
  628. <xsl:choose>
  629. <xsl:when test="count(child::node()) &gt; 0">
  630. <!-- If it has content, use it -->
  631. <xsl:apply-templates/>
  632. </xsl:when>
  633. <!-- look for an endterm -->
  634. <xsl:when test="@endterm">
  635. <xsl:variable name="etargets" select="key('id',@endterm)"/>
  636. <xsl:variable name="etarget" select="$etargets[1]"/>
  637. <xsl:choose>
  638. <xsl:when test="count($etarget) = 0">
  639. <xsl:message>
  640. <xsl:value-of select="count($etargets)"/>
  641. <xsl:text>Endterm points to nonexistent ID: </xsl:text>
  642. <xsl:value-of select="@endterm"/>
  643. </xsl:message>
  644. <xsl:text>???</xsl:text>
  645. </xsl:when>
  646. <xsl:otherwise>
  647. <xsl:apply-templates select="$etarget" mode="endterm"/>
  648. </xsl:otherwise>
  649. </xsl:choose>
  650. </xsl:when>
  651. <xsl:otherwise>
  652. <xsl:apply-templates/>
  653. </xsl:otherwise>
  654. </xsl:choose>
  655. </xsl:template>
  656. <xsl:template match="olink" mode="no.anchor.mode">
  657. <xsl:apply-templates/>
  658. </xsl:template>
  659. <xsl:template match="indexterm" mode="no.anchor.mode">
  660. <!-- nop, suppressed -->
  661. </xsl:template>
  662. <xsl:template match="xref" mode="no.anchor.mode">
  663. <xsl:variable name="targets" select="key('id',@linkend)|key('id',substring-after(@xlink:href,'#'))"/>
  664. <xsl:variable name="target" select="$targets[1]"/>
  665. <xsl:variable name="refelem" select="local-name($target)"/>
  666. <xsl:call-template name="check.id.unique">
  667. <xsl:with-param name="linkend" select="@linkend"/>
  668. </xsl:call-template>
  669. <xsl:choose>
  670. <xsl:when test="count($target) = 0">
  671. <xsl:message>
  672. <xsl:text>XRef to nonexistent id: </xsl:text>
  673. <xsl:value-of select="@linkend"/>
  674. <xsl:value-of select="@xlink:href"/>
  675. </xsl:message>
  676. <xsl:text>???</xsl:text>
  677. </xsl:when>
  678. <xsl:when test="@endterm">
  679. <xsl:variable name="etargets" select="key('id',@endterm)"/>
  680. <xsl:variable name="etarget" select="$etargets[1]"/>
  681. <xsl:choose>
  682. <xsl:when test="count($etarget) = 0">
  683. <xsl:message>
  684. <xsl:value-of select="count($etargets)"/>
  685. <xsl:text>Endterm points to nonexistent ID: </xsl:text>
  686. <xsl:value-of select="@endterm"/>
  687. </xsl:message>
  688. <xsl:text>???</xsl:text>
  689. </xsl:when>
  690. <xsl:otherwise>
  691. <xsl:apply-templates select="$etarget" mode="endterm"/>
  692. </xsl:otherwise>
  693. </xsl:choose>
  694. </xsl:when>
  695. <xsl:when test="$target/@xreflabel">
  696. <xsl:call-template name="xref.xreflabel">
  697. <xsl:with-param name="target" select="$target"/>
  698. </xsl:call-template>
  699. </xsl:when>
  700. <xsl:otherwise>
  701. <xsl:choose>
  702. <!-- Watch out for the case when there is a xref or link inside
  703. a title. See bugs #1811721 and #1838136. -->
  704. <xsl:when test="not(ancestor::*[@id = $target/@id] or ancestor::*[@xml:id = $target/@xml:id])">
  705. <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
  706. <xsl:apply-templates select="$target" mode="xref-to">
  707. <xsl:with-param name="referrer" select="."/>
  708. <xsl:with-param name="xrefstyle">
  709. <xsl:choose>
  710. <xsl:when test="@role and not(@xrefstyle) and $use.role.as.xrefstyle != 0">
  711. <xsl:value-of select="@role"/>
  712. </xsl:when>
  713. <xsl:otherwise>
  714. <xsl:value-of select="@xrefstyle"/>
  715. </xsl:otherwise>
  716. </xsl:choose>
  717. </xsl:with-param>
  718. </xsl:apply-templates>
  719. <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
  720. </xsl:when>
  721. <xsl:otherwise>
  722. <xsl:apply-templates/>
  723. </xsl:otherwise>
  724. </xsl:choose>
  725. </xsl:otherwise>
  726. </xsl:choose>
  727. </xsl:template>
  728. <!-- ============================================================ -->
  729. </xsl:stylesheet>