chunk-code.xsl 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:exsl="http://exslt.org/common"
  4. xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
  5. xmlns:ng="http://docbook.org/docbook-ng"
  6. xmlns:db="http://docbook.org/ns/docbook"
  7. exclude-result-prefixes="exsl cf ng db"
  8. version="1.0">
  9. <!-- ********************************************************************
  10. $Id: chunk-code.xsl 9328 2012-05-03 16:28:23Z bobstayton $
  11. ********************************************************************
  12. This file is part of the XSL DocBook Stylesheet distribution.
  13. See ../README or http://docbook.sf.net/release/xsl/current/ for
  14. copyright and other information.
  15. ******************************************************************** -->
  16. <!-- ==================================================================== -->
  17. <xsl:template match="*" mode="chunk-filename">
  18. <!-- returns the filename of a chunk -->
  19. <xsl:variable name="ischunk">
  20. <xsl:call-template name="chunk"/>
  21. </xsl:variable>
  22. <xsl:variable name="fn">
  23. <xsl:apply-templates select="." mode="recursive-chunk-filename"/>
  24. </xsl:variable>
  25. <!--
  26. <xsl:message>
  27. <xsl:value-of select="$ischunk"/>
  28. <xsl:text> (</xsl:text>
  29. <xsl:value-of select="local-name(.)"/>
  30. <xsl:text>) </xsl:text>
  31. <xsl:value-of select="$fn"/>
  32. <xsl:text>, </xsl:text>
  33. <xsl:call-template name="dbhtml-dir"/>
  34. </xsl:message>
  35. -->
  36. <!-- 2003-11-25 by ndw:
  37. The following test used to read test="$ischunk != 0 and $fn != ''"
  38. I've removed the ischunk part of the test so that href.to.uri and
  39. href.from.uri will be fully qualified even if the source or target
  40. isn't a chunk. I *think* that if $fn != '' then it's appropriate
  41. to put the directory on the front, even if the element isn't a
  42. chunk. I could be wrong. -->
  43. <xsl:if test="$fn != ''">
  44. <xsl:call-template name="dbhtml-dir"/>
  45. </xsl:if>
  46. <xsl:value-of select="$chunked.filename.prefix"/>
  47. <xsl:value-of select="$fn"/>
  48. <!-- You can't add the html.ext here because dbhtml filename= may already -->
  49. <!-- have added it. It really does have to be handled in the recursive template -->
  50. </xsl:template>
  51. <xsl:template match="*" mode="recursive-chunk-filename">
  52. <xsl:param name="recursive" select="false()"/>
  53. <!-- returns the filename of a chunk -->
  54. <xsl:variable name="ischunk">
  55. <xsl:call-template name="chunk"/>
  56. </xsl:variable>
  57. <xsl:variable name="dbhtml-filename">
  58. <xsl:call-template name="pi.dbhtml_filename"/>
  59. </xsl:variable>
  60. <xsl:variable name="filename">
  61. <xsl:choose>
  62. <xsl:when test="$dbhtml-filename != ''">
  63. <xsl:value-of select="$dbhtml-filename"/>
  64. </xsl:when>
  65. <!-- if this is the root element, use the root.filename -->
  66. <xsl:when test="not(parent::*) and $root.filename != ''">
  67. <xsl:value-of select="$root.filename"/>
  68. <xsl:value-of select="$html.ext"/>
  69. </xsl:when>
  70. <!-- Special case -->
  71. <xsl:when test="self::legalnotice and not($generate.legalnotice.link = 0)">
  72. <xsl:choose>
  73. <xsl:when test="(@id or @xml:id) and not($use.id.as.filename = 0)">
  74. <!-- * if this legalnotice has an ID, then go ahead and use -->
  75. <!-- * just the value of that ID as the basename for the file -->
  76. <!-- * (that is, without prepending an "ln-" too it) -->
  77. <xsl:value-of select="(@id|@xml:id)[1]"/>
  78. <xsl:value-of select="$html.ext"/>
  79. </xsl:when>
  80. <xsl:otherwise>
  81. <!-- * otherwise, if this legalnotice does not have an ID, -->
  82. <!-- * then we generate an ID... -->
  83. <xsl:variable name="id">
  84. <xsl:call-template name="object.id"/>
  85. </xsl:variable>
  86. <!-- * ...and then we take that generated ID, prepend an -->
  87. <!-- * "ln-" to it, and use that as the basename for the file -->
  88. <xsl:value-of select="concat('ln-',$id,$html.ext)"/>
  89. </xsl:otherwise>
  90. </xsl:choose>
  91. </xsl:when>
  92. <!-- if there's no dbhtml filename, and if we're to use IDs as -->
  93. <!-- filenames, then use the ID to generate the filename. -->
  94. <xsl:when test="(@id or @xml:id) and $use.id.as.filename != 0">
  95. <xsl:value-of select="(@id|@xml:id)[1]"/>
  96. <xsl:value-of select="$html.ext"/>
  97. </xsl:when>
  98. <xsl:otherwise></xsl:otherwise>
  99. </xsl:choose>
  100. </xsl:variable>
  101. <xsl:choose>
  102. <xsl:when test="$ischunk='0'">
  103. <!-- if called on something that isn't a chunk, walk up... -->
  104. <xsl:choose>
  105. <xsl:when test="count(parent::*)>0">
  106. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  107. <xsl:with-param name="recursive" select="$recursive"/>
  108. </xsl:apply-templates>
  109. </xsl:when>
  110. <!-- unless there is no up, in which case return "" -->
  111. <xsl:otherwise></xsl:otherwise>
  112. </xsl:choose>
  113. </xsl:when>
  114. <xsl:when test="not($recursive) and $filename != ''">
  115. <!-- if this chunk has an explicit name, use it -->
  116. <xsl:value-of select="$filename"/>
  117. </xsl:when>
  118. <xsl:when test="self::set">
  119. <xsl:value-of select="$root.filename"/>
  120. <xsl:if test="not($recursive)">
  121. <xsl:value-of select="$html.ext"/>
  122. </xsl:if>
  123. </xsl:when>
  124. <xsl:when test="self::book">
  125. <xsl:text>bk</xsl:text>
  126. <xsl:number level="any" format="01"/>
  127. <xsl:if test="not($recursive)">
  128. <xsl:value-of select="$html.ext"/>
  129. </xsl:if>
  130. </xsl:when>
  131. <xsl:when test="self::article">
  132. <xsl:if test="/set">
  133. <!-- in a set, make sure we inherit the right book info... -->
  134. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  135. <xsl:with-param name="recursive" select="true()"/>
  136. </xsl:apply-templates>
  137. </xsl:if>
  138. <xsl:text>ar</xsl:text>
  139. <xsl:number level="any" format="01" from="book"/>
  140. <xsl:if test="not($recursive)">
  141. <xsl:value-of select="$html.ext"/>
  142. </xsl:if>
  143. </xsl:when>
  144. <xsl:when test="self::preface">
  145. <xsl:if test="/set">
  146. <!-- in a set, make sure we inherit the right book info... -->
  147. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  148. <xsl:with-param name="recursive" select="true()"/>
  149. </xsl:apply-templates>
  150. </xsl:if>
  151. <xsl:text>pr</xsl:text>
  152. <xsl:number level="any" format="01" from="book"/>
  153. <xsl:if test="not($recursive)">
  154. <xsl:value-of select="$html.ext"/>
  155. </xsl:if>
  156. </xsl:when>
  157. <xsl:when test="self::chapter">
  158. <xsl:if test="/set">
  159. <!-- in a set, make sure we inherit the right book info... -->
  160. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  161. <xsl:with-param name="recursive" select="true()"/>
  162. </xsl:apply-templates>
  163. </xsl:if>
  164. <xsl:text>ch</xsl:text>
  165. <xsl:number level="any" format="01" from="book"/>
  166. <xsl:if test="not($recursive)">
  167. <xsl:value-of select="$html.ext"/>
  168. </xsl:if>
  169. </xsl:when>
  170. <xsl:when test="self::appendix">
  171. <xsl:if test="/set">
  172. <!-- in a set, make sure we inherit the right book info... -->
  173. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  174. <xsl:with-param name="recursive" select="true()"/>
  175. </xsl:apply-templates>
  176. </xsl:if>
  177. <xsl:text>ap</xsl:text>
  178. <xsl:number level="any" format="a" from="book"/>
  179. <xsl:if test="not($recursive)">
  180. <xsl:value-of select="$html.ext"/>
  181. </xsl:if>
  182. </xsl:when>
  183. <xsl:when test="self::part">
  184. <xsl:choose>
  185. <xsl:when test="/set">
  186. <!-- in a set, make sure we inherit the right book info... -->
  187. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  188. <xsl:with-param name="recursive" select="true()"/>
  189. </xsl:apply-templates>
  190. </xsl:when>
  191. <xsl:otherwise>
  192. </xsl:otherwise>
  193. </xsl:choose>
  194. <xsl:text>pt</xsl:text>
  195. <xsl:number level="any" format="01" from="book"/>
  196. <xsl:if test="not($recursive)">
  197. <xsl:value-of select="$html.ext"/>
  198. </xsl:if>
  199. </xsl:when>
  200. <xsl:when test="self::reference">
  201. <xsl:choose>
  202. <xsl:when test="/set">
  203. <!-- in a set, make sure we inherit the right book info... -->
  204. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  205. <xsl:with-param name="recursive" select="true()"/>
  206. </xsl:apply-templates>
  207. </xsl:when>
  208. <xsl:otherwise>
  209. </xsl:otherwise>
  210. </xsl:choose>
  211. <xsl:text>rn</xsl:text>
  212. <xsl:number level="any" format="01" from="book"/>
  213. <xsl:if test="not($recursive)">
  214. <xsl:value-of select="$html.ext"/>
  215. </xsl:if>
  216. </xsl:when>
  217. <xsl:when test="self::refentry">
  218. <xsl:choose>
  219. <xsl:when test="parent::reference">
  220. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  221. <xsl:with-param name="recursive" select="true()"/>
  222. </xsl:apply-templates>
  223. </xsl:when>
  224. <xsl:otherwise>
  225. <xsl:if test="/set">
  226. <!-- in a set, make sure we inherit the right book info... -->
  227. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  228. <xsl:with-param name="recursive" select="true()"/>
  229. </xsl:apply-templates>
  230. </xsl:if>
  231. </xsl:otherwise>
  232. </xsl:choose>
  233. <xsl:text>re</xsl:text>
  234. <xsl:number level="any" format="01" from="book"/>
  235. <xsl:if test="not($recursive)">
  236. <xsl:value-of select="$html.ext"/>
  237. </xsl:if>
  238. </xsl:when>
  239. <xsl:when test="self::colophon">
  240. <xsl:choose>
  241. <xsl:when test="/set">
  242. <!-- in a set, make sure we inherit the right book info... -->
  243. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  244. <xsl:with-param name="recursive" select="true()"/>
  245. </xsl:apply-templates>
  246. </xsl:when>
  247. <xsl:otherwise>
  248. </xsl:otherwise>
  249. </xsl:choose>
  250. <xsl:text>co</xsl:text>
  251. <xsl:number level="any" format="01" from="book"/>
  252. <xsl:if test="not($recursive)">
  253. <xsl:value-of select="$html.ext"/>
  254. </xsl:if>
  255. </xsl:when>
  256. <xsl:when test="self::sect1
  257. or self::sect2
  258. or self::sect3
  259. or self::sect4
  260. or self::sect5
  261. or self::section">
  262. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  263. <xsl:with-param name="recursive" select="true()"/>
  264. </xsl:apply-templates>
  265. <xsl:text>s</xsl:text>
  266. <xsl:number format="01"/>
  267. <xsl:if test="not($recursive)">
  268. <xsl:value-of select="$html.ext"/>
  269. </xsl:if>
  270. </xsl:when>
  271. <xsl:when test="self::bibliography">
  272. <xsl:choose>
  273. <xsl:when test="/set">
  274. <!-- in a set, make sure we inherit the right book info... -->
  275. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  276. <xsl:with-param name="recursive" select="true()"/>
  277. </xsl:apply-templates>
  278. </xsl:when>
  279. <xsl:otherwise>
  280. </xsl:otherwise>
  281. </xsl:choose>
  282. <xsl:text>bi</xsl:text>
  283. <xsl:number level="any" format="01" from="book"/>
  284. <xsl:if test="not($recursive)">
  285. <xsl:value-of select="$html.ext"/>
  286. </xsl:if>
  287. </xsl:when>
  288. <xsl:when test="self::glossary">
  289. <xsl:choose>
  290. <xsl:when test="/set">
  291. <!-- in a set, make sure we inherit the right book info... -->
  292. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  293. <xsl:with-param name="recursive" select="true()"/>
  294. </xsl:apply-templates>
  295. </xsl:when>
  296. <xsl:otherwise>
  297. </xsl:otherwise>
  298. </xsl:choose>
  299. <xsl:text>go</xsl:text>
  300. <xsl:number level="any" format="01" from="book"/>
  301. <xsl:if test="not($recursive)">
  302. <xsl:value-of select="$html.ext"/>
  303. </xsl:if>
  304. </xsl:when>
  305. <xsl:when test="self::index">
  306. <xsl:choose>
  307. <xsl:when test="/set">
  308. <!-- in a set, make sure we inherit the right book info... -->
  309. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  310. <xsl:with-param name="recursive" select="true()"/>
  311. </xsl:apply-templates>
  312. </xsl:when>
  313. <xsl:otherwise>
  314. </xsl:otherwise>
  315. </xsl:choose>
  316. <xsl:text>ix</xsl:text>
  317. <xsl:number level="any" format="01" from="book"/>
  318. <xsl:if test="not($recursive)">
  319. <xsl:value-of select="$html.ext"/>
  320. </xsl:if>
  321. </xsl:when>
  322. <xsl:when test="self::setindex">
  323. <xsl:text>si</xsl:text>
  324. <xsl:number level="any" format="01" from="set"/>
  325. <xsl:if test="not($recursive)">
  326. <xsl:value-of select="$html.ext"/>
  327. </xsl:if>
  328. </xsl:when>
  329. <xsl:when test="self::topic">
  330. <xsl:choose>
  331. <xsl:when test="/set">
  332. <!-- in a set, make sure we inherit the right book info... -->
  333. <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
  334. <xsl:with-param name="recursive" select="true()"/>
  335. </xsl:apply-templates>
  336. </xsl:when>
  337. <xsl:otherwise>
  338. </xsl:otherwise>
  339. </xsl:choose>
  340. <xsl:text>to</xsl:text>
  341. <xsl:number level="any" format="01" from="book"/>
  342. <xsl:if test="not($recursive)">
  343. <xsl:value-of select="$html.ext"/>
  344. </xsl:if>
  345. </xsl:when>
  346. <xsl:otherwise>
  347. <xsl:text>chunk-filename-error-</xsl:text>
  348. <xsl:value-of select="name(.)"/>
  349. <xsl:number level="any" format="01" from="set"/>
  350. <xsl:if test="not($recursive)">
  351. <xsl:value-of select="$html.ext"/>
  352. </xsl:if>
  353. </xsl:otherwise>
  354. </xsl:choose>
  355. </xsl:template>
  356. <!-- ==================================================================== -->
  357. <xsl:template match="processing-instruction('dbhtml')">
  358. <!-- nop -->
  359. </xsl:template>
  360. <!-- ==================================================================== -->
  361. <xsl:template match="*" mode="find.chunks">
  362. <xsl:variable name="chunk">
  363. <xsl:call-template name="chunk"/>
  364. </xsl:variable>
  365. <xsl:choose>
  366. <xsl:when test="$chunk != 0">
  367. <cf:div id="{generate-id()}">
  368. <xsl:apply-templates select="." mode="class.attribute"/>
  369. <xsl:apply-templates select="*" mode="find.chunks"/>
  370. </cf:div>
  371. </xsl:when>
  372. <xsl:otherwise>
  373. <xsl:apply-templates select="*" mode="find.chunks"/>
  374. </xsl:otherwise>
  375. </xsl:choose>
  376. </xsl:template>
  377. <!-- Leave legalnotice chunk out of the list for Next and Prev -->
  378. <xsl:template match="legalnotice" mode="find.chunks"/>
  379. <xsl:template match="/">
  380. <!-- * Get a title for current doc so that we let the user -->
  381. <!-- * know what document we are processing at this point. -->
  382. <xsl:variable name="doc.title">
  383. <xsl:call-template name="get.doc.title"/>
  384. </xsl:variable>
  385. <xsl:choose>
  386. <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
  387. toss the namespace and continue. Use the docbook5 namespaced
  388. stylesheets for DocBook5 if you don't want to use this feature.-->
  389. <xsl:when test="$exsl.node.set.available != 0
  390. and (*/self::ng:* or */self::db:*)">
  391. <xsl:call-template name="log.message">
  392. <xsl:with-param name="level">Note</xsl:with-param>
  393. <xsl:with-param name="source" select="$doc.title"/>
  394. <xsl:with-param name="context-desc">
  395. <xsl:text>namesp. cut</xsl:text>
  396. </xsl:with-param>
  397. <xsl:with-param name="message">
  398. <xsl:text>processing stripped document</xsl:text>
  399. </xsl:with-param>
  400. </xsl:call-template>
  401. <xsl:apply-templates select="exsl:node-set($no.namespace)"/>
  402. </xsl:when>
  403. <!-- Can't process unless namespace removed -->
  404. <xsl:when test="*/self::ng:* or */self::db:*">
  405. <xsl:message terminate="yes">
  406. <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
  407. <xsl:text> cannot proceed.</xsl:text>
  408. </xsl:message>
  409. </xsl:when>
  410. <xsl:otherwise>
  411. <xsl:choose>
  412. <xsl:when test="$rootid != ''">
  413. <xsl:choose>
  414. <xsl:when test="count(key('id',$rootid)) = 0">
  415. <xsl:message terminate="yes">
  416. <xsl:text>ID '</xsl:text>
  417. <xsl:value-of select="$rootid"/>
  418. <xsl:text>' not found in document.</xsl:text>
  419. </xsl:message>
  420. </xsl:when>
  421. <xsl:otherwise>
  422. <xsl:if test="$collect.xref.targets = 'yes' or
  423. $collect.xref.targets = 'only'">
  424. <xsl:apply-templates select="key('id', $rootid)"
  425. mode="collect.targets"/>
  426. </xsl:if>
  427. <xsl:if test="$collect.xref.targets != 'only'">
  428. <xsl:apply-templates select="key('id',$rootid)"
  429. mode="process.root"/>
  430. <xsl:if test="$tex.math.in.alt != ''">
  431. <xsl:apply-templates select="key('id',$rootid)"
  432. mode="collect.tex.math"/>
  433. </xsl:if>
  434. <xsl:if test="$generate.manifest != 0">
  435. <xsl:call-template name="generate.manifest">
  436. <xsl:with-param name="node" select="key('id',$rootid)"/>
  437. </xsl:call-template>
  438. </xsl:if>
  439. </xsl:if>
  440. </xsl:otherwise>
  441. </xsl:choose>
  442. </xsl:when>
  443. <xsl:otherwise>
  444. <xsl:if test="$collect.xref.targets = 'yes' or
  445. $collect.xref.targets = 'only'">
  446. <xsl:apply-templates select="/" mode="collect.targets"/>
  447. </xsl:if>
  448. <xsl:if test="$collect.xref.targets != 'only'">
  449. <xsl:apply-templates select="/" mode="process.root"/>
  450. <xsl:if test="$tex.math.in.alt != ''">
  451. <xsl:apply-templates select="/" mode="collect.tex.math"/>
  452. </xsl:if>
  453. <xsl:if test="$generate.manifest != 0">
  454. <xsl:call-template name="generate.manifest">
  455. <xsl:with-param name="node" select="/"/>
  456. </xsl:call-template>
  457. </xsl:if>
  458. </xsl:if>
  459. </xsl:otherwise>
  460. </xsl:choose>
  461. </xsl:otherwise>
  462. </xsl:choose>
  463. </xsl:template>
  464. <xsl:template match="*" mode="process.root">
  465. <xsl:apply-templates select="."/>
  466. <xsl:call-template name="generate.css.files"/>
  467. </xsl:template>
  468. <!-- ====================================================================== -->
  469. <xsl:template match="set|book|part|preface|chapter|appendix
  470. |article
  471. |topic
  472. |reference|refentry
  473. |book/glossary|article/glossary|part/glossary
  474. |book/bibliography|article/bibliography|part/bibliography
  475. |colophon">
  476. <xsl:choose>
  477. <xsl:when test="$onechunk != 0 and parent::*">
  478. <xsl:apply-imports/>
  479. </xsl:when>
  480. <xsl:otherwise>
  481. <xsl:call-template name="process-chunk-element"/>
  482. </xsl:otherwise>
  483. </xsl:choose>
  484. </xsl:template>
  485. <xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
  486. <xsl:variable name="ischunk">
  487. <xsl:call-template name="chunk"/>
  488. </xsl:variable>
  489. <xsl:choose>
  490. <xsl:when test="not(parent::*)">
  491. <xsl:call-template name="process-chunk-element"/>
  492. </xsl:when>
  493. <xsl:when test="$ischunk = 0">
  494. <xsl:apply-imports/>
  495. </xsl:when>
  496. <xsl:otherwise>
  497. <xsl:call-template name="process-chunk-element"/>
  498. </xsl:otherwise>
  499. </xsl:choose>
  500. </xsl:template>
  501. <xsl:template match="setindex
  502. |book/index
  503. |article/index
  504. |part/index">
  505. <!-- some implementations use completely empty index tags to indicate -->
  506. <!-- where an automatically generated index should be inserted. so -->
  507. <!-- if the index is completely empty, skip it. -->
  508. <xsl:if test="count(*)>0 or $generate.index != '0'">
  509. <xsl:call-template name="process-chunk-element"/>
  510. </xsl:if>
  511. </xsl:template>
  512. <!-- Resolve xml:base attributes -->
  513. <xsl:template match="@fileref">
  514. <!-- need a check for absolute urls -->
  515. <xsl:choose>
  516. <xsl:when test="contains(., ':')">
  517. <!-- it has a uri scheme so it is an absolute uri -->
  518. <xsl:value-of select="."/>
  519. </xsl:when>
  520. <xsl:when test="$keep.relative.image.uris != 0">
  521. <!-- leave it alone -->
  522. <xsl:value-of select="."/>
  523. </xsl:when>
  524. <xsl:otherwise>
  525. <!-- its a relative uri -->
  526. <xsl:call-template name="relative-uri">
  527. <xsl:with-param name="destdir">
  528. <xsl:call-template name="dbhtml-dir">
  529. <xsl:with-param name="context" select=".."/>
  530. </xsl:call-template>
  531. </xsl:with-param>
  532. </xsl:call-template>
  533. </xsl:otherwise>
  534. </xsl:choose>
  535. </xsl:template>
  536. <!-- ==================================================================== -->
  537. <xsl:template match="set|book|part|preface|chapter|appendix
  538. |article
  539. |topic
  540. |reference|refentry
  541. |sect1|sect2|sect3|sect4|sect5
  542. |section
  543. |book/glossary|article/glossary|part/glossary
  544. |book/bibliography|article/bibliography|part/bibliography
  545. |colophon"
  546. mode="enumerate-files">
  547. <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
  548. <xsl:if test="$ischunk='1'">
  549. <xsl:call-template name="make-relative-filename">
  550. <xsl:with-param name="base.dir">
  551. <xsl:if test="$manifest.in.base.dir = 0">
  552. <xsl:value-of select="$chunk.base.dir"/>
  553. </xsl:if>
  554. </xsl:with-param>
  555. <xsl:with-param name="base.name">
  556. <xsl:apply-templates mode="chunk-filename" select="."/>
  557. </xsl:with-param>
  558. </xsl:call-template>
  559. <xsl:text>&#10;</xsl:text>
  560. </xsl:if>
  561. <xsl:apply-templates select="*" mode="enumerate-files"/>
  562. </xsl:template>
  563. <xsl:template match="book/index|article/index|part/index"
  564. mode="enumerate-files">
  565. <xsl:if test="$htmlhelp.output != 1">
  566. <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
  567. <xsl:if test="$ischunk='1'">
  568. <xsl:call-template name="make-relative-filename">
  569. <xsl:with-param name="base.dir">
  570. <xsl:if test="$manifest.in.base.dir = 0">
  571. <xsl:value-of select="$chunk.base.dir"/>
  572. </xsl:if>
  573. </xsl:with-param>
  574. <xsl:with-param name="base.name">
  575. <xsl:apply-templates mode="chunk-filename" select="."/>
  576. </xsl:with-param>
  577. </xsl:call-template>
  578. <xsl:text>&#10;</xsl:text>
  579. </xsl:if>
  580. <xsl:apply-templates select="*" mode="enumerate-files"/>
  581. </xsl:if>
  582. </xsl:template>
  583. <xsl:template match="legalnotice" mode="enumerate-files">
  584. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  585. <xsl:if test="$generate.legalnotice.link != 0">
  586. <xsl:call-template name="make-relative-filename">
  587. <xsl:with-param name="base.dir">
  588. <xsl:if test="$manifest.in.base.dir = 0">
  589. <xsl:value-of select="$chunk.base.dir"/>
  590. </xsl:if>
  591. </xsl:with-param>
  592. <xsl:with-param name="base.name">
  593. <xsl:apply-templates mode="chunk-filename" select="."/>
  594. </xsl:with-param>
  595. </xsl:call-template>
  596. <xsl:text>&#10;</xsl:text>
  597. </xsl:if>
  598. </xsl:template>
  599. <xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files">
  600. <xsl:variable name="longdesc.uri">
  601. <xsl:call-template name="longdesc.uri">
  602. <xsl:with-param name="mediaobject"
  603. select="."/>
  604. </xsl:call-template>
  605. </xsl:variable>
  606. <xsl:variable name="mediaobject" select="."/>
  607. <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
  608. <xsl:call-template name="longdesc.uri">
  609. <xsl:with-param name="mediaobject" select="$mediaobject"/>
  610. </xsl:call-template>
  611. <xsl:text>&#10;</xsl:text>
  612. </xsl:if>
  613. </xsl:template>
  614. <xsl:template match="text()" mode="enumerate-files">
  615. </xsl:template>
  616. </xsl:stylesheet>