chunker.xsl 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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:saxon="http://icl.com/saxon" xmlns:lxslt="http://xml.apache.org/xslt" xmlns:redirect="http://xml.apache.org/xalan/redirect" xmlns:exsl="http://exslt.org/common" xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" xmlns="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="doc" extension-element-prefixes="saxon redirect lxslt exsl">
  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. <!-- This stylesheet works with XSLT implementations that support -->
  14. <!-- exsl:document, saxon:output, or Xalan's redirect:write -->
  15. <!-- Note: Only Saxon 6.4.2 or later is supported. -->
  16. <xsl:param name="chunker.output.method" select="'xml'"/>
  17. <xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
  18. <xsl:param name="chunker.output.indent" select="'no'"/>
  19. <xsl:param name="chunker.output.omit-xml-declaration" select="'no'"/>
  20. <xsl:param name="chunker.output.standalone" select="'no'"/>
  21. <xsl:param name="chunker.output.doctype-public" select="'-//W3C//DTD XHTML 1.0 Transitional//EN'"/>
  22. <xsl:param name="chunker.output.doctype-system" select="'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'"/>
  23. <xsl:param name="chunker.output.media-type" select="''"/>
  24. <xsl:param name="chunker.output.cdata-section-elements" select="''"/>
  25. <xsl:param name="chunker.output.quiet" select="0"/>
  26. <xsl:param name="saxon.character.representation" select="'entity;decimal'"/>
  27. <!-- ==================================================================== -->
  28. <xsl:template name="make-relative-filename">
  29. <xsl:param name="base.dir" select="'./'"/>
  30. <xsl:param name="base.name" select="''"/>
  31. <xsl:choose>
  32. <!-- put Saxon first to work around a bug in libxslt -->
  33. <xsl:when test="element-available('saxon:output')">
  34. <!-- Saxon doesn't make the chunks relative -->
  35. <xsl:value-of select="concat($base.dir,$base.name)"/>
  36. </xsl:when>
  37. <xsl:when test="element-available('exsl:document')">
  38. <!-- EXSL document does make the chunks relative, I think -->
  39. <xsl:choose>
  40. <xsl:when test="count(parent::*) = 0">
  41. <xsl:value-of select="concat($base.dir,$base.name)"/>
  42. </xsl:when>
  43. <xsl:otherwise>
  44. <xsl:value-of select="$base.name"/>
  45. </xsl:otherwise>
  46. </xsl:choose>
  47. </xsl:when>
  48. <xsl:when test="element-available('redirect:write')">
  49. <!-- Xalan doesn't make the chunks relative -->
  50. <xsl:value-of select="concat($base.dir,$base.name)"/>
  51. </xsl:when>
  52. <xsl:otherwise>
  53. <xsl:message terminate="yes">
  54. <xsl:text>Don't know how to chunk with </xsl:text>
  55. <xsl:value-of select="system-property('xsl:vendor')"/>
  56. </xsl:message>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. </xsl:template>
  60. <xsl:template name="write.chunk">
  61. <xsl:param name="filename" select="''"/>
  62. <xsl:param name="quiet" select="$chunker.output.quiet"/>
  63. <xsl:param name="suppress-context-node-name" select="0"/>
  64. <xsl:param name="message-prolog"/>
  65. <xsl:param name="message-epilog"/>
  66. <xsl:param name="method" select="$chunker.output.method"/>
  67. <xsl:param name="encoding" select="$chunker.output.encoding"/>
  68. <xsl:param name="indent" select="$chunker.output.indent"/>
  69. <xsl:param name="omit-xml-declaration" select="$chunker.output.omit-xml-declaration"/>
  70. <xsl:param name="standalone" select="$chunker.output.standalone"/>
  71. <xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
  72. <xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
  73. <xsl:param name="media-type" select="$chunker.output.media-type"/>
  74. <xsl:param name="cdata-section-elements" select="$chunker.output.cdata-section-elements"/>
  75. <xsl:param name="content"/>
  76. <xsl:if test="$quiet = 0">
  77. <xsl:message>
  78. <xsl:if test="not($message-prolog = '')">
  79. <xsl:value-of select="$message-prolog"/>
  80. </xsl:if>
  81. <xsl:text>Writing </xsl:text>
  82. <xsl:value-of select="$filename"/>
  83. <xsl:if test="name(.) != '' and $suppress-context-node-name = 0">
  84. <xsl:text> for </xsl:text>
  85. <xsl:value-of select="name(.)"/>
  86. <xsl:if test="@id or @xml:id">
  87. <xsl:text>(</xsl:text>
  88. <xsl:value-of select="(@id|@xml:id)[1]"/>
  89. <xsl:text>)</xsl:text>
  90. </xsl:if>
  91. </xsl:if>
  92. <xsl:if test="not($message-epilog = '')">
  93. <xsl:value-of select="$message-epilog"/>
  94. </xsl:if>
  95. </xsl:message>
  96. </xsl:if>
  97. <xsl:choose>
  98. <xsl:when test="element-available('exsl:document')">
  99. <xsl:choose>
  100. <!-- Handle the permutations ... -->
  101. <xsl:when test="$media-type != ''">
  102. <xsl:choose>
  103. <xsl:when test="$doctype-public != '' and $doctype-system != ''">
  104. <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" media-type="{$media-type}" doctype-public="{$doctype-public}" doctype-system="{$doctype-system}" standalone="{$standalone}">
  105. <xsl:copy-of select="$content"/>
  106. </exsl:document>
  107. </xsl:when>
  108. <xsl:when test="$doctype-public != '' and $doctype-system = ''">
  109. <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" media-type="{$media-type}" doctype-public="{$doctype-public}" standalone="{$standalone}">
  110. <xsl:copy-of select="$content"/>
  111. </exsl:document>
  112. </xsl:when>
  113. <xsl:when test="$doctype-public = '' and $doctype-system != ''">
  114. <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" media-type="{$media-type}" doctype-system="{$doctype-system}" standalone="{$standalone}">
  115. <xsl:copy-of select="$content"/>
  116. </exsl:document>
  117. </xsl:when>
  118. <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
  119. <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" media-type="{$media-type}" standalone="{$standalone}">
  120. <xsl:copy-of select="$content"/>
  121. </exsl:document>
  122. </xsl:otherwise>
  123. </xsl:choose>
  124. </xsl:when>
  125. <xsl:otherwise>
  126. <xsl:choose>
  127. <xsl:when test="$doctype-public != '' and $doctype-system != ''">
  128. <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" doctype-public="{$doctype-public}" doctype-system="{$doctype-system}" standalone="{$standalone}">
  129. <xsl:copy-of select="$content"/>
  130. </exsl:document>
  131. </xsl:when>
  132. <xsl:when test="$doctype-public != '' and $doctype-system = ''">
  133. <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" doctype-public="{$doctype-public}" standalone="{$standalone}">
  134. <xsl:copy-of select="$content"/>
  135. </exsl:document>
  136. </xsl:when>
  137. <xsl:when test="$doctype-public = '' and $doctype-system != ''">
  138. <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" doctype-system="{$doctype-system}" standalone="{$standalone}">
  139. <xsl:copy-of select="$content"/>
  140. </exsl:document>
  141. </xsl:when>
  142. <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
  143. <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" standalone="{$standalone}">
  144. <xsl:copy-of select="$content"/>
  145. </exsl:document>
  146. </xsl:otherwise>
  147. </xsl:choose>
  148. </xsl:otherwise>
  149. </xsl:choose>
  150. </xsl:when>
  151. <xsl:when test="element-available('saxon:output')">
  152. <xsl:choose>
  153. <!-- Handle the permutations ... -->
  154. <xsl:when test="$media-type != ''">
  155. <xsl:choose>
  156. <xsl:when test="$doctype-public != '' and $doctype-system != ''">
  157. <saxon:output saxon:character-representation="{$saxon.character.representation}" href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" media-type="{$media-type}" doctype-public="{$doctype-public}" doctype-system="{$doctype-system}" standalone="{$standalone}">
  158. <xsl:copy-of select="$content"/>
  159. </saxon:output>
  160. </xsl:when>
  161. <xsl:when test="$doctype-public != '' and $doctype-system = ''">
  162. <saxon:output saxon:character-representation="{$saxon.character.representation}" href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" media-type="{$media-type}" doctype-public="{$doctype-public}" standalone="{$standalone}">
  163. <xsl:copy-of select="$content"/>
  164. </saxon:output>
  165. </xsl:when>
  166. <xsl:when test="$doctype-public = '' and $doctype-system != ''">
  167. <saxon:output saxon:character-representation="{$saxon.character.representation}" href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" media-type="{$media-type}" doctype-system="{$doctype-system}" standalone="{$standalone}">
  168. <xsl:copy-of select="$content"/>
  169. </saxon:output>
  170. </xsl:when>
  171. <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
  172. <saxon:output saxon:character-representation="{$saxon.character.representation}" href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" media-type="{$media-type}" standalone="{$standalone}">
  173. <xsl:copy-of select="$content"/>
  174. </saxon:output>
  175. </xsl:otherwise>
  176. </xsl:choose>
  177. </xsl:when>
  178. <xsl:otherwise>
  179. <xsl:choose>
  180. <xsl:when test="$doctype-public != '' and $doctype-system != ''">
  181. <saxon:output saxon:character-representation="{$saxon.character.representation}" href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" doctype-public="{$doctype-public}" doctype-system="{$doctype-system}" standalone="{$standalone}">
  182. <xsl:copy-of select="$content"/>
  183. </saxon:output>
  184. </xsl:when>
  185. <xsl:when test="$doctype-public != '' and $doctype-system = ''">
  186. <saxon:output saxon:character-representation="{$saxon.character.representation}" href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" doctype-public="{$doctype-public}" standalone="{$standalone}">
  187. <xsl:copy-of select="$content"/>
  188. </saxon:output>
  189. </xsl:when>
  190. <xsl:when test="$doctype-public = '' and $doctype-system != ''">
  191. <saxon:output saxon:character-representation="{$saxon.character.representation}" href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" doctype-system="{$doctype-system}" standalone="{$standalone}">
  192. <xsl:copy-of select="$content"/>
  193. </saxon:output>
  194. </xsl:when>
  195. <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
  196. <saxon:output saxon:character-representation="{$saxon.character.representation}" href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" standalone="{$standalone}">
  197. <xsl:copy-of select="$content"/>
  198. </saxon:output>
  199. </xsl:otherwise>
  200. </xsl:choose>
  201. </xsl:otherwise>
  202. </xsl:choose>
  203. </xsl:when>
  204. <xsl:when test="element-available('redirect:write')">
  205. <!-- Xalan uses redirect -->
  206. <redirect:write file="{$filename}">
  207. <xsl:copy-of select="$content"/>
  208. </redirect:write>
  209. </xsl:when>
  210. <xsl:otherwise>
  211. <!-- it doesn't matter since we won't be making chunks... -->
  212. <xsl:message terminate="yes">
  213. <xsl:text>Can't make chunks with </xsl:text>
  214. <xsl:value-of select="system-property('xsl:vendor')"/>
  215. <xsl:text>'s processor.</xsl:text>
  216. </xsl:message>
  217. </xsl:otherwise>
  218. </xsl:choose>
  219. </xsl:template>
  220. <xsl:template name="write.chunk.with.doctype">
  221. <xsl:param name="filename" select="''"/>
  222. <xsl:param name="quiet" select="$chunker.output.quiet"/>
  223. <xsl:param name="method" select="$chunker.output.method"/>
  224. <xsl:param name="encoding" select="$chunker.output.encoding"/>
  225. <xsl:param name="indent" select="$chunker.output.indent"/>
  226. <xsl:param name="omit-xml-declaration" select="$chunker.output.omit-xml-declaration"/>
  227. <xsl:param name="standalone" select="$chunker.output.standalone"/>
  228. <xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
  229. <xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
  230. <xsl:param name="media-type" select="$chunker.output.media-type"/>
  231. <xsl:param name="cdata-section-elements" select="$chunker.output.cdata-section-elements"/>
  232. <xsl:param name="content"/>
  233. <xsl:call-template name="write.chunk">
  234. <xsl:with-param name="filename" select="$filename"/>
  235. <xsl:with-param name="quiet" select="$quiet"/>
  236. <xsl:with-param name="method" select="$method"/>
  237. <xsl:with-param name="encoding" select="$encoding"/>
  238. <xsl:with-param name="indent" select="$indent"/>
  239. <xsl:with-param name="omit-xml-declaration" select="$omit-xml-declaration"/>
  240. <xsl:with-param name="standalone" select="$standalone"/>
  241. <xsl:with-param name="doctype-public" select="$doctype-public"/>
  242. <xsl:with-param name="doctype-system" select="$doctype-system"/>
  243. <xsl:with-param name="media-type" select="$media-type"/>
  244. <xsl:with-param name="cdata-section-elements" select="$cdata-section-elements"/>
  245. <xsl:with-param name="content" select="$content"/>
  246. </xsl:call-template>
  247. </xsl:template>
  248. <xsl:template name="write.text.chunk">
  249. <xsl:param name="filename" select="''"/>
  250. <xsl:param name="quiet" select="$chunker.output.quiet"/>
  251. <xsl:param name="suppress-context-node-name" select="0"/>
  252. <xsl:param name="message-prolog"/>
  253. <xsl:param name="message-epilog"/>
  254. <xsl:param name="method" select="'text'"/>
  255. <xsl:param name="encoding" select="$chunker.output.encoding"/>
  256. <xsl:param name="media-type" select="$chunker.output.media-type"/>
  257. <xsl:param name="content"/>
  258. <xsl:call-template name="write.chunk">
  259. <xsl:with-param name="filename" select="$filename"/>
  260. <xsl:with-param name="quiet" select="$quiet"/>
  261. <xsl:with-param name="suppress-context-node-name" select="$suppress-context-node-name"/>
  262. <xsl:with-param name="message-prolog" select="$message-prolog"/>
  263. <xsl:with-param name="message-epilog" select="$message-epilog"/>
  264. <xsl:with-param name="method" select="$method"/>
  265. <xsl:with-param name="encoding" select="$encoding"/>
  266. <xsl:with-param name="indent" select="'no'"/>
  267. <xsl:with-param name="omit-xml-declaration" select="'no'"/>
  268. <xsl:with-param name="standalone" select="'no'"/>
  269. <xsl:with-param name="doctype-public"/>
  270. <xsl:with-param name="doctype-system"/>
  271. <xsl:with-param name="media-type" select="$media-type"/>
  272. <xsl:with-param name="cdata-section-elements"/>
  273. <xsl:with-param name="content" select="$content"/>
  274. </xsl:call-template>
  275. </xsl:template>
  276. </xsl:stylesheet>