chunker.xsl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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="saxon lxslt redirect exsl doc" extension-element-prefixes="saxon redirect lxslt exsl">
  5. <!-- ********************************************************************
  6. $Id: chunker.xsl 9656 2012-10-29 18:09:53Z bobstayton $
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <!-- ==================================================================== -->
  13. <!-- 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. <!-- Make sure base.dir has a trailing slash now -->
  26. <xsl:param name="chunk.base.dir">
  27. <xsl:choose>
  28. <xsl:when test="string-length($base.dir) = 0"/>
  29. <!-- make sure to add trailing slash if omitted by user -->
  30. <xsl:when test="substring($base.dir, string-length($base.dir), 1) = '/'">
  31. <xsl:value-of select="$base.dir"/>
  32. </xsl:when>
  33. <xsl:otherwise>
  34. <xsl:value-of select="concat($base.dir, '/')"/>
  35. </xsl:otherwise>
  36. </xsl:choose>
  37. </xsl:param>
  38. <xsl:param name="saxon.character.representation" select="'entity;decimal'"/>
  39. <!-- ==================================================================== -->
  40. <xsl:template name="make-relative-filename">
  41. <xsl:param name="base.dir" select="'./'"/>
  42. <xsl:param name="base.name" select="''"/>
  43. <xsl:choose>
  44. <!-- put Saxon first to work around a bug in libxslt -->
  45. <xsl:when test="element-available('saxon:output')">
  46. <!-- Saxon doesn't make the chunks relative -->
  47. <xsl:value-of select="concat($base.dir,$base.name)"/>
  48. </xsl:when>
  49. <xsl:when test="element-available('exsl:document')">
  50. <!-- EXSL document does make the chunks relative, I think -->
  51. <xsl:choose>
  52. <xsl:when test="count(parent::*) = 0">
  53. <xsl:value-of select="concat($base.dir,$base.name)"/>
  54. </xsl:when>
  55. <xsl:otherwise>
  56. <xsl:value-of select="$base.name"/>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. </xsl:when>
  60. <xsl:when test="element-available('redirect:write')">
  61. <!-- Xalan doesn't make the chunks relative -->
  62. <xsl:value-of select="concat($base.dir,$base.name)"/>
  63. </xsl:when>
  64. <xsl:otherwise>
  65. <xsl:message terminate="yes">
  66. <xsl:text>Don't know how to chunk with </xsl:text>
  67. <xsl:value-of select="system-property('xsl:vendor')"/>
  68. </xsl:message>
  69. </xsl:otherwise>
  70. </xsl:choose>
  71. </xsl:template>
  72. <xsl:template name="write.chunk">
  73. <xsl:param name="filename" select="''"/>
  74. <xsl:param name="quiet" select="$chunk.quietly"/>
  75. <xsl:param name="suppress-context-node-name" select="0"/>
  76. <xsl:param name="message-prolog"/>
  77. <xsl:param name="message-epilog"/>
  78. <xsl:param name="method" select="$chunker.output.method"/>
  79. <xsl:param name="encoding" select="$chunker.output.encoding"/>
  80. <xsl:param name="indent" select="$chunker.output.indent"/>
  81. <xsl:param name="omit-xml-declaration" select="$chunker.output.omit-xml-declaration"/>
  82. <xsl:param name="standalone" select="$chunker.output.standalone"/>
  83. <xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
  84. <xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
  85. <xsl:param name="media-type" select="$chunker.output.media-type"/>
  86. <xsl:param name="cdata-section-elements" select="$chunker.output.cdata-section-elements"/>
  87. <xsl:param name="content"/>
  88. <xsl:if test="$quiet = 0">
  89. <xsl:message>
  90. <xsl:if test="not($message-prolog = '')">
  91. <xsl:value-of select="$message-prolog"/>
  92. </xsl:if>
  93. <xsl:text>Writing </xsl:text>
  94. <xsl:value-of select="$filename"/>
  95. <xsl:if test="name(.) != '' and $suppress-context-node-name = 0">
  96. <xsl:text> for </xsl:text>
  97. <xsl:value-of select="name(.)"/>
  98. <xsl:if test="@id or @xml:id">
  99. <xsl:text>(</xsl:text>
  100. <xsl:value-of select="(@id|@xml:id)[1]"/>
  101. <xsl:text>)</xsl:text>
  102. </xsl:if>
  103. </xsl:if>
  104. <xsl:if test="not($message-epilog = '')">
  105. <xsl:value-of select="$message-epilog"/>
  106. </xsl:if>
  107. </xsl:message>
  108. </xsl:if>
  109. <xsl:choose>
  110. <xsl:when test="element-available('exsl:document')">
  111. <xsl:choose>
  112. <!-- Handle the permutations ... -->
  113. <xsl:when test="$media-type != ''">
  114. <xsl:choose>
  115. <xsl:when test="$doctype-public != '' and $doctype-system != ''">
  116. <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}">
  117. <xsl:copy-of select="$content"/>
  118. </exsl:document>
  119. </xsl:when>
  120. <xsl:when test="$doctype-public != '' and $doctype-system = ''">
  121. <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}">
  122. <xsl:copy-of select="$content"/>
  123. </exsl:document>
  124. </xsl:when>
  125. <xsl:when test="$doctype-public = '' and $doctype-system != ''">
  126. <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}">
  127. <xsl:copy-of select="$content"/>
  128. </exsl:document>
  129. </xsl:when>
  130. <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
  131. <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}">
  132. <xsl:copy-of select="$content"/>
  133. </exsl:document>
  134. </xsl:otherwise>
  135. </xsl:choose>
  136. </xsl:when>
  137. <xsl:otherwise>
  138. <xsl:choose>
  139. <xsl:when test="$doctype-public != '' and $doctype-system != ''">
  140. <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}">
  141. <xsl:copy-of select="$content"/>
  142. </exsl:document>
  143. </xsl:when>
  144. <xsl:when test="$doctype-public != '' and $doctype-system = ''">
  145. <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}">
  146. <xsl:copy-of select="$content"/>
  147. </exsl:document>
  148. </xsl:when>
  149. <xsl:when test="$doctype-public = '' and $doctype-system != ''">
  150. <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}">
  151. <xsl:copy-of select="$content"/>
  152. </exsl:document>
  153. </xsl:when>
  154. <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
  155. <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" standalone="{$standalone}">
  156. <xsl:copy-of select="$content"/>
  157. </exsl:document>
  158. </xsl:otherwise>
  159. </xsl:choose>
  160. </xsl:otherwise>
  161. </xsl:choose>
  162. </xsl:when>
  163. <xsl:when test="element-available('saxon:output')">
  164. <xsl:choose>
  165. <!-- Handle the permutations ... -->
  166. <xsl:when test="$media-type != ''">
  167. <xsl:choose>
  168. <xsl:when test="$doctype-public != '' and $doctype-system != ''">
  169. <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}">
  170. <xsl:copy-of select="$content"/>
  171. </saxon:output>
  172. </xsl:when>
  173. <xsl:when test="$doctype-public != '' and $doctype-system = ''">
  174. <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}">
  175. <xsl:copy-of select="$content"/>
  176. </saxon:output>
  177. </xsl:when>
  178. <xsl:when test="$doctype-public = '' and $doctype-system != ''">
  179. <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}">
  180. <xsl:copy-of select="$content"/>
  181. </saxon:output>
  182. </xsl:when>
  183. <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
  184. <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}">
  185. <xsl:copy-of select="$content"/>
  186. </saxon:output>
  187. </xsl:otherwise>
  188. </xsl:choose>
  189. </xsl:when>
  190. <xsl:otherwise>
  191. <xsl:choose>
  192. <xsl:when test="$doctype-public != '' and $doctype-system != ''">
  193. <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}">
  194. <xsl:copy-of select="$content"/>
  195. </saxon:output>
  196. </xsl:when>
  197. <xsl:when test="$doctype-public != '' and $doctype-system = ''">
  198. <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}">
  199. <xsl:copy-of select="$content"/>
  200. </saxon:output>
  201. </xsl:when>
  202. <xsl:when test="$doctype-public = '' and $doctype-system != ''">
  203. <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}">
  204. <xsl:copy-of select="$content"/>
  205. </saxon:output>
  206. </xsl:when>
  207. <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
  208. <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}">
  209. <xsl:copy-of select="$content"/>
  210. </saxon:output>
  211. </xsl:otherwise>
  212. </xsl:choose>
  213. </xsl:otherwise>
  214. </xsl:choose>
  215. </xsl:when>
  216. <xsl:when test="element-available('redirect:write')">
  217. <!-- Xalan uses redirect -->
  218. <redirect:write file="{$filename}">
  219. <xsl:copy-of select="$content"/>
  220. </redirect:write>
  221. </xsl:when>
  222. <xsl:otherwise>
  223. <!-- it doesn't matter since we won't be making chunks... -->
  224. <xsl:message terminate="yes">
  225. <xsl:text>Can't make chunks with </xsl:text>
  226. <xsl:value-of select="system-property('xsl:vendor')"/>
  227. <xsl:text>'s processor.</xsl:text>
  228. </xsl:message>
  229. </xsl:otherwise>
  230. </xsl:choose>
  231. </xsl:template>
  232. <xsl:template name="write.chunk.with.doctype">
  233. <xsl:param name="filename" select="''"/>
  234. <xsl:param name="quiet" select="$chunk.quietly"/>
  235. <xsl:param name="method" select="$chunker.output.method"/>
  236. <xsl:param name="encoding" select="$chunker.output.encoding"/>
  237. <xsl:param name="indent" select="$chunker.output.indent"/>
  238. <xsl:param name="omit-xml-declaration" select="$chunker.output.omit-xml-declaration"/>
  239. <xsl:param name="standalone" select="$chunker.output.standalone"/>
  240. <xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
  241. <xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
  242. <xsl:param name="media-type" select="$chunker.output.media-type"/>
  243. <xsl:param name="cdata-section-elements" select="$chunker.output.cdata-section-elements"/>
  244. <xsl:param name="content"/>
  245. <xsl:call-template name="write.chunk">
  246. <xsl:with-param name="filename" select="$filename"/>
  247. <xsl:with-param name="quiet" select="$quiet"/>
  248. <xsl:with-param name="method" select="$method"/>
  249. <xsl:with-param name="encoding" select="$encoding"/>
  250. <xsl:with-param name="indent" select="$indent"/>
  251. <xsl:with-param name="omit-xml-declaration" select="$omit-xml-declaration"/>
  252. <xsl:with-param name="standalone" select="$standalone"/>
  253. <xsl:with-param name="doctype-public" select="$doctype-public"/>
  254. <xsl:with-param name="doctype-system" select="$doctype-system"/>
  255. <xsl:with-param name="media-type" select="$media-type"/>
  256. <xsl:with-param name="cdata-section-elements" select="$cdata-section-elements"/>
  257. <xsl:with-param name="content" select="$content"/>
  258. </xsl:call-template>
  259. </xsl:template>
  260. <xsl:template name="write.text.chunk">
  261. <xsl:param name="filename" select="''"/>
  262. <xsl:param name="quiet" select="$chunk.quietly"/>
  263. <xsl:param name="suppress-context-node-name" select="0"/>
  264. <xsl:param name="message-prolog"/>
  265. <xsl:param name="message-epilog"/>
  266. <xsl:param name="method" select="'text'"/>
  267. <xsl:param name="encoding" select="$chunker.output.encoding"/>
  268. <xsl:param name="media-type" select="$chunker.output.media-type"/>
  269. <xsl:param name="content"/>
  270. <xsl:call-template name="write.chunk">
  271. <xsl:with-param name="filename" select="$filename"/>
  272. <xsl:with-param name="quiet" select="$quiet"/>
  273. <xsl:with-param name="suppress-context-node-name" select="$suppress-context-node-name"/>
  274. <xsl:with-param name="message-prolog" select="$message-prolog"/>
  275. <xsl:with-param name="message-epilog" select="$message-epilog"/>
  276. <xsl:with-param name="method" select="$method"/>
  277. <xsl:with-param name="encoding" select="$encoding"/>
  278. <xsl:with-param name="indent" select="'no'"/>
  279. <xsl:with-param name="omit-xml-declaration" select="'yes'"/>
  280. <xsl:with-param name="standalone" select="'no'"/>
  281. <xsl:with-param name="doctype-public"/>
  282. <xsl:with-param name="doctype-system"/>
  283. <xsl:with-param name="media-type" select="$media-type"/>
  284. <xsl:with-param name="cdata-section-elements"/>
  285. <xsl:with-param name="content" select="$content"/>
  286. </xsl:call-template>
  287. </xsl:template>
  288. </xsl:stylesheet>