profile-chunk-code.xsl 24 KB

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