profile-chunk-code.xsl 24 KB

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