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">
6 <!-- ********************************************************************
7 $Id: chunker.xsl 9741 2013-04-11 21:57:59Z bobstayton $
8 ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
18 <!-- This stylesheet works with XSLT implementations that support -->
19 <!-- exsl:document, saxon:output, or Xalan's redirect:write -->
20 <!-- Note: Only Saxon 6.4.2 or later is supported. -->
22 <xsl:param name="chunker.output.method" select="'xml'"/>
23 <xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
24 <xsl:param name="chunker.output.indent" select="'no'"/>
25 <xsl:param name="chunker.output.omit-xml-declaration" select="'no'"/>
26 <xsl:param name="chunker.output.standalone" select="'no'"/>
27 <xsl:param name="chunker.output.doctype-public" select="'-//W3C//DTD XHTML 1.0 Transitional//EN'"/>
28 <xsl:param name="chunker.output.doctype-system" select="'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'"/>
29 <xsl:param name="chunker.output.media-type" select="''"/>
30 <xsl:param name="chunker.output.cdata-section-elements" select="''"/>
32 <!-- Make sure base.dir has a trailing slash. -->
33 <!-- This is an internal-only variable. Customize $base.dir instead. -->
34 <xsl:variable name="chunk.base.dir">
36 <xsl:when test="string-length($base.dir) = 0"/>
37 <!-- make sure to add trailing slash if omitted by user -->
38 <xsl:when test="substring($base.dir, string-length($base.dir), 1) = '/'">
39 <xsl:value-of select="$base.dir"/>
42 <xsl:value-of select="concat($base.dir, '/')"/>
47 <xsl:param name="saxon.character.representation" select="'entity;decimal'"/>
49 <!-- ==================================================================== -->
51 <xsl:template name="make-relative-filename">
52 <xsl:param name="base.dir" select="'./'"/>
53 <xsl:param name="base.name" select="''"/>
56 <!-- put Saxon first to work around a bug in libxslt -->
57 <xsl:when test="element-available('saxon:output')">
58 <!-- Saxon doesn't make the chunks relative -->
59 <xsl:value-of select="concat($base.dir,$base.name)"/>
61 <xsl:when test="element-available('exsl:document')">
62 <!-- EXSL document does make the chunks relative, I think -->
64 <xsl:when test="count(parent::*) = 0">
65 <xsl:value-of select="concat($base.dir,$base.name)"/>
68 <xsl:value-of select="$base.name"/>
72 <xsl:when test="element-available('redirect:write')">
73 <!-- Xalan doesn't make the chunks relative -->
74 <xsl:value-of select="concat($base.dir,$base.name)"/>
77 <xsl:message terminate="yes">
78 <xsl:text>Don't know how to chunk with </xsl:text>
79 <xsl:value-of select="system-property('xsl:vendor')"/>
85 <xsl:template name="write.chunk">
86 <xsl:param name="filename" select="''"/>
87 <xsl:param name="quiet" select="$chunk.quietly"/>
88 <xsl:param name="suppress-context-node-name" select="0"/>
89 <xsl:param name="message-prolog"/>
90 <xsl:param name="message-epilog"/>
92 <xsl:param name="method" select="$chunker.output.method"/>
93 <xsl:param name="encoding" select="$chunker.output.encoding"/>
94 <xsl:param name="indent" select="$chunker.output.indent"/>
95 <xsl:param name="omit-xml-declaration" select="$chunker.output.omit-xml-declaration"/>
96 <xsl:param name="standalone" select="$chunker.output.standalone"/>
97 <xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
98 <xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
99 <xsl:param name="media-type" select="$chunker.output.media-type"/>
100 <xsl:param name="cdata-section-elements" select="$chunker.output.cdata-section-elements"/>
102 <xsl:param name="content"/>
104 <xsl:if test="$quiet = 0">
106 <xsl:if test="not($message-prolog = '')">
107 <xsl:value-of select="$message-prolog"/>
109 <xsl:text>Writing </xsl:text>
110 <xsl:value-of select="$filename"/>
111 <xsl:if test="name(.) != '' and $suppress-context-node-name = 0">
112 <xsl:text> for </xsl:text>
113 <xsl:value-of select="name(.)"/>
114 <xsl:if test="@id or @xml:id">
115 <xsl:text>(</xsl:text>
116 <xsl:value-of select="(@id|@xml:id)[1]"/>
117 <xsl:text>)</xsl:text>
120 <xsl:if test="not($message-epilog = '')">
121 <xsl:value-of select="$message-epilog"/>
127 <xsl:when test="element-available('exsl:document')">
129 <!-- Handle the permutations ... -->
130 <xsl:when test="$media-type != ''">
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}" media-type="{$media-type}" doctype-public="{$doctype-public}" doctype-system="{$doctype-system}" standalone="{$standalone}">
134 <xsl:copy-of select="$content"/>
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}" media-type="{$media-type}" doctype-public="{$doctype-public}" standalone="{$standalone}">
139 <xsl:copy-of select="$content"/>
142 <xsl:when test="$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}" media-type="{$media-type}" doctype-system="{$doctype-system}" standalone="{$standalone}">
144 <xsl:copy-of select="$content"/>
147 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
148 <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}">
149 <xsl:copy-of select="$content"/>
156 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
157 <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}">
158 <xsl:copy-of select="$content"/>
161 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
162 <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}">
163 <xsl:copy-of select="$content"/>
166 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
167 <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}">
168 <xsl:copy-of select="$content"/>
171 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
172 <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" standalone="{$standalone}">
173 <xsl:copy-of select="$content"/>
181 <xsl:when test="element-available('saxon:output')">
183 <!-- Handle the permutations ... -->
184 <xsl:when test="$media-type != ''">
186 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
187 <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}">
188 <xsl:copy-of select="$content"/>
191 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
192 <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}">
193 <xsl:copy-of select="$content"/>
196 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
197 <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}">
198 <xsl:copy-of select="$content"/>
201 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
202 <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}">
203 <xsl:copy-of select="$content"/>
210 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
211 <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}">
212 <xsl:copy-of select="$content"/>
215 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
216 <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}">
217 <xsl:copy-of select="$content"/>
220 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
221 <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}">
222 <xsl:copy-of select="$content"/>
225 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
226 <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}">
227 <xsl:copy-of select="$content"/>
235 <xsl:when test="element-available('redirect:write')">
236 <!-- Xalan uses redirect -->
237 <redirect:write file="{$filename}">
238 <xsl:copy-of select="$content"/>
243 <!-- it doesn't matter since we won't be making chunks... -->
244 <xsl:message terminate="yes">
245 <xsl:text>Can't make chunks with </xsl:text>
246 <xsl:value-of select="system-property('xsl:vendor')"/>
247 <xsl:text>'s processor.</xsl:text>
253 <xsl:template name="write.chunk.with.doctype">
254 <xsl:param name="filename" select="''"/>
255 <xsl:param name="quiet" select="$chunk.quietly"/>
257 <xsl:param name="method" select="$chunker.output.method"/>
258 <xsl:param name="encoding" select="$chunker.output.encoding"/>
259 <xsl:param name="indent" select="$chunker.output.indent"/>
260 <xsl:param name="omit-xml-declaration" select="$chunker.output.omit-xml-declaration"/>
261 <xsl:param name="standalone" select="$chunker.output.standalone"/>
262 <xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
263 <xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
264 <xsl:param name="media-type" select="$chunker.output.media-type"/>
265 <xsl:param name="cdata-section-elements" select="$chunker.output.cdata-section-elements"/>
267 <xsl:param name="content"/>
269 <xsl:call-template name="write.chunk">
270 <xsl:with-param name="filename" select="$filename"/>
271 <xsl:with-param name="quiet" select="$quiet"/>
272 <xsl:with-param name="method" select="$method"/>
273 <xsl:with-param name="encoding" select="$encoding"/>
274 <xsl:with-param name="indent" select="$indent"/>
275 <xsl:with-param name="omit-xml-declaration" select="$omit-xml-declaration"/>
276 <xsl:with-param name="standalone" select="$standalone"/>
277 <xsl:with-param name="doctype-public" select="$doctype-public"/>
278 <xsl:with-param name="doctype-system" select="$doctype-system"/>
279 <xsl:with-param name="media-type" select="$media-type"/>
280 <xsl:with-param name="cdata-section-elements" select="$cdata-section-elements"/>
281 <xsl:with-param name="content" select="$content"/>
285 <xsl:template name="write.text.chunk">
286 <xsl:param name="filename" select="''"/>
287 <xsl:param name="quiet" select="$chunk.quietly"/>
288 <xsl:param name="suppress-context-node-name" select="0"/>
289 <xsl:param name="message-prolog"/>
290 <xsl:param name="message-epilog"/>
291 <xsl:param name="method" select="'text'"/>
292 <xsl:param name="encoding" select="$chunker.output.encoding"/>
293 <xsl:param name="media-type" select="$chunker.output.media-type"/>
294 <xsl:param name="content"/>
296 <xsl:call-template name="write.chunk">
297 <xsl:with-param name="filename" select="$filename"/>
298 <xsl:with-param name="quiet" select="$quiet"/>
299 <xsl:with-param name="suppress-context-node-name" select="$suppress-context-node-name"/>
300 <xsl:with-param name="message-prolog" select="$message-prolog"/>
301 <xsl:with-param name="message-epilog" select="$message-epilog"/>
302 <xsl:with-param name="method" select="$method"/>
303 <xsl:with-param name="encoding" select="$encoding"/>
304 <xsl:with-param name="indent" select="'no'"/>
305 <xsl:with-param name="omit-xml-declaration" select="'yes'"/>
306 <xsl:with-param name="standalone" select="'no'"/>
307 <xsl:with-param name="doctype-public"/>
308 <xsl:with-param name="doctype-system"/>
309 <xsl:with-param name="media-type" select="$media-type"/>
310 <xsl:with-param name="cdata-section-elements"/>
311 <xsl:with-param name="content" select="$content"/>