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 8526 2009-10-14 18:59:40Z 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.1//EN'"/>
28 <xsl:param name="chunker.output.doctype-system" select="'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'"/>
29 <xsl:param name="chunker.output.media-type" select="''"/>
30 <xsl:param name="chunker.output.cdata-section-elements" select="''"/>
31 <xsl:param name="chunker.output.quiet" select="0"/>
33 <xsl:param name="saxon.character.representation" select="'entity;decimal'"/>
35 <!-- ==================================================================== -->
37 <xsl:template name="make-relative-filename">
38 <xsl:param name="base.dir" select="'./'"/>
39 <xsl:param name="base.name" select="''"/>
42 <!-- put Saxon first to work around a bug in libxslt -->
43 <xsl:when test="element-available('saxon:output')">
44 <!-- Saxon doesn't make the chunks relative -->
45 <xsl:value-of select="concat($base.dir,$base.name)"/>
47 <xsl:when test="element-available('exsl:document')">
48 <!-- EXSL document does make the chunks relative, I think -->
50 <xsl:when test="count(parent::*) = 0">
51 <xsl:value-of select="concat($base.dir,$base.name)"/>
54 <xsl:value-of select="$base.name"/>
58 <xsl:when test="element-available('redirect:write')">
59 <!-- Xalan doesn't make the chunks relative -->
60 <xsl:value-of select="concat($base.dir,$base.name)"/>
63 <xsl:message terminate="yes">
64 <xsl:text>Don't know how to chunk with </xsl:text>
65 <xsl:value-of select="system-property('xsl:vendor')"/>
71 <xsl:template name="write.chunk">
72 <xsl:param name="filename" select="''"/>
73 <xsl:param name="quiet" select="$chunker.output.quiet"/>
74 <xsl:param name="suppress-context-node-name" select="0"/>
75 <xsl:param name="message-prolog"/>
76 <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"/>
88 <xsl:param name="content"/>
90 <xsl:if test="$quiet = 0">
92 <xsl:if test="not($message-prolog = '')">
93 <xsl:value-of select="$message-prolog"/>
95 <xsl:text>Writing </xsl:text>
96 <xsl:value-of select="$filename"/>
97 <xsl:if test="name(.) != '' and $suppress-context-node-name = 0">
98 <xsl:text> for </xsl:text>
99 <xsl:value-of select="name(.)"/>
100 <xsl:if test="@id or @xml:id">
101 <xsl:text>(</xsl:text>
102 <xsl:value-of select="(@id|@xml:id)[1]"/>
103 <xsl:text>)</xsl:text>
106 <xsl:if test="not($message-epilog = '')">
107 <xsl:value-of select="$message-epilog"/>
113 <xsl:when test="element-available('exsl:document')">
115 <!-- Handle the permutations ... -->
116 <xsl:when test="$media-type != ''">
118 <xsl:when test="$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}" doctype-public="{$doctype-public}" doctype-system="{$doctype-system}" standalone="{$standalone}">
120 <xsl:copy-of select="$content"/>
123 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
124 <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}">
125 <xsl:copy-of select="$content"/>
128 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
129 <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}">
130 <xsl:copy-of select="$content"/>
133 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
134 <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}">
135 <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}" doctype-public="{$doctype-public}" doctype-system="{$doctype-system}" standalone="{$standalone}">
144 <xsl:copy-of select="$content"/>
147 <xsl:when test="$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}" doctype-public="{$doctype-public}" standalone="{$standalone}">
149 <xsl:copy-of select="$content"/>
152 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
153 <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}">
154 <xsl:copy-of select="$content"/>
157 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
158 <exsl:document href="{$filename}" method="{$method}" encoding="{$encoding}" indent="{$indent}" omit-xml-declaration="{$omit-xml-declaration}" cdata-section-elements="{$cdata-section-elements}" standalone="{$standalone}">
159 <xsl:copy-of select="$content"/>
167 <xsl:when test="element-available('saxon:output')">
169 <!-- Handle the permutations ... -->
170 <xsl:when test="$media-type != ''">
172 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
173 <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}">
174 <xsl:copy-of select="$content"/>
177 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
178 <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}">
179 <xsl:copy-of select="$content"/>
182 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
183 <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}">
184 <xsl:copy-of select="$content"/>
187 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
188 <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}">
189 <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}" doctype-public="{$doctype-public}" doctype-system="{$doctype-system}" standalone="{$standalone}">
198 <xsl:copy-of select="$content"/>
201 <xsl:when test="$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}" doctype-public="{$doctype-public}" standalone="{$standalone}">
203 <xsl:copy-of select="$content"/>
206 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
207 <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}">
208 <xsl:copy-of select="$content"/>
211 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
212 <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}">
213 <xsl:copy-of select="$content"/>
221 <xsl:when test="element-available('redirect:write')">
222 <!-- Xalan uses redirect -->
223 <redirect:write file="{$filename}">
224 <xsl:copy-of select="$content"/>
229 <!-- it doesn't matter since we won't be making chunks... -->
230 <xsl:message terminate="yes">
231 <xsl:text>Can't make chunks with </xsl:text>
232 <xsl:value-of select="system-property('xsl:vendor')"/>
233 <xsl:text>'s processor.</xsl:text>
239 <xsl:template name="write.chunk.with.doctype">
240 <xsl:param name="filename" select="''"/>
241 <xsl:param name="quiet" select="$chunker.output.quiet"/>
243 <xsl:param name="method" select="$chunker.output.method"/>
244 <xsl:param name="encoding" select="$chunker.output.encoding"/>
245 <xsl:param name="indent" select="$chunker.output.indent"/>
246 <xsl:param name="omit-xml-declaration" select="$chunker.output.omit-xml-declaration"/>
247 <xsl:param name="standalone" select="$chunker.output.standalone"/>
248 <xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
249 <xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
250 <xsl:param name="media-type" select="$chunker.output.media-type"/>
251 <xsl:param name="cdata-section-elements" select="$chunker.output.cdata-section-elements"/>
253 <xsl:param name="content"/>
255 <xsl:call-template name="write.chunk">
256 <xsl:with-param name="filename" select="$filename"/>
257 <xsl:with-param name="quiet" select="$quiet"/>
258 <xsl:with-param name="method" select="$method"/>
259 <xsl:with-param name="encoding" select="$encoding"/>
260 <xsl:with-param name="indent" select="$indent"/>
261 <xsl:with-param name="omit-xml-declaration" select="$omit-xml-declaration"/>
262 <xsl:with-param name="standalone" select="$standalone"/>
263 <xsl:with-param name="doctype-public" select="$doctype-public"/>
264 <xsl:with-param name="doctype-system" select="$doctype-system"/>
265 <xsl:with-param name="media-type" select="$media-type"/>
266 <xsl:with-param name="cdata-section-elements" select="$cdata-section-elements"/>
267 <xsl:with-param name="content" select="$content"/>
271 <xsl:template name="write.text.chunk">
272 <xsl:param name="filename" select="''"/>
273 <xsl:param name="quiet" select="$chunker.output.quiet"/>
274 <xsl:param name="suppress-context-node-name" select="0"/>
275 <xsl:param name="message-prolog"/>
276 <xsl:param name="message-epilog"/>
277 <xsl:param name="method" select="'text'"/>
278 <xsl:param name="encoding" select="$chunker.output.encoding"/>
279 <xsl:param name="media-type" select="$chunker.output.media-type"/>
280 <xsl:param name="content"/>
282 <xsl:call-template name="write.chunk">
283 <xsl:with-param name="filename" select="$filename"/>
284 <xsl:with-param name="quiet" select="$quiet"/>
285 <xsl:with-param name="suppress-context-node-name" select="$suppress-context-node-name"/>
286 <xsl:with-param name="message-prolog" select="$message-prolog"/>
287 <xsl:with-param name="message-epilog" select="$message-epilog"/>
288 <xsl:with-param name="method" select="$method"/>
289 <xsl:with-param name="encoding" select="$encoding"/>
290 <xsl:with-param name="indent" select="'no'"/>
291 <xsl:with-param name="omit-xml-declaration" select="'no'"/>
292 <xsl:with-param name="standalone" select="'no'"/>
293 <xsl:with-param name="doctype-public"/>
294 <xsl:with-param name="doctype-system"/>
295 <xsl:with-param name="media-type" select="$media-type"/>
296 <xsl:with-param name="cdata-section-elements"/>
297 <xsl:with-param name="content" select="$content"/>