website-common.xsl 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:html='http://www.w3.org/1999/xhtml'
  4. xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  5. exclude-result-prefixes="doc html"
  6. version='1.0'>
  7. <!-- ********************************************************************
  8. $Id: website-common.xsl 9396 2012-06-02 21:56:19Z bobstayton $
  9. ********************************************************************
  10. This file is part of the WebSite distribution.
  11. See ../README or http://nwalsh.com/website/ for copyright
  12. copyright and other information.
  13. ******************************************************************** -->
  14. <!-- ==================================================================== -->
  15. <xsl:import href="../html/docbook.xsl"/>
  16. <xsl:import href="xbel.xsl"/>
  17. <xsl:include href="../VERSION.xsl"/>
  18. <xsl:include href="param.xsl"/>
  19. <xsl:include href="head.xsl"/>
  20. <xsl:include href="rss.xsl"/>
  21. <xsl:include href="olink.xsl"/>
  22. <xsl:preserve-space elements="*"/>
  23. <xsl:strip-space elements="website webpage"/>
  24. <xsl:output method="html"
  25. indent="no"/>
  26. <!-- ==================================================================== -->
  27. <xsl:template name="admon.graphic">
  28. <xsl:param name="node" select="."/>
  29. <xsl:call-template name="root-rel-path"/>
  30. <xsl:value-of select="$admon.graphics.path"/>
  31. <xsl:choose>
  32. <xsl:when test="name($node)='note'">note</xsl:when>
  33. <xsl:when test="name($node)='warning'">warning</xsl:when>
  34. <xsl:when test="name($node)='caution'">caution</xsl:when>
  35. <xsl:when test="name($node)='tip'">tip</xsl:when>
  36. <xsl:when test="name($node)='important'">important</xsl:when>
  37. <xsl:otherwise>note</xsl:otherwise>
  38. </xsl:choose>
  39. <xsl:value-of select="$admon.graphics.extension"/>
  40. </xsl:template>
  41. <doc:template name="admon.graphic">
  42. <refpurpose>Select appropriate admonition graphic</refpurpose>
  43. <refdescription>
  44. <para>Selects the appropriate admonition graphic file and returns the
  45. fully qualified path to it.</para>
  46. </refdescription>
  47. <refparam>
  48. <variablelist>
  49. <varlistentry><term>node</term>
  50. <listitem>
  51. <para>The source node to use for the purpose of selection. It should
  52. be one of the admonition elements (<sgmltag>note</sgmltag>,
  53. <sgmltag>warning</sgmltag>, etc.). The default node is the context
  54. node.</para>
  55. </listitem>
  56. </varlistentry>
  57. </variablelist>
  58. </refparam>
  59. <refreturns>
  60. <para>The fully qualified path to the admonition graphic. If the
  61. <varname>node</varname> is not an admonition element, the
  62. <quote>note</quote> graphic is returned.</para>
  63. </refreturns>
  64. </doc:template>
  65. <!-- ==================================================================== -->
  66. <xsl:template match="/">
  67. <xsl:apply-templates/>
  68. </xsl:template>
  69. <!-- ==================================================================== -->
  70. <xsl:template name="allpages.banner"/>
  71. <!-- ==================================================================== -->
  72. <xsl:template name="webpage.table.footer"/>
  73. <xsl:template name="webpage.footer">
  74. <xsl:variable name="page" select="."/>
  75. <xsl:variable name="footers" select="$page/config[@param='footer']
  76. |$page/config[@param='footlink']
  77. |$autolayout/autolayout/config[@param='footer']
  78. |$autolayout/autolayout/config[@param='footlink']"/>
  79. <xsl:variable name="tocentry" select="$autolayout//*[@id=$page/@id]"/>
  80. <xsl:variable name="toc" select="($tocentry/ancestor-or-self::toc[1]
  81. | $autolayout//toc[1])[last()]"/>
  82. <xsl:variable name="feedback">
  83. <xsl:choose>
  84. <xsl:when test="$page/config[@param='feedback.href']">
  85. <xsl:value-of select="($page/config[@param='feedback.href'])[1]/@value"/>
  86. </xsl:when>
  87. <xsl:when test="$autolayout/autolayout/config[@param='feedback.href']">
  88. <xsl:value-of select="($autolayout/autolayout/config[@param='feedback.href'])[1]/@value"/>
  89. </xsl:when>
  90. <xsl:otherwise>
  91. <xsl:value-of select="$feedback.href"/>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. </xsl:variable>
  95. <div class="navfoot">
  96. <xsl:if test="$footer.hr != 0"><hr/></xsl:if>
  97. <table width="100%" border="0" summary="Footer navigation">
  98. <tr>
  99. <td width="33%" align="left">
  100. <span class="footdate">
  101. <xsl:call-template name="rcsdate.format">
  102. <xsl:with-param name="rcsdate"
  103. select="$page/config[@param='rcsdate']/@value"/>
  104. </xsl:call-template>
  105. </span>
  106. </td>
  107. <td width="34%" align="center">
  108. <xsl:choose>
  109. <xsl:when test="not($toc)">
  110. <xsl:message>
  111. <xsl:text>Cannot determine TOC for </xsl:text>
  112. <xsl:value-of select="$page/@id"/>
  113. </xsl:message>
  114. </xsl:when>
  115. <xsl:when test="$toc/@id = $page/@id">
  116. <!-- nop; this is the home page -->
  117. </xsl:when>
  118. <xsl:otherwise>
  119. <span class="foothome">
  120. <a>
  121. <xsl:attribute name="href">
  122. <xsl:call-template name="homeuri"/>
  123. </xsl:attribute>
  124. <xsl:call-template name="gentext.nav.home"/>
  125. </a>
  126. <xsl:if test="$footers">
  127. <xsl:text> | </xsl:text>
  128. </xsl:if>
  129. </span>
  130. </xsl:otherwise>
  131. </xsl:choose>
  132. <xsl:apply-templates select="$footers" mode="footer.link.mode"/>
  133. </td>
  134. <td width="33%" align="right">
  135. <xsl:choose>
  136. <xsl:when test="$feedback != ''">
  137. <span class="footfeed">
  138. <a>
  139. <xsl:choose>
  140. <xsl:when test="$feedback.with.ids != 0">
  141. <xsl:attribute name="href">
  142. <xsl:value-of select="$feedback"/>
  143. <xsl:value-of select="$page/@id"/>
  144. </xsl:attribute>
  145. </xsl:when>
  146. <xsl:otherwise>
  147. <xsl:attribute name="href">
  148. <xsl:value-of select="$feedback"/>
  149. </xsl:attribute>
  150. </xsl:otherwise>
  151. </xsl:choose>
  152. <xsl:value-of select="$feedback.link.text"/>
  153. </a>
  154. </span>
  155. </xsl:when>
  156. <xsl:otherwise>&#160;</xsl:otherwise>
  157. </xsl:choose>
  158. </td>
  159. </tr>
  160. <tr>
  161. <td colspan="3" align="right">
  162. <span class="footcopy">
  163. <xsl:choose>
  164. <xsl:when test="head/copyright">
  165. <xsl:apply-templates select="head/copyright" mode="footer.mode"/>
  166. </xsl:when>
  167. <xsl:otherwise>
  168. <xsl:apply-templates mode="footer.mode"
  169. select="$autolayout/autolayout/copyright"/>
  170. </xsl:otherwise>
  171. </xsl:choose>
  172. </span>
  173. </td>
  174. </tr>
  175. <xsl:if test="$sequential.links != 0">
  176. <tr>
  177. <xsl:variable name="prev">
  178. <xsl:call-template name="prev.page"/>
  179. </xsl:variable>
  180. <xsl:variable name="next">
  181. <xsl:call-template name="next.page"/>
  182. </xsl:variable>
  183. <xsl:variable name="ptoc"
  184. select="$autolayout/autolayout//*[$prev=@id]"/>
  185. <xsl:variable name="ntoc"
  186. select="$autolayout/autolayout//*[$next=@id]"/>
  187. <td align="left" valign="top">
  188. <xsl:choose>
  189. <xsl:when test="$prev != ''">
  190. <xsl:call-template name="link.to.page">
  191. <xsl:with-param name="frompage" select="$tocentry"/>
  192. <xsl:with-param name="page" select="$ptoc"/>
  193. <xsl:with-param name="linktext" select="'Prev'"/>
  194. </xsl:call-template>
  195. </xsl:when>
  196. <xsl:otherwise>&#160;</xsl:otherwise>
  197. </xsl:choose>
  198. </td>
  199. <td>&#160;</td>
  200. <td align="right" valign="top">
  201. <xsl:choose>
  202. <xsl:when test="$next != ''">
  203. <xsl:call-template name="link.to.page">
  204. <xsl:with-param name="frompage" select="$tocentry"/>
  205. <xsl:with-param name="page" select="$ntoc"/>
  206. <xsl:with-param name="linktext" select="'Next'"/>
  207. </xsl:call-template>
  208. </xsl:when>
  209. <xsl:otherwise>&#160;</xsl:otherwise>
  210. </xsl:choose>
  211. </td>
  212. </tr>
  213. </xsl:if>
  214. </table>
  215. </div>
  216. </xsl:template>
  217. <xsl:template name="rcsdate.format">
  218. <xsl:param name="rcsdate" select="./config[@param='rcsdate']/@value"/>
  219. <xsl:value-of select="$rcsdate"/>
  220. </xsl:template>
  221. <xsl:template match="config" mode="footer.link.mode">
  222. <span class="foothome">
  223. <xsl:if test="position() &gt; 1">
  224. <xsl:text> | </xsl:text>
  225. </xsl:if>
  226. <xsl:choose>
  227. <xsl:when test="@param='footlink'">
  228. <xsl:variable name="id" select="@value"/>
  229. <xsl:variable name="tocentry"
  230. select="$autolayout//*[@id=$id]"/>
  231. <xsl:if test="count($tocentry) != 1">
  232. <xsl:message>
  233. <xsl:text>Footlink to </xsl:text>
  234. <xsl:value-of select="$id"/>
  235. <xsl:text> does not id a unique page.</xsl:text>
  236. </xsl:message>
  237. </xsl:if>
  238. <xsl:variable name="dir">
  239. <xsl:choose>
  240. <xsl:when test="starts-with($tocentry/@dir, '/')">
  241. <xsl:value-of select="substring($tocentry/@dir, 2)"/>
  242. </xsl:when>
  243. <xsl:otherwise>
  244. <xsl:value-of select="$tocentry/@dir"/>
  245. </xsl:otherwise>
  246. </xsl:choose>
  247. </xsl:variable>
  248. <a>
  249. <xsl:attribute name="href">
  250. <xsl:call-template name="root-rel-path"/>
  251. <xsl:value-of select="$dir"/>
  252. <xsl:value-of select="$filename-prefix"/>
  253. <xsl:value-of select="$tocentry/@filename"/>
  254. </xsl:attribute>
  255. <xsl:value-of select="@altval"/>
  256. </a>
  257. </xsl:when>
  258. <xsl:otherwise>
  259. <a href="{@value}">
  260. <xsl:value-of select="@altval"/>
  261. </a>
  262. </xsl:otherwise>
  263. </xsl:choose>
  264. </span>
  265. </xsl:template>
  266. <!-- ==================================================================== -->
  267. <xsl:template name="homeuri">
  268. <xsl:param name="page" select="ancestor-or-self::webpage"/>
  269. <xsl:variable name="id" select="$page/@id"/>
  270. <xsl:variable name="tocentry"
  271. select="$autolayout//*[@id=$id]"/>
  272. <xsl:variable name="toc" select="$tocentry/ancestor::toc"/>
  273. <xsl:variable name="first-toc"
  274. select="$autolayout/autolayout/toc[1]"/>
  275. <xsl:call-template name="root-rel-path"/>
  276. <xsl:choose>
  277. <xsl:when test="$toc">
  278. <xsl:choose>
  279. <xsl:when test="starts-with($toc/@dir, '/')">
  280. <xsl:value-of select="substring($toc/@dir, 2)"/>
  281. </xsl:when>
  282. <xsl:otherwise>
  283. <xsl:value-of select="$toc/@dir"/>
  284. </xsl:otherwise>
  285. </xsl:choose>
  286. <xsl:value-of select="$filename-prefix"/>
  287. <xsl:value-of select="$toc/@filename"/>
  288. </xsl:when>
  289. <xsl:otherwise>
  290. <xsl:choose>
  291. <xsl:when test="starts-with($first-toc/@dir, '/')">
  292. <xsl:value-of select="substring($first-toc/@dir, 2)"/>
  293. </xsl:when>
  294. <xsl:otherwise>
  295. <xsl:value-of select="$first-toc/@dir"/>
  296. </xsl:otherwise>
  297. </xsl:choose>
  298. <xsl:value-of select="$filename-prefix"/>
  299. <xsl:value-of select="$first-toc/@filename"/>
  300. </xsl:otherwise>
  301. </xsl:choose>
  302. </xsl:template>
  303. <!-- ==================================================================== -->
  304. <xsl:template match="copyright" mode="footer.mode">
  305. <span class="{name(.)}">
  306. <xsl:call-template name="gentext.element.name"/>
  307. <xsl:call-template name="gentext.space"/>
  308. <xsl:call-template name="dingbat">
  309. <xsl:with-param name="dingbat">copyright</xsl:with-param>
  310. </xsl:call-template>
  311. <xsl:call-template name="gentext.space"/>
  312. <xsl:apply-templates select="year" mode="footer.mode"/>
  313. <xsl:call-template name="gentext.space"/>
  314. <xsl:apply-templates select="holder" mode="footer.mode"/>
  315. <xsl:value-of select="$biblioentry.item.separator"/>
  316. </span>
  317. </xsl:template>
  318. <xsl:template match="year" mode="footer.mode">
  319. <xsl:apply-templates/><xsl:text>, </xsl:text>
  320. </xsl:template>
  321. <xsl:template match="year[position()=last()]" mode="footer.mode">
  322. <xsl:apply-templates/>
  323. </xsl:template>
  324. <xsl:template match="holder" mode="footer.mode">
  325. <xsl:apply-templates/>
  326. <xsl:if test="position() != last()">, </xsl:if>
  327. </xsl:template>
  328. <!-- ==================================================================== -->
  329. <xsl:template match="config">
  330. </xsl:template>
  331. <!-- ==================================================================== -->
  332. <xsl:template match="head">
  333. </xsl:template>
  334. <xsl:template match="head/title" mode="title.mode">
  335. <h1><xsl:apply-templates/></h1>
  336. </xsl:template>
  337. <xsl:template match="head/title">
  338. <xsl:apply-templates/>
  339. </xsl:template>
  340. <!-- ==================================================================== -->
  341. <xsl:template name="directory-depth">
  342. <xsl:param name="dir"></xsl:param>
  343. <xsl:param name="count" select="0"/>
  344. <xsl:choose>
  345. <xsl:when test='contains($dir,"/")'>
  346. <xsl:call-template name="directory-depth">
  347. <xsl:with-param name="dir" select="substring-after($dir,'/')"/>
  348. <xsl:with-param name="count" select="$count + 1"/>
  349. </xsl:call-template>
  350. </xsl:when>
  351. <xsl:otherwise>
  352. <xsl:choose>
  353. <xsl:when test='$dir=""'>
  354. <xsl:value-of select="$count"/>
  355. </xsl:when>
  356. <xsl:otherwise>
  357. <xsl:value-of select="$count + 1"/>
  358. </xsl:otherwise>
  359. </xsl:choose>
  360. </xsl:otherwise>
  361. </xsl:choose>
  362. </xsl:template>
  363. <xsl:template name="root-rel-path">
  364. <xsl:param name="webpage" select="ancestor-or-self::webpage"/>
  365. <xsl:variable name="tocentry" select="$autolayout//*[$webpage/@id=@id]"/>
  366. <xsl:apply-templates select="$tocentry" mode="toc-rel-path"/>
  367. </xsl:template>
  368. <!-- ==================================================================== -->
  369. <xsl:template match="footnote" mode="footnote.number">
  370. <xsl:choose>
  371. <xsl:when test="ancestor::table|ancestor::informaltable">
  372. <xsl:number level="any" from="table|informaltable" format="a"/>
  373. </xsl:when>
  374. <xsl:otherwise>
  375. <xsl:number level="any" from="webpage" format="1"/>
  376. </xsl:otherwise>
  377. </xsl:choose>
  378. </xsl:template>
  379. <xsl:template name="process.footnotes">
  380. <!-- we're only interested in footnotes that occur on this page, not
  381. on descendants of this page (which will be similarly processed) -->
  382. <xsl:variable name="thispage"
  383. select="ancestor-or-self::webpage"/>
  384. <xsl:variable name="footnotes"
  385. select=".//footnote[ancestor-or-self::webpage=$thispage]"/>
  386. <xsl:variable name="table.footnotes"
  387. select=".//table//footnote[ancestor-or-self::webpage=$thispage]
  388. |.//informaltable//footnote[ancestor-or-self::webpage
  389. =$thispage]"/>
  390. <!-- Only bother to do this if there's at least one non-table footnote -->
  391. <xsl:if test="count($footnotes)>count($table.footnotes)">
  392. <div class="footnotes">
  393. <hr width="100" align="left"/>
  394. <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
  395. </div>
  396. </xsl:if>
  397. </xsl:template>
  398. <!-- ==================================================================== -->
  399. <xsl:template match="@*" mode="copy">
  400. <xsl:attribute name="{local-name(.)}">
  401. <xsl:value-of select="."/>
  402. </xsl:attribute>
  403. </xsl:template>
  404. <xsl:template match="html:*">
  405. <xsl:element name="{local-name(.)}" namespace="">
  406. <xsl:apply-templates select="@*" mode="copy"/>
  407. <xsl:apply-templates/>
  408. </xsl:element>
  409. </xsl:template>
  410. <!-- ==================================================================== -->
  411. <xsl:template match="processing-instruction('php')">
  412. <xsl:processing-instruction name="php">
  413. <xsl:value-of select="."/>
  414. </xsl:processing-instruction>
  415. </xsl:template>
  416. <!-- ==================================================================== -->
  417. <xsl:template match="rddl:*" xmlns:rddl='http://www.rddl.org/'>
  418. <xsl:element name="{name(.)}">
  419. <xsl:apply-templates select="@*" mode="copy"/>
  420. <xsl:apply-templates/>
  421. </xsl:element>
  422. </xsl:template>
  423. <xsl:template match="section[@rddl]" xmlns:rddl='http://www.rddl.org/'>
  424. <xsl:variable name="rddl" select="id(@rddl)"/>
  425. <xsl:choose>
  426. <xsl:when test="local-name($rddl) != 'resource'">
  427. <xsl:message>
  428. <xsl:text>Warning: section rddl isn't an rddl:resource: </xsl:text>
  429. <xsl:value-of select="@rddl"/>
  430. </xsl:message>
  431. <xsl:apply-imports/>
  432. </xsl:when>
  433. <xsl:otherwise>
  434. <xsl:element name="{name($rddl)}">
  435. <xsl:apply-templates select="$rddl/@*" mode="copy"/>
  436. <xsl:apply-imports/>
  437. </xsl:element>
  438. </xsl:otherwise>
  439. </xsl:choose>
  440. </xsl:template>
  441. <!-- ==================================================================== -->
  442. <xsl:template name="page.uri">
  443. <xsl:param name="href" select="''"/>
  444. <xsl:param name="page" select="ancestor-or-self::tocentry"/>
  445. <xsl:param name="relpath">
  446. <xsl:call-template name="toc-rel-path">
  447. <xsl:with-param name="pageid" select="$page/@id"/>
  448. </xsl:call-template>
  449. </xsl:param>
  450. <!--
  451. <xsl:message><xsl:value-of select="$page/@id"/>: <xsl:value-of select="$relpath"/></xsl:message>
  452. -->
  453. <xsl:variable name="dir">
  454. <xsl:choose>
  455. <xsl:when test="starts-with($page/@dir, '/')">
  456. <xsl:value-of select="substring($page/@dir, 2)"/>
  457. </xsl:when>
  458. <xsl:otherwise>
  459. <xsl:value-of select="$page/@dir"/>
  460. </xsl:otherwise>
  461. </xsl:choose>
  462. </xsl:variable>
  463. <xsl:variable name="html.href">
  464. <xsl:choose>
  465. <xsl:when test="$href != ''">
  466. <xsl:value-of select="$href"/>
  467. </xsl:when>
  468. <xsl:when test="$page/@href">
  469. <xsl:value-of select="$page/@href"/>
  470. </xsl:when>
  471. <xsl:otherwise>
  472. <xsl:value-of select="concat($relpath,$dir,$filename-prefix)"/>
  473. <xsl:value-of select="$page/@filename"/>
  474. </xsl:otherwise>
  475. </xsl:choose>
  476. </xsl:variable>
  477. <xsl:value-of select="$html.href"/>
  478. </xsl:template>
  479. <xsl:template name="link.to.page">
  480. <xsl:param name="href" select="''"/>
  481. <xsl:param name="frompage"/>
  482. <xsl:param name="page" select="ancestor-or-self::tocentry"/>
  483. <xsl:param name="relpath">
  484. <xsl:choose>
  485. <xsl:when test="$frompage">
  486. <xsl:call-template name="toc-rel-path">
  487. <xsl:with-param name="pageid" select="$frompage/@id"/>
  488. </xsl:call-template>
  489. </xsl:when>
  490. <xsl:otherwise>
  491. <xsl:call-template name="toc-rel-path">
  492. <xsl:with-param name="pageid" select="$page/@id"/>
  493. </xsl:call-template>
  494. </xsl:otherwise>
  495. </xsl:choose>
  496. </xsl:param>
  497. <xsl:param name="linktext" select="'???'"/>
  498. <a>
  499. <xsl:attribute name="href">
  500. <xsl:call-template name="page.uri">
  501. <xsl:with-param name="href" select="$href"/>
  502. <xsl:with-param name="page" select="$page"/>
  503. <xsl:with-param name="relpath" select="$relpath"/>
  504. </xsl:call-template>
  505. </xsl:attribute>
  506. <xsl:if test="summary">
  507. <xsl:attribute name="title">
  508. <xsl:value-of select="normalize-space(string(summary))"/>
  509. </xsl:attribute>
  510. </xsl:if>
  511. <xsl:copy-of select="$linktext"/>
  512. </a>
  513. </xsl:template>
  514. <xsl:template name="next.page">
  515. <xsl:param name="page" select="ancestor-or-self::webpage"/>
  516. <xsl:variable name="id" select="$page/@id"/>
  517. <xsl:variable name="tocentry"
  518. select="$autolayout//*[@id=$id]"/>
  519. <xsl:variable name="next-following"
  520. select="$tocentry/following::tocentry[1]"/>
  521. <xsl:variable name="next-child"
  522. select="$tocentry/descendant::tocentry[1]"/>
  523. <xsl:variable name="nextid">
  524. <xsl:choose>
  525. <xsl:when test="$next-child">
  526. <xsl:value-of select="$next-child/@id"/>
  527. </xsl:when>
  528. <xsl:when test="$next-following">
  529. <xsl:value-of select="$next-following/@id"/>
  530. </xsl:when>
  531. <xsl:otherwise></xsl:otherwise>
  532. </xsl:choose>
  533. </xsl:variable>
  534. <xsl:value-of select="$nextid"/>
  535. </xsl:template>
  536. <xsl:template name="prev.page">
  537. <xsl:param name="page" select="ancestor-or-self::webpage"/>
  538. <xsl:variable name="id" select="$page/@id"/>
  539. <xsl:variable name="tocentry"
  540. select="$autolayout//*[@id=$id]"/>
  541. <xsl:variable name="prev-ancestor"
  542. select="($tocentry/ancestor::tocentry
  543. |$tocentry/ancestor::toc)[last()]"/>
  544. <xsl:variable name="prev-sibling"
  545. select="$tocentry/preceding-sibling::tocentry[1]"/>
  546. <xsl:variable name="previd">
  547. <xsl:choose>
  548. <xsl:when test="$prev-sibling">
  549. <xsl:value-of select="$prev-sibling/@id"/>
  550. </xsl:when>
  551. <xsl:when test="$prev-ancestor">
  552. <xsl:value-of select="$prev-ancestor/@id"/>
  553. </xsl:when>
  554. <xsl:otherwise></xsl:otherwise>
  555. </xsl:choose>
  556. </xsl:variable>
  557. <xsl:value-of select="$previd"/>
  558. </xsl:template>
  559. <xsl:template name="top.page">
  560. <xsl:param name="page" select="ancestor-or-self::webpage"/>
  561. <xsl:variable name="id" select="$page/@id"/>
  562. <xsl:variable name="tocentry"
  563. select="$autolayout//*[@id=$id]"/>
  564. <xsl:value-of select="$tocentry/ancestor::toc/@id"/>
  565. </xsl:template>
  566. <xsl:template name="up.page">
  567. <xsl:param name="page" select="ancestor-or-self::webpage"/>
  568. <xsl:variable name="id" select="$page/@id"/>
  569. <xsl:variable name="tocentry"
  570. select="$autolayout//*[@id=$id]"/>
  571. <xsl:choose>
  572. <xsl:when test="$tocentry/ancestor::tocentry">
  573. <xsl:value-of select="$tocentry/ancestor::tocentry[1]/@id"/>
  574. </xsl:when>
  575. <xsl:when test="$tocentry/ancestor::toc">
  576. <xsl:value-of select="$tocentry/ancestor::toc[1]/@id"/>
  577. </xsl:when>
  578. <xsl:otherwise></xsl:otherwise>
  579. </xsl:choose>
  580. </xsl:template>
  581. <xsl:template name="first.page">
  582. <xsl:param name="page" select="ancestor-or-self::webpage"/>
  583. <xsl:variable name="id" select="$page/@id"/>
  584. <xsl:variable name="tocentry"
  585. select="$autolayout//*[@id=$id]"/>
  586. <xsl:value-of select="$tocentry/preceding-sibling::tocentry[last()]/@id"/>
  587. </xsl:template>
  588. <xsl:template name="last.page">
  589. <xsl:param name="page" select="ancestor-or-self::webpage"/>
  590. <xsl:variable name="id" select="$page/@id"/>
  591. <xsl:variable name="tocentry"
  592. select="$autolayout//*[@id=$id]"/>
  593. <xsl:variable name="prev-sibling"
  594. select="$tocentry/preceding-sibling::tocentry[1]"/>
  595. <xsl:value-of select="$tocentry/following-sibling::tocentry[last()]/@id"/>
  596. </xsl:template>
  597. <xsl:template match="autolayout" mode="collect.targets">
  598. <targetset>
  599. <xsl:apply-templates mode="olink.mode"/>
  600. </targetset>
  601. </xsl:template>
  602. <xsl:template match="toc|tocentry|notoc" mode="olink.mode">
  603. <xsl:text>&#10;</xsl:text>
  604. <xsl:call-template name="tocentry"/>
  605. <xsl:apply-templates select="tocentry" mode="olink.mode"/>
  606. </xsl:template>
  607. <xsl:template name="tocentry">
  608. <xsl:choose>
  609. <xsl:when test="@href">
  610. <!-- no op -->
  611. </xsl:when>
  612. <xsl:otherwise>
  613. <xsl:if test="not(@page)">
  614. <xsl:message terminate="yes">
  615. <xsl:text>All toc entries must have a page attribute.</xsl:text>
  616. </xsl:message>
  617. </xsl:if>
  618. <xsl:variable name="page" select="document(@page,.)"/>
  619. <xsl:if test="not($page/*[1]/@id)">
  620. <xsl:message terminate="yes">
  621. <xsl:value-of select="@page"/>
  622. <xsl:text>: missing ID.</xsl:text>
  623. </xsl:message>
  624. </xsl:if>
  625. <xsl:variable name="id" select="$page/*[1]/@id"/>
  626. <xsl:variable name="filename">
  627. <xsl:choose>
  628. <xsl:when test="@filename">
  629. <xsl:value-of select="$filename-prefix"/>
  630. <xsl:value-of select="@filename"/>
  631. </xsl:when>
  632. <xsl:when test="/layout/config[@param='default-filename']">
  633. <xsl:value-of select="$filename-prefix"/>
  634. <xsl:value-of select="(/layout/config[@param='default-filename'])[1]/@value"/>
  635. </xsl:when>
  636. <xsl:otherwise><xsl:value-of select="$filename-prefix"/>index.html</xsl:otherwise>
  637. </xsl:choose>
  638. </xsl:variable>
  639. <xsl:variable name="dir" select="@dir"/>
  640. <xsl:if test="$filename = ''">
  641. <xsl:message terminate="yes">
  642. <xsl:value-of select="@page"/>
  643. <xsl:text>: missing filename.</xsl:text>
  644. </xsl:message>
  645. </xsl:if>
  646. <!--
  647. <xsl:message>
  648. <xsl:value-of select="@page"/>
  649. <xsl:text>: </xsl:text>
  650. <xsl:if test="$dir != ''">
  651. <xsl:value-of select="$dir"/>
  652. </xsl:if>
  653. <xsl:value-of select="$filename"/>
  654. </xsl:message>
  655. -->
  656. <document>
  657. <xsl:attribute name="targetdoc">
  658. <xsl:value-of select="$id"/>
  659. </xsl:attribute>
  660. <xsl:attribute name="baseuri">
  661. <xsl:value-of select="$filename"/>
  662. </xsl:attribute>
  663. <xsl:if test="$dir != ''">
  664. <xsl:attribute name="dir">
  665. <xsl:value-of select="$dir"/>
  666. </xsl:attribute>
  667. </xsl:if>
  668. <xsl:apply-templates select="$page" mode="olink.mode"/>
  669. </document>
  670. </xsl:otherwise>
  671. </xsl:choose>
  672. </xsl:template>
  673. <xsl:template match="webpage" mode="olink.mode">
  674. <xsl:call-template name="div"/>
  675. </xsl:template>
  676. <xsl:template match="webpage" mode="xref-to" >
  677. <xsl:param name="referrer"/>
  678. <xsl:param name="xrefstyle"/>
  679. <xsl:apply-templates select="." mode="object.xref.markup">
  680. <xsl:with-param name="purpose" select="'xref'"/>
  681. <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
  682. <xsl:with-param name="referrer" select="$referrer"/>
  683. </xsl:apply-templates>
  684. <!-- FIXME: What about "in Chapter X"? -->
  685. </xsl:template>
  686. <xsl:template match="webpage" mode="title.markup">
  687. <xsl:param name="allow-anchors" select="0"/>
  688. <xsl:apply-templates select="head/title"
  689. mode="title.markup">
  690. <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
  691. </xsl:apply-templates>
  692. </xsl:template>
  693. <xsl:param name="local.l10n.xml" select="document('')" />
  694. <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
  695. <l:l10n language="en">
  696. <l:context name="title">
  697. <l:template name="webpage" text="%t"/>
  698. </l:context>
  699. <l:context name="xref">
  700. <l:template name="webpage" text="%t"/>
  701. </l:context>
  702. </l:l10n>
  703. <l:l10n language="de">
  704. <l:context name="title">
  705. <l:template name="webpage" text="%t"/>
  706. </l:context>
  707. <l:context name="xref">
  708. <l:template name="webpage" text="%t"/>
  709. </l:context>
  710. </l:l10n>
  711. <l:l10n language="fr">
  712. <l:context name="title">
  713. <l:template name="webpage" text="%t"/>
  714. </l:context>
  715. <l:context name="xref">
  716. <l:template name="webpage" text="%t"/>
  717. </l:context>
  718. </l:l10n>
  719. <l:l10n language="es">
  720. <l:context name="title">
  721. <l:template name="webpage" text="%t"/>
  722. </l:context>
  723. <l:context name="xref">
  724. <l:template name="webpage" text="%t"/>
  725. </l:context>
  726. </l:l10n>
  727. </l:i18n>
  728. </xsl:stylesheet>