chunk-common.xsl 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545
  1. <?xml version="1.0" encoding="ASCII"?>
  2. <!--This file was created automatically by html2xhtml-->
  3. <!--from the HTML 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="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="exsl cf ng db">
  5. <!-- ********************************************************************
  6. $Id$
  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:param name="onechunk" select="0"/>
  14. <xsl:param name="refentry.separator" select="0"/>
  15. <xsl:param name="chunk.fast" select="0"/>
  16. <xsl:key name="genid" match="*" use="generate-id()"/>
  17. <!-- ==================================================================== -->
  18. <xsl:variable name="chunk.hierarchy">
  19. <xsl:if test="$chunk.fast != 0">
  20. <xsl:choose>
  21. <xsl:when test="function-available('exsl:node-set')">
  22. <xsl:message>Computing chunks...</xsl:message>
  23. <xsl:apply-templates select="/*" mode="find.chunks"/>
  24. </xsl:when>
  25. <xsl:otherwise>
  26. <xsl:message>
  27. <xsl:text>Fast chunking requires exsl:node-set(). </xsl:text>
  28. <xsl:text>Using "slow" chunking.</xsl:text>
  29. </xsl:message>
  30. </xsl:otherwise>
  31. </xsl:choose>
  32. </xsl:if>
  33. </xsl:variable>
  34. <!-- ==================================================================== -->
  35. <xsl:template name="process-chunk-element">
  36. <xsl:param name="content">
  37. <xsl:apply-imports/>
  38. </xsl:param>
  39. <xsl:choose>
  40. <xsl:when test="$chunk.fast != 0 and function-available('exsl:node-set')">
  41. <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
  42. <xsl:variable name="genid" select="generate-id()"/>
  43. <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
  44. <xsl:variable name="prevdiv" select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
  45. <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
  46. <xsl:variable name="nextdiv" select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
  47. <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
  48. <xsl:choose>
  49. <xsl:when test="$onechunk != 0 and parent::*">
  50. <xsl:copy-of select="$content"/>
  51. </xsl:when>
  52. <xsl:otherwise>
  53. <xsl:call-template name="process-chunk">
  54. <xsl:with-param name="prev" select="$prev"/>
  55. <xsl:with-param name="next" select="$next"/>
  56. <xsl:with-param name="content" select="$content"/>
  57. </xsl:call-template>
  58. </xsl:otherwise>
  59. </xsl:choose>
  60. </xsl:when>
  61. <xsl:otherwise>
  62. <xsl:choose>
  63. <xsl:when test="$onechunk != 0 and not(parent::*)">
  64. <xsl:call-template name="chunk-all-sections">
  65. <xsl:with-param name="content" select="$content"/>
  66. </xsl:call-template>
  67. </xsl:when>
  68. <xsl:when test="$onechunk != 0">
  69. <xsl:copy-of select="$content"/>
  70. </xsl:when>
  71. <xsl:when test="$chunk.first.sections = 0">
  72. <xsl:call-template name="chunk-first-section-with-parent">
  73. <xsl:with-param name="content" select="$content"/>
  74. </xsl:call-template>
  75. </xsl:when>
  76. <xsl:otherwise>
  77. <xsl:call-template name="chunk-all-sections">
  78. <xsl:with-param name="content" select="$content"/>
  79. </xsl:call-template>
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. </xsl:otherwise>
  83. </xsl:choose>
  84. </xsl:template>
  85. <xsl:template name="process-chunk">
  86. <xsl:param name="prev" select="."/>
  87. <xsl:param name="next" select="."/>
  88. <xsl:param name="content">
  89. <xsl:apply-imports/>
  90. </xsl:param>
  91. <xsl:variable name="ischunk">
  92. <xsl:call-template name="chunk"/>
  93. </xsl:variable>
  94. <xsl:variable name="chunkfn">
  95. <xsl:if test="$ischunk='1'">
  96. <xsl:apply-templates mode="chunk-filename" select="."/>
  97. </xsl:if>
  98. </xsl:variable>
  99. <xsl:if test="$ischunk='0'">
  100. <xsl:message>
  101. <xsl:text>Error </xsl:text>
  102. <xsl:value-of select="name(.)"/>
  103. <xsl:text> is not a chunk!</xsl:text>
  104. </xsl:message>
  105. </xsl:if>
  106. <xsl:variable name="filename">
  107. <xsl:call-template name="make-relative-filename">
  108. <xsl:with-param name="base.dir" select="$base.dir"/>
  109. <xsl:with-param name="base.name" select="$chunkfn"/>
  110. </xsl:call-template>
  111. </xsl:variable>
  112. <xsl:call-template name="write.chunk">
  113. <xsl:with-param name="filename" select="$filename"/>
  114. <xsl:with-param name="content">
  115. <xsl:call-template name="chunk-element-content">
  116. <xsl:with-param name="prev" select="$prev"/>
  117. <xsl:with-param name="next" select="$next"/>
  118. <xsl:with-param name="content" select="$content"/>
  119. </xsl:call-template>
  120. </xsl:with-param>
  121. <xsl:with-param name="quiet" select="$chunk.quietly"/>
  122. </xsl:call-template>
  123. </xsl:template>
  124. <xsl:template name="chunk-first-section-with-parent">
  125. <xsl:param name="content">
  126. <xsl:apply-imports/>
  127. </xsl:param>
  128. <!-- These xpath expressions are really hairy. The trick is to pick sections -->
  129. <!-- that are not first children and are not the children of first children -->
  130. <!-- Break these variables into pieces to work around
  131. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
  132. <xsl:variable name="prev-v1" select="(ancestor::sect1[$chunk.section.depth &gt; 0 and preceding-sibling::sect1][1] |ancestor::sect2[$chunk.section.depth &gt; 1 and preceding-sibling::sect2 and parent::sect1[preceding-sibling::sect1]][1] |ancestor::sect3[$chunk.section.depth &gt; 2 and preceding-sibling::sect3 and parent::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |ancestor::sect4[$chunk.section.depth &gt; 3 and preceding-sibling::sect4 and parent::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |ancestor::sect5[$chunk.section.depth &gt; 4 and preceding-sibling::sect5 and parent::sect4[preceding-sibling::sect4] and ancestor::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |ancestor::section[$chunk.section.depth &gt; count(ancestor::section) and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
  133. <xsl:variable name="prev-v2" select="(preceding::sect1[$chunk.section.depth &gt; 0 and preceding-sibling::sect1][1] |preceding::sect2[$chunk.section.depth &gt; 1 and preceding-sibling::sect2 and parent::sect1[preceding-sibling::sect1]][1] |preceding::sect3[$chunk.section.depth &gt; 2 and preceding-sibling::sect3 and parent::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |preceding::sect4[$chunk.section.depth &gt; 3 and preceding-sibling::sect4 and parent::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |preceding::sect5[$chunk.section.depth &gt; 4 and preceding-sibling::sect5 and parent::sect4[preceding-sibling::sect4] and ancestor::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |preceding::section[$chunk.section.depth &gt; count(ancestor::section) and preceding-sibling::section and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
  134. <xsl:variable name="prev" select="(preceding::book[1] |preceding::preface[1] |preceding::chapter[1] |preceding::appendix[1] |preceding::part[1] |preceding::reference[1] |preceding::refentry[1] |preceding::colophon[1] |preceding::article[1] |preceding::bibliography[parent::article or parent::book or parent::part][1] |preceding::glossary[parent::article or parent::book or parent::part][1] |preceding::index[$generate.index != 0] [parent::article or parent::book or parent::part][1] |preceding::setindex[$generate.index != 0][1] |ancestor::set |ancestor::book[1] |ancestor::preface[1] |ancestor::chapter[1] |ancestor::appendix[1] |ancestor::part[1] |ancestor::reference[1] |ancestor::article[1] |$prev-v1 |$prev-v2)[last()]"/>
  135. <xsl:variable name="next-v1" select="(following::sect1[$chunk.section.depth &gt; 0 and preceding-sibling::sect1][1] |following::sect2[$chunk.section.depth &gt; 1 and preceding-sibling::sect2 and parent::sect1[preceding-sibling::sect1]][1] |following::sect3[$chunk.section.depth &gt; 2 and preceding-sibling::sect3 and parent::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |following::sect4[$chunk.section.depth &gt; 3 and preceding-sibling::sect4 and parent::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |following::sect5[$chunk.section.depth &gt; 4 and preceding-sibling::sect5 and parent::sect4[preceding-sibling::sect4] and ancestor::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |following::section[$chunk.section.depth &gt; count(ancestor::section) and preceding-sibling::section and not(ancestor::section[not(preceding-sibling::section)])][1])[1]"/>
  136. <xsl:variable name="next-v2" select="(descendant::sect1[$chunk.section.depth &gt; 0 and preceding-sibling::sect1][1] |descendant::sect2[$chunk.section.depth &gt; 1 and preceding-sibling::sect2 and parent::sect1[preceding-sibling::sect1]][1] |descendant::sect3[$chunk.section.depth &gt; 2 and preceding-sibling::sect3 and parent::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |descendant::sect4[$chunk.section.depth &gt; 3 and preceding-sibling::sect4 and parent::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |descendant::sect5[$chunk.section.depth &gt; 4 and preceding-sibling::sect5 and parent::sect4[preceding-sibling::sect4] and ancestor::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |descendant::section[$chunk.section.depth &gt; count(ancestor::section) and preceding-sibling::section and not(ancestor::section[not(preceding-sibling::section)])])[1]"/>
  137. <xsl:variable name="next" select="(following::book[1] |following::preface[1] |following::chapter[1] |following::appendix[1] |following::part[1] |following::reference[1] |following::refentry[1] |following::colophon[1] |following::bibliography[parent::article or parent::book or parent::part][1] |following::glossary[parent::article or parent::book or parent::part][1] |following::index[$generate.index != 0] [parent::article or parent::book or parent::part][1] |following::article[1] |following::setindex[$generate.index != 0][1] |descendant::book[1] |descendant::preface[1] |descendant::chapter[1] |descendant::appendix[1] |descendant::article[1] |descendant::bibliography[parent::article or parent::book or parent::part][1] |descendant::glossary[parent::article or parent::book or parent::part][1] |descendant::index[$generate.index != 0] [parent::article or parent::book or parent::part][1] |descendant::colophon[1] |descendant::setindex[$generate.index != 0][1] |descendant::part[1] |descendant::reference[1] |descendant::refentry[1] |$next-v1 |$next-v2)[1]"/>
  138. <xsl:call-template name="process-chunk">
  139. <xsl:with-param name="prev" select="$prev"/>
  140. <xsl:with-param name="next" select="$next"/>
  141. <xsl:with-param name="content" select="$content"/>
  142. </xsl:call-template>
  143. </xsl:template>
  144. <xsl:template name="chunk-all-sections">
  145. <xsl:param name="content">
  146. <xsl:apply-imports/>
  147. </xsl:param>
  148. <xsl:variable name="prev-v1" select="(preceding::sect1[$chunk.section.depth &gt; 0][1] |preceding::sect2[$chunk.section.depth &gt; 1][1] |preceding::sect3[$chunk.section.depth &gt; 2][1] |preceding::sect4[$chunk.section.depth &gt; 3][1] |preceding::sect5[$chunk.section.depth &gt; 4][1] |preceding::section[$chunk.section.depth &gt; count(ancestor::section)][1])[last()]"/>
  149. <xsl:variable name="prev-v2" select="(ancestor::sect1[$chunk.section.depth &gt; 0][1] |ancestor::sect2[$chunk.section.depth &gt; 1][1] |ancestor::sect3[$chunk.section.depth &gt; 2][1] |ancestor::sect4[$chunk.section.depth &gt; 3][1] |ancestor::sect5[$chunk.section.depth &gt; 4][1] |ancestor::section[$chunk.section.depth &gt; count(ancestor::section)][1])[last()]"/>
  150. <xsl:variable name="prev" select="(preceding::book[1] |preceding::preface[1] |preceding::chapter[1] |preceding::appendix[1] |preceding::part[1] |preceding::reference[1] |preceding::refentry[1] |preceding::colophon[1] |preceding::article[1] |preceding::bibliography[parent::article or parent::book or parent::part][1] |preceding::glossary[parent::article or parent::book or parent::part][1] |preceding::index[$generate.index != 0] [parent::article or parent::book or parent::part][1] |preceding::setindex[$generate.index != 0][1] |ancestor::set |ancestor::book[1] |ancestor::preface[1] |ancestor::chapter[1] |ancestor::appendix[1] |ancestor::part[1] |ancestor::reference[1] |ancestor::article[1] |$prev-v1 |$prev-v2)[last()]"/>
  151. <xsl:variable name="next-v1" select="(following::sect1[$chunk.section.depth &gt; 0][1] |following::sect2[$chunk.section.depth &gt; 1][1] |following::sect3[$chunk.section.depth &gt; 2][1] |following::sect4[$chunk.section.depth &gt; 3][1] |following::sect5[$chunk.section.depth &gt; 4][1] |following::section[$chunk.section.depth &gt; count(ancestor::section)][1])[1]"/>
  152. <xsl:variable name="next-v2" select="(descendant::sect1[$chunk.section.depth &gt; 0][1] |descendant::sect2[$chunk.section.depth &gt; 1][1] |descendant::sect3[$chunk.section.depth &gt; 2][1] |descendant::sect4[$chunk.section.depth &gt; 3][1] |descendant::sect5[$chunk.section.depth &gt; 4][1] |descendant::section[$chunk.section.depth &gt; count(ancestor::section)][1])[1]"/>
  153. <xsl:variable name="next" select="(following::book[1] |following::preface[1] |following::chapter[1] |following::appendix[1] |following::part[1] |following::reference[1] |following::refentry[1] |following::colophon[1] |following::bibliography[parent::article or parent::book or parent::part][1] |following::glossary[parent::article or parent::book or parent::part][1] |following::index[$generate.index != 0] [parent::article or parent::book][1] |following::article[1] |following::setindex[$generate.index != 0][1] |descendant::book[1] |descendant::preface[1] |descendant::chapter[1] |descendant::appendix[1] |descendant::article[1] |descendant::bibliography[parent::article or parent::book][1] |descendant::glossary[parent::article or parent::book or parent::part][1] |descendant::index[$generate.index != 0] [parent::article or parent::book][1] |descendant::colophon[1] |descendant::setindex[$generate.index != 0][1] |descendant::part[1] |descendant::reference[1] |descendant::refentry[1] |$next-v1 |$next-v2)[1]"/>
  154. <xsl:call-template name="process-chunk">
  155. <xsl:with-param name="prev" select="$prev"/>
  156. <xsl:with-param name="next" select="$next"/>
  157. <xsl:with-param name="content" select="$content"/>
  158. </xsl:call-template>
  159. </xsl:template>
  160. <!-- ==================================================================== -->
  161. <!-- ==================================================================== -->
  162. <xsl:template name="make.lots">
  163. <xsl:param name="toc.params" select="''"/>
  164. <xsl:param name="toc"/>
  165. <xsl:variable name="lots">
  166. <xsl:if test="contains($toc.params, 'toc')">
  167. <xsl:copy-of select="$toc"/>
  168. </xsl:if>
  169. <xsl:if test="contains($toc.params, 'figure')">
  170. <xsl:choose>
  171. <xsl:when test="$chunk.separate.lots != '0'">
  172. <xsl:call-template name="make.lot.chunk">
  173. <xsl:with-param name="type" select="'figure'"/>
  174. <xsl:with-param name="lot">
  175. <xsl:call-template name="list.of.titles">
  176. <xsl:with-param name="titles" select="'figure'"/>
  177. <xsl:with-param name="nodes" select=".//figure"/>
  178. </xsl:call-template>
  179. </xsl:with-param>
  180. </xsl:call-template>
  181. </xsl:when>
  182. <xsl:otherwise>
  183. <xsl:call-template name="list.of.titles">
  184. <xsl:with-param name="titles" select="'figure'"/>
  185. <xsl:with-param name="nodes" select=".//figure"/>
  186. </xsl:call-template>
  187. </xsl:otherwise>
  188. </xsl:choose>
  189. </xsl:if>
  190. <xsl:if test="contains($toc.params, 'table')">
  191. <xsl:choose>
  192. <xsl:when test="$chunk.separate.lots != '0'">
  193. <xsl:call-template name="make.lot.chunk">
  194. <xsl:with-param name="type" select="'table'"/>
  195. <xsl:with-param name="lot">
  196. <xsl:call-template name="list.of.titles">
  197. <xsl:with-param name="titles" select="'table'"/>
  198. <xsl:with-param name="nodes" select=".//table"/>
  199. </xsl:call-template>
  200. </xsl:with-param>
  201. </xsl:call-template>
  202. </xsl:when>
  203. <xsl:otherwise>
  204. <xsl:call-template name="list.of.titles">
  205. <xsl:with-param name="titles" select="'table'"/>
  206. <xsl:with-param name="nodes" select=".//table"/>
  207. </xsl:call-template>
  208. </xsl:otherwise>
  209. </xsl:choose>
  210. </xsl:if>
  211. <xsl:if test="contains($toc.params, 'example')">
  212. <xsl:choose>
  213. <xsl:when test="$chunk.separate.lots != '0'">
  214. <xsl:call-template name="make.lot.chunk">
  215. <xsl:with-param name="type" select="'example'"/>
  216. <xsl:with-param name="lot">
  217. <xsl:call-template name="list.of.titles">
  218. <xsl:with-param name="titles" select="'example'"/>
  219. <xsl:with-param name="nodes" select=".//example"/>
  220. </xsl:call-template>
  221. </xsl:with-param>
  222. </xsl:call-template>
  223. </xsl:when>
  224. <xsl:otherwise>
  225. <xsl:call-template name="list.of.titles">
  226. <xsl:with-param name="titles" select="'example'"/>
  227. <xsl:with-param name="nodes" select=".//example"/>
  228. </xsl:call-template>
  229. </xsl:otherwise>
  230. </xsl:choose>
  231. </xsl:if>
  232. <xsl:if test="contains($toc.params, 'equation')">
  233. <xsl:choose>
  234. <xsl:when test="$chunk.separate.lots != '0'">
  235. <xsl:call-template name="make.lot.chunk">
  236. <xsl:with-param name="type" select="'equation'"/>
  237. <xsl:with-param name="lot">
  238. <xsl:call-template name="list.of.titles">
  239. <xsl:with-param name="titles" select="'equation'"/>
  240. <xsl:with-param name="nodes" select=".//equation"/>
  241. </xsl:call-template>
  242. </xsl:with-param>
  243. </xsl:call-template>
  244. </xsl:when>
  245. <xsl:otherwise>
  246. <xsl:call-template name="list.of.titles">
  247. <xsl:with-param name="titles" select="'equation'"/>
  248. <xsl:with-param name="nodes" select=".//equation"/>
  249. </xsl:call-template>
  250. </xsl:otherwise>
  251. </xsl:choose>
  252. </xsl:if>
  253. <xsl:if test="contains($toc.params, 'procedure')">
  254. <xsl:choose>
  255. <xsl:when test="$chunk.separate.lots != '0'">
  256. <xsl:call-template name="make.lot.chunk">
  257. <xsl:with-param name="type" select="'procedure'"/>
  258. <xsl:with-param name="lot">
  259. <xsl:call-template name="list.of.titles">
  260. <xsl:with-param name="titles" select="'procedure'"/>
  261. <xsl:with-param name="nodes" select=".//procedure[title]"/>
  262. </xsl:call-template>
  263. </xsl:with-param>
  264. </xsl:call-template>
  265. </xsl:when>
  266. <xsl:otherwise>
  267. <xsl:call-template name="list.of.titles">
  268. <xsl:with-param name="titles" select="'procedure'"/>
  269. <xsl:with-param name="nodes" select=".//procedure[title]"/>
  270. </xsl:call-template>
  271. </xsl:otherwise>
  272. </xsl:choose>
  273. </xsl:if>
  274. </xsl:variable>
  275. <xsl:if test="string($lots) != ''">
  276. <xsl:choose>
  277. <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
  278. <xsl:call-template name="write.chunk">
  279. <xsl:with-param name="filename">
  280. <xsl:call-template name="make-relative-filename">
  281. <xsl:with-param name="base.dir" select="$base.dir"/>
  282. <xsl:with-param name="base.name">
  283. <xsl:call-template name="dbhtml-dir"/>
  284. <xsl:apply-templates select="." mode="recursive-chunk-filename">
  285. <xsl:with-param name="recursive" select="true()"/>
  286. </xsl:apply-templates>
  287. <xsl:text>-toc</xsl:text>
  288. <xsl:value-of select="$html.ext"/>
  289. </xsl:with-param>
  290. </xsl:call-template>
  291. </xsl:with-param>
  292. <xsl:with-param name="content">
  293. <xsl:call-template name="chunk-element-content">
  294. <xsl:with-param name="prev" select="/foo"/>
  295. <xsl:with-param name="next" select="/foo"/>
  296. <xsl:with-param name="nav.context" select="'toc'"/>
  297. <xsl:with-param name="content">
  298. <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
  299. <h1>
  300. <xsl:apply-templates select="." mode="object.title.markup"/>
  301. </h1>
  302. </xsl:if>
  303. <xsl:copy-of select="$lots"/>
  304. </xsl:with-param>
  305. </xsl:call-template>
  306. </xsl:with-param>
  307. <xsl:with-param name="quiet" select="$chunk.quietly"/>
  308. </xsl:call-template>
  309. </xsl:when>
  310. <xsl:otherwise>
  311. <xsl:copy-of select="$lots"/>
  312. </xsl:otherwise>
  313. </xsl:choose>
  314. </xsl:if>
  315. </xsl:template>
  316. <xsl:template name="make.lot.chunk">
  317. <xsl:param name="type" select="''"/>
  318. <xsl:param name="lot"/>
  319. <xsl:if test="string($lot) != ''">
  320. <xsl:variable name="filename">
  321. <xsl:call-template name="make-relative-filename">
  322. <xsl:with-param name="base.dir" select="$base.dir"/>
  323. <xsl:with-param name="base.name">
  324. <xsl:call-template name="dbhtml-dir"/>
  325. <xsl:value-of select="$type"/>
  326. <xsl:text>-toc</xsl:text>
  327. <xsl:value-of select="$html.ext"/>
  328. </xsl:with-param>
  329. </xsl:call-template>
  330. </xsl:variable>
  331. <xsl:variable name="href">
  332. <xsl:call-template name="make-relative-filename">
  333. <xsl:with-param name="base.name">
  334. <xsl:call-template name="dbhtml-dir"/>
  335. <xsl:value-of select="$type"/>
  336. <xsl:text>-toc</xsl:text>
  337. <xsl:value-of select="$html.ext"/>
  338. </xsl:with-param>
  339. </xsl:call-template>
  340. </xsl:variable>
  341. <xsl:call-template name="write.chunk">
  342. <xsl:with-param name="filename" select="$filename"/>
  343. <xsl:with-param name="content">
  344. <xsl:call-template name="chunk-element-content">
  345. <xsl:with-param name="prev" select="/foo"/>
  346. <xsl:with-param name="next" select="/foo"/>
  347. <xsl:with-param name="nav.context" select="'toc'"/>
  348. <xsl:with-param name="content">
  349. <xsl:copy-of select="$lot"/>
  350. </xsl:with-param>
  351. </xsl:call-template>
  352. </xsl:with-param>
  353. <xsl:with-param name="quiet" select="$chunk.quietly"/>
  354. </xsl:call-template>
  355. <!-- And output a link to this file -->
  356. <div>
  357. <xsl:attribute name="class">
  358. <xsl:text>ListofTitles</xsl:text>
  359. </xsl:attribute>
  360. <a href="{$href}">
  361. <xsl:call-template name="gentext">
  362. <xsl:with-param name="key">
  363. <xsl:choose>
  364. <xsl:when test="$type='table'">ListofTables</xsl:when>
  365. <xsl:when test="$type='figure'">ListofFigures</xsl:when>
  366. <xsl:when test="$type='equation'">ListofEquations</xsl:when>
  367. <xsl:when test="$type='example'">ListofExamples</xsl:when>
  368. <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
  369. <xsl:otherwise>ListofUnknown</xsl:otherwise>
  370. </xsl:choose>
  371. </xsl:with-param>
  372. </xsl:call-template>
  373. </a>
  374. </div>
  375. </xsl:if>
  376. </xsl:template>
  377. <!-- ==================================================================== -->
  378. <xsl:template name="in.other.chunk">
  379. <xsl:param name="chunk" select="."/>
  380. <xsl:param name="node" select="."/>
  381. <xsl:variable name="is.chunk">
  382. <xsl:call-template name="chunk">
  383. <xsl:with-param name="node" select="$node"/>
  384. </xsl:call-template>
  385. </xsl:variable>
  386. <!--
  387. <xsl:message>
  388. <xsl:text>in.other.chunk: </xsl:text>
  389. <xsl:value-of select="name($chunk)"/>
  390. <xsl:text> </xsl:text>
  391. <xsl:value-of select="name($node)"/>
  392. <xsl:text> </xsl:text>
  393. <xsl:value-of select="$chunk = $node"/>
  394. <xsl:text> </xsl:text>
  395. <xsl:value-of select="$is.chunk"/>
  396. </xsl:message>
  397. -->
  398. <xsl:choose>
  399. <xsl:when test="$chunk = $node">0</xsl:when>
  400. <xsl:when test="$is.chunk = 1">1</xsl:when>
  401. <xsl:when test="count($node) = 0">0</xsl:when>
  402. <xsl:otherwise>
  403. <xsl:call-template name="in.other.chunk">
  404. <xsl:with-param name="chunk" select="$chunk"/>
  405. <xsl:with-param name="node" select="$node/parent::*"/>
  406. </xsl:call-template>
  407. </xsl:otherwise>
  408. </xsl:choose>
  409. </xsl:template>
  410. <xsl:template name="count.footnotes.in.this.chunk">
  411. <xsl:param name="node" select="."/>
  412. <xsl:param name="footnotes" select="$node//footnote"/>
  413. <xsl:param name="count" select="0"/>
  414. <!--
  415. <xsl:message>
  416. <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
  417. <xsl:value-of select="name($node)"/>
  418. </xsl:message>
  419. -->
  420. <xsl:variable name="in.other.chunk">
  421. <xsl:call-template name="in.other.chunk">
  422. <xsl:with-param name="chunk" select="$node"/>
  423. <xsl:with-param name="node" select="$footnotes[1]"/>
  424. </xsl:call-template>
  425. </xsl:variable>
  426. <xsl:choose>
  427. <xsl:when test="count($footnotes) = 0">
  428. <xsl:value-of select="$count"/>
  429. </xsl:when>
  430. <xsl:otherwise>
  431. <xsl:choose>
  432. <xsl:when test="$in.other.chunk != 0">
  433. <xsl:call-template name="count.footnotes.in.this.chunk">
  434. <xsl:with-param name="node" select="$node"/>
  435. <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
  436. <xsl:with-param name="count" select="$count"/>
  437. </xsl:call-template>
  438. </xsl:when>
  439. <xsl:when test="$footnotes[1]/ancestor::table |$footnotes[1]/ancestor::informaltable">
  440. <xsl:call-template name="count.footnotes.in.this.chunk">
  441. <xsl:with-param name="node" select="$node"/>
  442. <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
  443. <xsl:with-param name="count" select="$count"/>
  444. </xsl:call-template>
  445. </xsl:when>
  446. <xsl:otherwise>
  447. <xsl:call-template name="count.footnotes.in.this.chunk">
  448. <xsl:with-param name="node" select="$node"/>
  449. <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
  450. <xsl:with-param name="count" select="$count + 1"/>
  451. </xsl:call-template>
  452. </xsl:otherwise>
  453. </xsl:choose>
  454. </xsl:otherwise>
  455. </xsl:choose>
  456. </xsl:template>
  457. <xsl:template name="process.footnotes.in.this.chunk">
  458. <xsl:param name="node" select="."/>
  459. <xsl:param name="footnotes" select="$node//footnote"/>
  460. <!--
  461. <xsl:message>process.footnotes.in.this.chunk</xsl:message>
  462. -->
  463. <xsl:variable name="in.other.chunk">
  464. <xsl:call-template name="in.other.chunk">
  465. <xsl:with-param name="chunk" select="$node"/>
  466. <xsl:with-param name="node" select="$footnotes[1]"/>
  467. </xsl:call-template>
  468. </xsl:variable>
  469. <xsl:choose>
  470. <xsl:when test="count($footnotes) = 0">
  471. <!-- nop -->
  472. </xsl:when>
  473. <xsl:otherwise>
  474. <xsl:choose>
  475. <xsl:when test="$in.other.chunk != 0">
  476. <xsl:call-template name="process.footnotes.in.this.chunk">
  477. <xsl:with-param name="node" select="$node"/>
  478. <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
  479. </xsl:call-template>
  480. </xsl:when>
  481. <xsl:when test="$footnotes[1]/ancestor::table |$footnotes[1]/ancestor::informaltable">
  482. <xsl:call-template name="process.footnotes.in.this.chunk">
  483. <xsl:with-param name="node" select="$node"/>
  484. <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
  485. </xsl:call-template>
  486. </xsl:when>
  487. <xsl:otherwise>
  488. <xsl:apply-templates select="$footnotes[1]" mode="process.footnote.mode"/>
  489. <xsl:call-template name="process.footnotes.in.this.chunk">
  490. <xsl:with-param name="node" select="$node"/>
  491. <xsl:with-param name="footnotes" select="$footnotes[position() &gt; 1]"/>
  492. </xsl:call-template>
  493. </xsl:otherwise>
  494. </xsl:choose>
  495. </xsl:otherwise>
  496. </xsl:choose>
  497. </xsl:template>
  498. <xsl:template name="process.footnotes">
  499. <xsl:variable name="footnotes" select=".//footnote"/>
  500. <xsl:variable name="fcount">
  501. <xsl:call-template name="count.footnotes.in.this.chunk">
  502. <xsl:with-param name="node" select="."/>
  503. <xsl:with-param name="footnotes" select="$footnotes"/>
  504. </xsl:call-template>
  505. </xsl:variable>
  506. <!--
  507. <xsl:message>
  508. <xsl:value-of select="name(.)"/>
  509. <xsl:text> fcount: </xsl:text>
  510. <xsl:value-of select="$fcount"/>
  511. </xsl:message>
  512. -->
  513. <!-- Only bother to do this if there's at least one non-table footnote -->
  514. <xsl:if test="$fcount &gt; 0">
  515. <div class="footnotes">
  516. <br/>
  517. <hr width="100" align="left"/>
  518. <xsl:call-template name="process.footnotes.in.this.chunk">
  519. <xsl:with-param name="node" select="."/>
  520. <xsl:with-param name="footnotes" select="$footnotes"/>
  521. </xsl:call-template>
  522. </div>
  523. </xsl:if>
  524. <!-- FIXME: When chunking, only the annotations actually used
  525. in this chunk should be referenced. I don't think it
  526. does any harm to reference them all, but it adds
  527. unnecessary bloat to each chunk. -->
  528. <xsl:if test="$annotation.support != 0 and //annotation">
  529. <div class="annotation-list">
  530. <div class="annotation-nocss">
  531. <p>The following annotations are from this essay. You are seeing
  532. them here because your browser doesn&#8217;t support the user-interface
  533. techniques used to make them appear as &#8216;popups&#8217; on modern browsers.</p>
  534. </div>
  535. <xsl:apply-templates select="//annotation" mode="annotation-popup"/>
  536. </div>
  537. </xsl:if>
  538. </xsl:template>
  539. <xsl:template name="process.chunk.footnotes">
  540. <xsl:variable name="is.chunk">
  541. <xsl:call-template name="chunk"/>
  542. </xsl:variable>
  543. <xsl:if test="$is.chunk = 1">
  544. <xsl:call-template name="process.footnotes"/>
  545. </xsl:if>
  546. </xsl:template>
  547. <!-- ====================================================================== -->
  548. <xsl:template name="chunk">
  549. <xsl:param name="node" select="."/>
  550. <!-- returns 1 if $node is a chunk -->
  551. <!-- ==================================================================== -->
  552. <!-- What's a chunk?
  553. The root element
  554. appendix
  555. article
  556. bibliography in article or part or book
  557. book
  558. chapter
  559. colophon
  560. glossary in article or part or book
  561. index in article or part or book
  562. part
  563. preface
  564. refentry
  565. reference
  566. sect{1,2,3,4,5} if position()>1 && depth < chunk.section.depth
  567. section if position()>1 && depth < chunk.section.depth
  568. set
  569. setindex
  570. -->
  571. <!-- ==================================================================== -->
  572. <!--
  573. <xsl:message>
  574. <xsl:text>chunk: </xsl:text>
  575. <xsl:value-of select="name($node)"/>
  576. <xsl:text>(</xsl:text>
  577. <xsl:value-of select="$node/@id"/>
  578. <xsl:text>)</xsl:text>
  579. <xsl:text> csd: </xsl:text>
  580. <xsl:value-of select="$chunk.section.depth"/>
  581. <xsl:text> cfs: </xsl:text>
  582. <xsl:value-of select="$chunk.first.sections"/>
  583. <xsl:text> ps: </xsl:text>
  584. <xsl:value-of select="count($node/parent::section)"/>
  585. <xsl:text> prs: </xsl:text>
  586. <xsl:value-of select="count($node/preceding-sibling::section)"/>
  587. </xsl:message>
  588. -->
  589. <xsl:choose>
  590. <xsl:when test="not($node/parent::*)">1</xsl:when>
  591. <xsl:when test="local-name($node) = 'sect1' and $chunk.section.depth &gt;= 1 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect1) &gt; 0)">
  592. <xsl:text>1</xsl:text>
  593. </xsl:when>
  594. <xsl:when test="local-name($node) = 'sect2' and $chunk.section.depth &gt;= 2 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect2) &gt; 0)">
  595. <xsl:call-template name="chunk">
  596. <xsl:with-param name="node" select="$node/parent::*"/>
  597. </xsl:call-template>
  598. </xsl:when>
  599. <xsl:when test="local-name($node) = 'sect3' and $chunk.section.depth &gt;= 3 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect3) &gt; 0)">
  600. <xsl:call-template name="chunk">
  601. <xsl:with-param name="node" select="$node/parent::*"/>
  602. </xsl:call-template>
  603. </xsl:when>
  604. <xsl:when test="local-name($node) = 'sect4' and $chunk.section.depth &gt;= 4 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect4) &gt; 0)">
  605. <xsl:call-template name="chunk">
  606. <xsl:with-param name="node" select="$node/parent::*"/>
  607. </xsl:call-template>
  608. </xsl:when>
  609. <xsl:when test="local-name($node) = 'sect5' and $chunk.section.depth &gt;= 5 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect5) &gt; 0)">
  610. <xsl:call-template name="chunk">
  611. <xsl:with-param name="node" select="$node/parent::*"/>
  612. </xsl:call-template>
  613. </xsl:when>
  614. <xsl:when test="local-name($node) = 'section' and $chunk.section.depth &gt;= count($node/ancestor::section)+1 and ($chunk.first.sections != 0 or count($node/preceding-sibling::section) &gt; 0)">
  615. <xsl:call-template name="chunk">
  616. <xsl:with-param name="node" select="$node/parent::*"/>
  617. </xsl:call-template>
  618. </xsl:when>
  619. <xsl:when test="local-name($node)='preface'">1</xsl:when>
  620. <xsl:when test="local-name($node)='chapter'">1</xsl:when>
  621. <xsl:when test="local-name($node)='appendix'">1</xsl:when>
  622. <xsl:when test="local-name($node)='article'">1</xsl:when>
  623. <xsl:when test="local-name($node)='part'">1</xsl:when>
  624. <xsl:when test="local-name($node)='reference'">1</xsl:when>
  625. <xsl:when test="local-name($node)='refentry'">1</xsl:when>
  626. <xsl:when test="local-name($node)='index' and ($generate.index != 0 or count($node/*) &gt; 0) and (local-name($node/parent::*) = 'article' or local-name($node/parent::*) = 'book' or local-name($node/parent::*) = 'part' )">1</xsl:when>
  627. <xsl:when test="local-name($node)='bibliography' and (local-name($node/parent::*) = 'article' or local-name($node/parent::*) = 'book' or local-name($node/parent::*) = 'part' )">1</xsl:when>
  628. <xsl:when test="local-name($node)='glossary' and (local-name($node/parent::*) = 'article' or local-name($node/parent::*) = 'book' or local-name($node/parent::*) = 'part' )">1</xsl:when>
  629. <xsl:when test="local-name($node)='colophon'">1</xsl:when>
  630. <xsl:when test="local-name($node)='book'">1</xsl:when>
  631. <xsl:when test="local-name($node)='set'">1</xsl:when>
  632. <xsl:when test="local-name($node)='setindex'">1</xsl:when>
  633. <xsl:when test="local-name($node)='legalnotice' and $generate.legalnotice.link != 0">1</xsl:when>
  634. <xsl:otherwise>0</xsl:otherwise>
  635. </xsl:choose>
  636. </xsl:template>
  637. <!-- ==================================================================== -->
  638. <xsl:template name="href.target.uri">
  639. <xsl:param name="object" select="."/>
  640. <xsl:variable name="ischunk">
  641. <xsl:call-template name="chunk">
  642. <xsl:with-param name="node" select="$object"/>
  643. </xsl:call-template>
  644. </xsl:variable>
  645. <xsl:apply-templates mode="chunk-filename" select="$object"/>
  646. <xsl:if test="$ischunk='0'">
  647. <xsl:text>#</xsl:text>
  648. <xsl:call-template name="object.id">
  649. <xsl:with-param name="object" select="$object"/>
  650. </xsl:call-template>
  651. </xsl:if>
  652. </xsl:template>
  653. <xsl:template name="href.target">
  654. <xsl:param name="context" select="."/>
  655. <xsl:param name="object" select="."/>
  656. <xsl:param name="toc-context" select="."/>
  657. <!-- * If $toc-context contains some node other than the current node, -->
  658. <!-- * it means we're processing a link in a TOC. In that case, to -->
  659. <!-- * ensure the link will work correctly, we need to take a look at -->
  660. <!-- * where the file containing the TOC will get written, and where -->
  661. <!-- * the file that's being linked to will get written. -->
  662. <xsl:variable name="toc-output-dir">
  663. <xsl:if test="not($toc-context = .)">
  664. <!-- * Get the $toc-context node and all its ancestors, look down -->
  665. <!-- * through them to find the last/closest node to the -->
  666. <!-- * toc-context node that has a "dbhtml dir" PI, and get the -->
  667. <!-- * directory name from that. That's the name of the directory -->
  668. <!-- * to which the current toc output file will get written. -->
  669. <xsl:call-template name="dbhtml-dir">
  670. <xsl:with-param name="context" select="$toc-context/ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
  671. </xsl:call-template>
  672. </xsl:if>
  673. </xsl:variable>
  674. <xsl:variable name="linked-file-output-dir">
  675. <xsl:if test="not($toc-context = .)">
  676. <!-- * Get the current node and all its ancestors, look down -->
  677. <!-- * through them to find the last/closest node to the current -->
  678. <!-- * node that has a "dbhtml dir" PI, and get the directory name -->
  679. <!-- * from that. That's the name of the directory to which the -->
  680. <!-- * file that's being linked to will get written. -->
  681. <xsl:call-template name="dbhtml-dir">
  682. <xsl:with-param name="context" select="ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
  683. </xsl:call-template>
  684. </xsl:if>
  685. </xsl:variable>
  686. <xsl:variable name="href.to.uri">
  687. <xsl:call-template name="href.target.uri">
  688. <xsl:with-param name="object" select="$object"/>
  689. </xsl:call-template>
  690. </xsl:variable>
  691. <xsl:variable name="href.from.uri">
  692. <xsl:call-template name="href.target.uri">
  693. <xsl:with-param name="object" select="$context"/>
  694. </xsl:call-template>
  695. </xsl:variable>
  696. <!-- * <xsl:message>toc-context: <xsl:value-of select="local-name($toc-context)"/></xsl:message> -->
  697. <!-- * <xsl:message>node: <xsl:value-of select="local-name(.)"/></xsl:message> -->
  698. <!-- * <xsl:message>context: <xsl:value-of select="local-name($context)"/></xsl:message> -->
  699. <!-- * <xsl:message>object: <xsl:value-of select="local-name($object)"/></xsl:message> -->
  700. <!-- * <xsl:message>toc-output-dir: <xsl:value-of select="$toc-output-dir"/></xsl:message> -->
  701. <!-- * <xsl:message>linked-file-output-dir: <xsl:value-of select="$linked-file-output-dir"/></xsl:message> -->
  702. <!-- * <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> -->
  703. <!-- * <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> -->
  704. <xsl:variable name="href.to">
  705. <xsl:choose>
  706. <!-- * 2007-07-19, MikeSmith: Added the following conditional to -->
  707. <!-- * deal with a problem case for links in TOCs. It checks to see -->
  708. <!-- * if the output dir that a TOC will get written to is -->
  709. <!-- * different from the output dir of the file being linked to. -->
  710. <!-- * If it is different, we do not call trim.common.uri.paths. -->
  711. <!-- * -->
  712. <!-- * Reason why I added that conditional is: I ran into a bug for -->
  713. <!-- * this case: -->
  714. <!-- * -->
  715. <!-- * 1. we are chunking into separate dirs -->
  716. <!-- * -->
  717. <!-- * 2. output for the TOC is written to current dir, but the file -->
  718. <!-- * being linked to is written to some subdir "foo". -->
  719. <!-- * -->
  720. <!-- * For that case, links to that file in that TOC did not show -->
  721. <!-- * the correct path - they omitted the "foo". -->
  722. <!-- * -->
  723. <!-- * The cause of that problem was that the trim.common.uri.paths -->
  724. <!-- * template[1] was being called under all conditions. But it's -->
  725. <!-- * apparent that we don't want to call trim.common.uri.paths in -->
  726. <!-- * the case where a linked file is being written to a different -->
  727. <!-- * directory than the TOC that contains the link, because doing -->
  728. <!-- * so will cause a necessary (not redundant) directory-name -->
  729. <!-- * part of the link to get inadvertently trimmed, resulting in -->
  730. <!-- * a broken link to that file. Thus, added the conditional. -->
  731. <!-- * -->
  732. <!-- * [1] The purpose of the trim.common.uri.paths template is to -->
  733. <!-- * prevent cases where, if we didn't call it, we end up with -->
  734. <!-- * unnecessary, redundant directory names getting output; for -->
  735. <!-- * example, "foo/foo/refname.html". -->
  736. <xsl:when test="not($toc-output-dir = $linked-file-output-dir)">
  737. <xsl:value-of select="$href.to.uri"/>
  738. </xsl:when>
  739. <xsl:otherwise>
  740. <xsl:call-template name="trim.common.uri.paths">
  741. <xsl:with-param name="uriA" select="$href.to.uri"/>
  742. <xsl:with-param name="uriB" select="$href.from.uri"/>
  743. <xsl:with-param name="return" select="'A'"/>
  744. </xsl:call-template>
  745. </xsl:otherwise>
  746. </xsl:choose>
  747. </xsl:variable>
  748. <xsl:variable name="href.from">
  749. <xsl:call-template name="trim.common.uri.paths">
  750. <xsl:with-param name="uriA" select="$href.to.uri"/>
  751. <xsl:with-param name="uriB" select="$href.from.uri"/>
  752. <xsl:with-param name="return" select="'B'"/>
  753. </xsl:call-template>
  754. </xsl:variable>
  755. <xsl:variable name="depth">
  756. <xsl:call-template name="count.uri.path.depth">
  757. <xsl:with-param name="filename" select="$href.from"/>
  758. </xsl:call-template>
  759. </xsl:variable>
  760. <xsl:variable name="href">
  761. <xsl:call-template name="copy-string">
  762. <xsl:with-param name="string" select="'../'"/>
  763. <xsl:with-param name="count" select="$depth"/>
  764. </xsl:call-template>
  765. <xsl:value-of select="$href.to"/>
  766. </xsl:variable>
  767. <!--
  768. <xsl:message>
  769. <xsl:text>In </xsl:text>
  770. <xsl:value-of select="name(.)"/>
  771. <xsl:text> (</xsl:text>
  772. <xsl:value-of select="$href.from"/>
  773. <xsl:text>,</xsl:text>
  774. <xsl:value-of select="$depth"/>
  775. <xsl:text>) </xsl:text>
  776. <xsl:value-of select="name($object)"/>
  777. <xsl:text> href=</xsl:text>
  778. <xsl:value-of select="$href"/>
  779. </xsl:message>
  780. -->
  781. <xsl:value-of select="$href"/>
  782. </xsl:template>
  783. <!-- Returns the complete olink href value if found -->
  784. <!-- Must take into account any dbhtml dir of the chunk containing the olink -->
  785. <xsl:template name="make.olink.href">
  786. <xsl:param name="olink.key" select="''"/>
  787. <xsl:param name="target.database"/>
  788. <xsl:if test="$olink.key != ''">
  789. <xsl:variable name="target.href">
  790. <xsl:for-each select="$target.database">
  791. <xsl:value-of select="key('targetptr-key', $olink.key)/@href"/>
  792. </xsl:for-each>
  793. </xsl:variable>
  794. <!-- an olink starting point may be in a subdirectory, so need
  795. the "from" reference point to compute a relative path -->
  796. <xsl:variable name="from.href">
  797. <xsl:call-template name="olink.from.uri">
  798. <xsl:with-param name="target.database" select="$target.database"/>
  799. <xsl:with-param name="object" select="."/>
  800. <xsl:with-param name="object.targetdoc" select="$current.docid"/>
  801. </xsl:call-template>
  802. </xsl:variable>
  803. <!-- If the from.href has directory path, then must "../" upward
  804. to document level -->
  805. <xsl:variable name="upward.from.path">
  806. <xsl:call-template name="upward.path">
  807. <xsl:with-param name="path" select="$from.href"/>
  808. </xsl:call-template>
  809. </xsl:variable>
  810. <xsl:variable name="targetdoc">
  811. <xsl:value-of select="substring-before($olink.key, '/')"/>
  812. </xsl:variable>
  813. <!-- Does the target database use a sitemap? -->
  814. <xsl:variable name="use.sitemap">
  815. <xsl:choose>
  816. <xsl:when test="$target.database//sitemap">1</xsl:when>
  817. <xsl:otherwise>0</xsl:otherwise>
  818. </xsl:choose>
  819. </xsl:variable>
  820. <!-- Get the baseuri for this targetptr -->
  821. <xsl:variable name="baseuri">
  822. <xsl:choose>
  823. <!-- Does the database use a sitemap? -->
  824. <xsl:when test="$use.sitemap != 0">
  825. <xsl:choose>
  826. <!-- Was current.docid parameter set? -->
  827. <xsl:when test="$current.docid != ''">
  828. <!-- Was it found in the database? -->
  829. <xsl:variable name="currentdoc.key">
  830. <xsl:for-each select="$target.database">
  831. <xsl:value-of select="key('targetdoc-key', $current.docid)/@targetdoc"/>
  832. </xsl:for-each>
  833. </xsl:variable>
  834. <xsl:choose>
  835. <xsl:when test="$currentdoc.key != ''">
  836. <xsl:for-each select="$target.database">
  837. <xsl:call-template name="targetpath">
  838. <xsl:with-param name="dirnode" select="key('targetdoc-key', $current.docid)/parent::dir"/>
  839. <xsl:with-param name="targetdoc" select="$targetdoc"/>
  840. </xsl:call-template>
  841. </xsl:for-each>
  842. </xsl:when>
  843. <xsl:otherwise>
  844. <xsl:message>
  845. <xsl:text>Olink error: cannot compute relative </xsl:text>
  846. <xsl:text>sitemap path because $current.docid '</xsl:text>
  847. <xsl:value-of select="$current.docid"/>
  848. <xsl:text>' not found in target database.</xsl:text>
  849. </xsl:message>
  850. </xsl:otherwise>
  851. </xsl:choose>
  852. </xsl:when>
  853. <xsl:otherwise>
  854. <xsl:message>
  855. <xsl:text>Olink warning: cannot compute relative </xsl:text>
  856. <xsl:text>sitemap path without $current.docid parameter</xsl:text>
  857. </xsl:message>
  858. </xsl:otherwise>
  859. </xsl:choose>
  860. <!-- In either case, add baseuri from its document entry-->
  861. <xsl:variable name="docbaseuri">
  862. <xsl:for-each select="$target.database">
  863. <xsl:value-of select="key('targetdoc-key', $targetdoc)/@baseuri"/>
  864. </xsl:for-each>
  865. </xsl:variable>
  866. <xsl:if test="$docbaseuri != ''">
  867. <xsl:value-of select="$docbaseuri"/>
  868. </xsl:if>
  869. </xsl:when>
  870. <!-- No database sitemap in use -->
  871. <xsl:otherwise>
  872. <!-- Just use any baseuri from its document entry -->
  873. <xsl:variable name="docbaseuri">
  874. <xsl:for-each select="$target.database">
  875. <xsl:value-of select="key('targetdoc-key', $targetdoc)/@baseuri"/>
  876. </xsl:for-each>
  877. </xsl:variable>
  878. <xsl:if test="$docbaseuri != ''">
  879. <xsl:value-of select="$docbaseuri"/>
  880. </xsl:if>
  881. </xsl:otherwise>
  882. </xsl:choose>
  883. </xsl:variable>
  884. <!-- Form the href information -->
  885. <xsl:if test="not(contains($baseuri, ':'))">
  886. <!-- if not an absolute uri, add upward path from olink chunk -->
  887. <xsl:value-of select="$upward.from.path"/>
  888. </xsl:if>
  889. <xsl:if test="$baseuri != ''">
  890. <xsl:value-of select="$baseuri"/>
  891. <xsl:if test="substring($target.href,1,1) != '#'">
  892. <!--xsl:text>/</xsl:text-->
  893. </xsl:if>
  894. </xsl:if>
  895. <!-- optionally turn off frag for PDF references -->
  896. <xsl:if test="not($insert.olink.pdf.frag = 0 and translate(substring($baseuri, string-length($baseuri) - 3), 'PDF', 'pdf') = '.pdf' and starts-with($target.href, '#') )">
  897. <xsl:value-of select="$target.href"/>
  898. </xsl:if>
  899. </xsl:if>
  900. </xsl:template>
  901. <!-- Computes "../" to reach top -->
  902. <xsl:template name="upward.path">
  903. <xsl:param name="path" select="''"/>
  904. <xsl:choose>
  905. <!-- Don't bother with absolute uris -->
  906. <xsl:when test="contains($path, ':')"/>
  907. <xsl:when test="starts-with($path, '/')"/>
  908. <xsl:when test="contains($path, '/')">
  909. <xsl:text>../</xsl:text>
  910. <xsl:call-template name="upward.path">
  911. <xsl:with-param name="path" select="substring-after($path, '/')"/>
  912. </xsl:call-template>
  913. </xsl:when>
  914. </xsl:choose>
  915. </xsl:template>
  916. <!-- ==================================================================== -->
  917. <xsl:template name="html.head">
  918. <xsl:param name="prev" select="/foo"/>
  919. <xsl:param name="next" select="/foo"/>
  920. <xsl:variable name="this" select="."/>
  921. <xsl:variable name="home" select="/*[1]"/>
  922. <xsl:variable name="up" select="parent::*"/>
  923. <head>
  924. <xsl:call-template name="system.head.content"/>
  925. <xsl:call-template name="head.content"/>
  926. <xsl:if test="$home">
  927. <link rel="start">
  928. <xsl:attribute name="href">
  929. <xsl:call-template name="href.target">
  930. <xsl:with-param name="object" select="$home"/>
  931. </xsl:call-template>
  932. </xsl:attribute>
  933. <xsl:attribute name="title">
  934. <xsl:apply-templates select="$home" mode="object.title.markup.textonly"/>
  935. </xsl:attribute>
  936. </link>
  937. </xsl:if>
  938. <xsl:if test="$up">
  939. <link rel="up">
  940. <xsl:attribute name="href">
  941. <xsl:call-template name="href.target">
  942. <xsl:with-param name="object" select="$up"/>
  943. </xsl:call-template>
  944. </xsl:attribute>
  945. <xsl:attribute name="title">
  946. <xsl:apply-templates select="$up" mode="object.title.markup.textonly"/>
  947. </xsl:attribute>
  948. </link>
  949. </xsl:if>
  950. <xsl:if test="$prev">
  951. <link rel="prev">
  952. <xsl:attribute name="href">
  953. <xsl:call-template name="href.target">
  954. <xsl:with-param name="object" select="$prev"/>
  955. </xsl:call-template>
  956. </xsl:attribute>
  957. <xsl:attribute name="title">
  958. <xsl:apply-templates select="$prev" mode="object.title.markup.textonly"/>
  959. </xsl:attribute>
  960. </link>
  961. </xsl:if>
  962. <xsl:if test="$next">
  963. <link rel="next">
  964. <xsl:attribute name="href">
  965. <xsl:call-template name="href.target">
  966. <xsl:with-param name="object" select="$next"/>
  967. </xsl:call-template>
  968. </xsl:attribute>
  969. <xsl:attribute name="title">
  970. <xsl:apply-templates select="$next" mode="object.title.markup.textonly"/>
  971. </xsl:attribute>
  972. </link>
  973. </xsl:if>
  974. <xsl:if test="$html.extra.head.links != 0">
  975. <xsl:for-each select="//part |//reference |//preface |//chapter |//article |//refentry |//appendix[not(parent::article)]|appendix |//glossary[not(parent::article)]|glossary |//index[not(parent::article)]|index">
  976. <link rel="{local-name(.)}">
  977. <xsl:attribute name="href">
  978. <xsl:call-template name="href.target">
  979. <xsl:with-param name="context" select="$this"/>
  980. <xsl:with-param name="object" select="."/>
  981. </xsl:call-template>
  982. </xsl:attribute>
  983. <xsl:attribute name="title">
  984. <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
  985. </xsl:attribute>
  986. </link>
  987. </xsl:for-each>
  988. <xsl:for-each select="section|sect1|refsection|refsect1">
  989. <link>
  990. <xsl:attribute name="rel">
  991. <xsl:choose>
  992. <xsl:when test="local-name($this) = 'section' or local-name($this) = 'refsection'">
  993. <xsl:value-of select="'subsection'"/>
  994. </xsl:when>
  995. <xsl:otherwise>
  996. <xsl:value-of select="'section'"/>
  997. </xsl:otherwise>
  998. </xsl:choose>
  999. </xsl:attribute>
  1000. <xsl:attribute name="href">
  1001. <xsl:call-template name="href.target">
  1002. <xsl:with-param name="context" select="$this"/>
  1003. <xsl:with-param name="object" select="."/>
  1004. </xsl:call-template>
  1005. </xsl:attribute>
  1006. <xsl:attribute name="title">
  1007. <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
  1008. </xsl:attribute>
  1009. </link>
  1010. </xsl:for-each>
  1011. <xsl:for-each select="sect2|sect3|sect4|sect5|refsect2|refsect3">
  1012. <link rel="subsection">
  1013. <xsl:attribute name="href">
  1014. <xsl:call-template name="href.target">
  1015. <xsl:with-param name="context" select="$this"/>
  1016. <xsl:with-param name="object" select="."/>
  1017. </xsl:call-template>
  1018. </xsl:attribute>
  1019. <xsl:attribute name="title">
  1020. <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
  1021. </xsl:attribute>
  1022. </link>
  1023. </xsl:for-each>
  1024. </xsl:if>
  1025. <!-- * if we have a legalnotice and user wants it output as a -->
  1026. <!-- * separate page and $html.head.legalnotice.link.types is -->
  1027. <!-- * non-empty, we generate a link or links for each value in -->
  1028. <!-- * $html.head.legalnotice.link.types -->
  1029. <xsl:if test="//legalnotice and not($generate.legalnotice.link = 0) and not($html.head.legalnotice.link.types = '')">
  1030. <xsl:call-template name="make.legalnotice.head.links"/>
  1031. </xsl:if>
  1032. <xsl:call-template name="user.head.content"/>
  1033. </head>
  1034. </xsl:template>
  1035. <!-- ==================================================================== -->
  1036. <xsl:template name="header.navigation">
  1037. <xsl:param name="prev" select="/foo"/>
  1038. <xsl:param name="next" select="/foo"/>
  1039. <xsl:param name="nav.context"/>
  1040. <xsl:variable name="home" select="/*[1]"/>
  1041. <xsl:variable name="up" select="parent::*"/>
  1042. <xsl:variable name="row1" select="$navig.showtitles != 0"/>
  1043. <xsl:variable name="row2" select="count($prev) &gt; 0 or (count($up) &gt; 0 and generate-id($up) != generate-id($home) and $navig.showtitles != 0) or count($next) &gt; 0"/>
  1044. <xsl:if test="$suppress.navigation = '0' and $suppress.header.navigation = '0'">
  1045. <div class="navheader">
  1046. <xsl:if test="$row1 or $row2">
  1047. <table width="100%" summary="Navigation header">
  1048. <xsl:if test="$row1">
  1049. <tr>
  1050. <th colspan="3" align="center">
  1051. <xsl:apply-templates select="." mode="object.title.markup"/>
  1052. </th>
  1053. </tr>
  1054. </xsl:if>
  1055. <xsl:if test="$row2">
  1056. <tr>
  1057. <td width="20%" align="left">
  1058. <xsl:if test="count($prev)&gt;0">
  1059. <a accesskey="p">
  1060. <xsl:attribute name="href">
  1061. <xsl:call-template name="href.target">
  1062. <xsl:with-param name="object" select="$prev"/>
  1063. </xsl:call-template>
  1064. </xsl:attribute>
  1065. <xsl:call-template name="navig.content">
  1066. <xsl:with-param name="direction" select="'prev'"/>
  1067. </xsl:call-template>
  1068. </a>
  1069. </xsl:if>
  1070. <xsl:text>&#160;</xsl:text>
  1071. </td>
  1072. <th width="60%" align="center">
  1073. <xsl:choose>
  1074. <xsl:when test="count($up) &gt; 0 and generate-id($up) != generate-id($home) and $navig.showtitles != 0">
  1075. <xsl:apply-templates select="$up" mode="object.title.markup"/>
  1076. </xsl:when>
  1077. <xsl:otherwise>&#160;</xsl:otherwise>
  1078. </xsl:choose>
  1079. </th>
  1080. <td width="20%" align="right">
  1081. <xsl:text>&#160;</xsl:text>
  1082. <xsl:if test="count($next)&gt;0">
  1083. <a accesskey="n">
  1084. <xsl:attribute name="href">
  1085. <xsl:call-template name="href.target">
  1086. <xsl:with-param name="object" select="$next"/>
  1087. </xsl:call-template>
  1088. </xsl:attribute>
  1089. <xsl:call-template name="navig.content">
  1090. <xsl:with-param name="direction" select="'next'"/>
  1091. </xsl:call-template>
  1092. </a>
  1093. </xsl:if>
  1094. </td>
  1095. </tr>
  1096. </xsl:if>
  1097. </table>
  1098. </xsl:if>
  1099. <xsl:if test="$header.rule != 0">
  1100. <hr/>
  1101. </xsl:if>
  1102. </div>
  1103. </xsl:if>
  1104. </xsl:template>
  1105. <!-- ==================================================================== -->
  1106. <xsl:template name="footer.navigation">
  1107. <xsl:param name="prev" select="/foo"/>
  1108. <xsl:param name="next" select="/foo"/>
  1109. <xsl:param name="nav.context"/>
  1110. <xsl:variable name="home" select="/*[1]"/>
  1111. <xsl:variable name="up" select="parent::*"/>
  1112. <xsl:variable name="row1" select="count($prev) &gt; 0 or count($up) &gt; 0 or count($next) &gt; 0"/>
  1113. <xsl:variable name="row2" select="($prev and $navig.showtitles != 0) or (generate-id($home) != generate-id(.) or $nav.context = 'toc') or ($chunk.tocs.and.lots != 0 and $nav.context != 'toc') or ($next and $navig.showtitles != 0)"/>
  1114. <xsl:if test="$suppress.navigation = '0' and $suppress.footer.navigation = '0'">
  1115. <div class="navfooter">
  1116. <xsl:if test="$footer.rule != 0">
  1117. <hr/>
  1118. </xsl:if>
  1119. <xsl:if test="$row1 or $row2">
  1120. <table width="100%" summary="Navigation footer">
  1121. <xsl:if test="$row1">
  1122. <tr>
  1123. <td width="40%" align="left">
  1124. <xsl:if test="count($prev)&gt;0">
  1125. <a accesskey="p">
  1126. <xsl:attribute name="href">
  1127. <xsl:call-template name="href.target">
  1128. <xsl:with-param name="object" select="$prev"/>
  1129. </xsl:call-template>
  1130. </xsl:attribute>
  1131. <xsl:call-template name="navig.content">
  1132. <xsl:with-param name="direction" select="'prev'"/>
  1133. </xsl:call-template>
  1134. </a>
  1135. </xsl:if>
  1136. <xsl:text>&#160;</xsl:text>
  1137. </td>
  1138. <td width="20%" align="center">
  1139. <xsl:choose>
  1140. <xsl:when test="count($up)&gt;0 and generate-id($up) != generate-id($home)">
  1141. <a accesskey="u">
  1142. <xsl:attribute name="href">
  1143. <xsl:call-template name="href.target">
  1144. <xsl:with-param name="object" select="$up"/>
  1145. </xsl:call-template>
  1146. </xsl:attribute>
  1147. <xsl:call-template name="navig.content">
  1148. <xsl:with-param name="direction" select="'up'"/>
  1149. </xsl:call-template>
  1150. </a>
  1151. </xsl:when>
  1152. <xsl:otherwise>&#160;</xsl:otherwise>
  1153. </xsl:choose>
  1154. </td>
  1155. <td width="40%" align="right">
  1156. <xsl:text>&#160;</xsl:text>
  1157. <xsl:if test="count($next)&gt;0">
  1158. <a accesskey="n">
  1159. <xsl:attribute name="href">
  1160. <xsl:call-template name="href.target">
  1161. <xsl:with-param name="object" select="$next"/>
  1162. </xsl:call-template>
  1163. </xsl:attribute>
  1164. <xsl:call-template name="navig.content">
  1165. <xsl:with-param name="direction" select="'next'"/>
  1166. </xsl:call-template>
  1167. </a>
  1168. </xsl:if>
  1169. </td>
  1170. </tr>
  1171. </xsl:if>
  1172. <xsl:if test="$row2">
  1173. <tr>
  1174. <td width="40%" align="left" valign="top">
  1175. <xsl:if test="$navig.showtitles != 0">
  1176. <xsl:apply-templates select="$prev" mode="object.title.markup"/>
  1177. </xsl:if>
  1178. <xsl:text>&#160;</xsl:text>
  1179. </td>
  1180. <td width="20%" align="center">
  1181. <xsl:choose>
  1182. <xsl:when test="$home != . or $nav.context = 'toc'">
  1183. <a accesskey="h">
  1184. <xsl:attribute name="href">
  1185. <xsl:call-template name="href.target">
  1186. <xsl:with-param name="object" select="$home"/>
  1187. </xsl:call-template>
  1188. </xsl:attribute>
  1189. <xsl:call-template name="navig.content">
  1190. <xsl:with-param name="direction" select="'home'"/>
  1191. </xsl:call-template>
  1192. </a>
  1193. <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
  1194. <xsl:text>&#160;|&#160;</xsl:text>
  1195. </xsl:if>
  1196. </xsl:when>
  1197. <xsl:otherwise>&#160;</xsl:otherwise>
  1198. </xsl:choose>
  1199. <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
  1200. <a accesskey="t">
  1201. <xsl:attribute name="href">
  1202. <xsl:apply-templates select="/*[1]" mode="recursive-chunk-filename">
  1203. <xsl:with-param name="recursive" select="true()"/>
  1204. </xsl:apply-templates>
  1205. <xsl:text>-toc</xsl:text>
  1206. <xsl:value-of select="$html.ext"/>
  1207. </xsl:attribute>
  1208. <xsl:call-template name="gentext">
  1209. <xsl:with-param name="key" select="'nav-toc'"/>
  1210. </xsl:call-template>
  1211. </a>
  1212. </xsl:if>
  1213. </td>
  1214. <td width="40%" align="right" valign="top">
  1215. <xsl:text>&#160;</xsl:text>
  1216. <xsl:if test="$navig.showtitles != 0">
  1217. <xsl:apply-templates select="$next" mode="object.title.markup"/>
  1218. </xsl:if>
  1219. </td>
  1220. </tr>
  1221. </xsl:if>
  1222. </table>
  1223. </xsl:if>
  1224. </div>
  1225. </xsl:if>
  1226. </xsl:template>
  1227. <!-- ==================================================================== -->
  1228. <xsl:template name="navig.content">
  1229. <xsl:param name="direction" select="next"/>
  1230. <xsl:variable name="navtext">
  1231. <xsl:choose>
  1232. <xsl:when test="$direction = 'prev'">
  1233. <xsl:call-template name="gentext.nav.prev"/>
  1234. </xsl:when>
  1235. <xsl:when test="$direction = 'next'">
  1236. <xsl:call-template name="gentext.nav.next"/>
  1237. </xsl:when>
  1238. <xsl:when test="$direction = 'up'">
  1239. <xsl:call-template name="gentext.nav.up"/>
  1240. </xsl:when>
  1241. <xsl:when test="$direction = 'home'">
  1242. <xsl:call-template name="gentext.nav.home"/>
  1243. </xsl:when>
  1244. <xsl:otherwise>
  1245. <xsl:text>xxx</xsl:text>
  1246. </xsl:otherwise>
  1247. </xsl:choose>
  1248. </xsl:variable>
  1249. <xsl:choose>
  1250. <xsl:when test="$navig.graphics != 0">
  1251. <img>
  1252. <xsl:attribute name="src">
  1253. <xsl:value-of select="$navig.graphics.path"/>
  1254. <xsl:value-of select="$direction"/>
  1255. <xsl:value-of select="$navig.graphics.extension"/>
  1256. </xsl:attribute>
  1257. <xsl:attribute name="alt">
  1258. <xsl:value-of select="$navtext"/>
  1259. </xsl:attribute>
  1260. </img>
  1261. </xsl:when>
  1262. <xsl:otherwise>
  1263. <xsl:value-of select="$navtext"/>
  1264. </xsl:otherwise>
  1265. </xsl:choose>
  1266. </xsl:template>
  1267. <!-- ==================================================================== -->
  1268. <!-- * The following template assumes that the first legalnotice -->
  1269. <!-- * instance found in a document applies to the contents of the -->
  1270. <!-- * entire document. It generates an HTML link in each chunk, back -->
  1271. <!-- * to the file containing the contents of the first legalnotice. -->
  1272. <!-- * -->
  1273. <!-- * Actually, it may generate multiple link instances in each chunk, -->
  1274. <!-- * because it walks through the space-separated list of link -->
  1275. <!-- * types specified in the $html.head.legalnotice.link.types param, -->
  1276. <!-- * popping off link types and generating links for them until it -->
  1277. <!-- * depletes the list. -->
  1278. <xsl:template name="make.legalnotice.head.links">
  1279. <!-- * the following ID is used as part of the legalnotice filename; -->
  1280. <!-- * we need it in order to construct the filename for use in the -->
  1281. <!-- * value of the href attribute on the link -->
  1282. <xsl:param name="id">
  1283. <xsl:call-template name="object.id">
  1284. <xsl:with-param name="object" select="(//legalnotice)[1]"/>
  1285. </xsl:call-template>
  1286. </xsl:param>
  1287. <xsl:param name="linktype">
  1288. <xsl:choose>
  1289. <xsl:when test="contains($html.head.legalnotice.link.types, ' ')">
  1290. <xsl:value-of select="normalize-space( substring-before($html.head.legalnotice.link.types, ' '))"/>
  1291. </xsl:when>
  1292. <xsl:otherwise>
  1293. <xsl:value-of select="$html.head.legalnotice.link.types"/>
  1294. </xsl:otherwise>
  1295. </xsl:choose>
  1296. </xsl:param>
  1297. <xsl:param name="remaining.linktypes" select="concat( normalize-space( substring-after($html.head.legalnotice.link.types, ' ')),' ')"/>
  1298. <xsl:if test="not($linktype = '')">
  1299. <link rel="{$linktype}">
  1300. <xsl:attribute name="href">
  1301. <xsl:value-of select="concat('ln-',$id,$html.ext)"/>
  1302. </xsl:attribute>
  1303. <xsl:attribute name="title">
  1304. <xsl:apply-templates select="(//legalnotice)[1]" mode="object.title.markup.textonly"/>
  1305. </xsl:attribute>
  1306. </link>
  1307. <xsl:call-template name="make.legalnotice.head.links">
  1308. <!-- * pop the next value off the list of link types -->
  1309. <xsl:with-param name="linktype" select="substring-before($remaining.linktypes, ' ')"/>
  1310. <!-- * remove the link type from the list of remaining link types -->
  1311. <xsl:with-param name="remaining.linktypes" select="substring-after($remaining.linktypes, ' ')"/>
  1312. </xsl:call-template>
  1313. </xsl:if>
  1314. </xsl:template>
  1315. <!-- ==================================================================== -->
  1316. <xsl:template name="chunk-element-content">
  1317. <xsl:param name="prev"/>
  1318. <xsl:param name="next"/>
  1319. <xsl:param name="nav.context"/>
  1320. <xsl:param name="content">
  1321. <xsl:apply-imports/>
  1322. </xsl:param>
  1323. <xsl:call-template name="user.preroot"/>
  1324. <html>
  1325. <xsl:call-template name="html.head">
  1326. <xsl:with-param name="prev" select="$prev"/>
  1327. <xsl:with-param name="next" select="$next"/>
  1328. </xsl:call-template>
  1329. <body>
  1330. <xsl:call-template name="body.attributes"/>
  1331. <xsl:call-template name="user.header.navigation"/>
  1332. <xsl:call-template name="header.navigation">
  1333. <xsl:with-param name="prev" select="$prev"/>
  1334. <xsl:with-param name="next" select="$next"/>
  1335. <xsl:with-param name="nav.context" select="$nav.context"/>
  1336. </xsl:call-template>
  1337. <xsl:call-template name="user.header.content"/>
  1338. <xsl:copy-of select="$content"/>
  1339. <xsl:call-template name="user.footer.content"/>
  1340. <xsl:call-template name="footer.navigation">
  1341. <xsl:with-param name="prev" select="$prev"/>
  1342. <xsl:with-param name="next" select="$next"/>
  1343. <xsl:with-param name="nav.context" select="$nav.context"/>
  1344. </xsl:call-template>
  1345. <xsl:call-template name="user.footer.navigation"/>
  1346. </body>
  1347. </html>
  1348. <xsl:value-of select="$chunk.append"/>
  1349. </xsl:template>
  1350. <!-- ==================================================================== -->
  1351. <xsl:template name="generate.manifest">
  1352. <xsl:param name="node" select="/"/>
  1353. <xsl:call-template name="write.text.chunk">
  1354. <xsl:with-param name="filename">
  1355. <xsl:if test="$manifest.in.base.dir != 0">
  1356. <xsl:value-of select="$base.dir"/>
  1357. </xsl:if>
  1358. <xsl:value-of select="$manifest"/>
  1359. </xsl:with-param>
  1360. <xsl:with-param name="method" select="'text'"/>
  1361. <xsl:with-param name="content">
  1362. <xsl:apply-templates select="$node" mode="enumerate-files"/>
  1363. </xsl:with-param>
  1364. <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
  1365. </xsl:call-template>
  1366. </xsl:template>
  1367. <!-- ==================================================================== -->
  1368. <xsl:template name="dbhtml-dir">
  1369. <xsl:param name="context" select="."/>
  1370. <!-- directories are now inherited from previous levels -->
  1371. <xsl:variable name="ppath">
  1372. <xsl:if test="$context/parent::*">
  1373. <xsl:call-template name="dbhtml-dir">
  1374. <xsl:with-param name="context" select="$context/parent::*"/>
  1375. </xsl:call-template>
  1376. </xsl:if>
  1377. </xsl:variable>
  1378. <xsl:variable name="path">
  1379. <xsl:call-template name="pi.dbhtml_dir">
  1380. <xsl:with-param name="node" select="$context"/>
  1381. </xsl:call-template>
  1382. </xsl:variable>
  1383. <xsl:choose>
  1384. <xsl:when test="$path = ''">
  1385. <xsl:if test="$ppath != ''">
  1386. <xsl:value-of select="$ppath"/>
  1387. </xsl:if>
  1388. </xsl:when>
  1389. <xsl:otherwise>
  1390. <xsl:if test="$ppath != ''">
  1391. <xsl:value-of select="$ppath"/>
  1392. <xsl:if test="substring($ppath, string-length($ppath), 1) != '/'">
  1393. <xsl:text>/</xsl:text>
  1394. </xsl:if>
  1395. </xsl:if>
  1396. <xsl:value-of select="$path"/>
  1397. <xsl:text>/</xsl:text>
  1398. </xsl:otherwise>
  1399. </xsl:choose>
  1400. </xsl:template>
  1401. </xsl:stylesheet>