1
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
xmlns:saxon="http://icl.com/saxon"
3
xmlns:lxslt="http://xml.apache.org/xslt"
4
xmlns:xalanredirect="org.apache.xalan.xslt.extensions.Redirect"
5
xmlns:exsl="http://exslt.org/common"
6
xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
8
exclude-result-prefixes="doc"
9
extension-element-prefixes="saxon xalanredirect lxslt exsl">
11
<!-- ********************************************************************
12
$Id: chunker.xsl 1341 2006-08-02 16:35:13Z telrod $
13
********************************************************************
15
This file is part of the XSL DocBook Stylesheet distribution.
16
See ../README or http://nwalsh.com/docbook/xsl/ for copyright
17
and other information.
19
******************************************************************** -->
21
<!-- ==================================================================== -->
23
<!-- This stylesheet works with XSLT implementations that support -->
24
<!-- exsl:document, saxon:output, or xalanredirect:write -->
25
<!-- Note: Only Saxon 6.4.2 or later is supported. -->
27
<xsl:param name="chunker.output.method" select="'html'"/>
28
<xsl:param name="chunker.output.encoding" select="'ISO-8859-1'"/>
29
<xsl:param name="chunker.output.indent" select="'no'"/>
30
<xsl:param name="chunker.output.omit-xml-declaration" select="'no'"/>
31
<xsl:param name="chunker.output.standalone" select="'no'"/>
32
<xsl:param name="chunker.output.doctype-public" select="''"/>
33
<xsl:param name="chunker.output.doctype-system" select="''"/>
34
<xsl:param name="chunker.output.media-type" select="''"/>
35
<xsl:param name="chunker.output.cdata-section-elements" select="''"/>
37
<xsl:param name="saxon.character.representation" select="'entity;decimal'"/>
39
<!-- ==================================================================== -->
41
<xsl:template name="make-relative-filename">
42
<xsl:param name="base.dir" select="'./'"/>
43
<xsl:param name="base.name" select="''"/>
46
<!-- put Saxon first to work around a bug in libxslt -->
47
<xsl:when test="element-available('saxon:output')">
48
<!-- Saxon doesn't make the chunks relative -->
49
<xsl:value-of select="concat($base.dir,$base.name)"/>
51
<xsl:when test="element-available('exsl:document')">
52
<!-- EXSL document does make the chunks relative, I think -->
54
<xsl:when test="count(parent::*) = 0">
55
<xsl:value-of select="concat($base.dir,$base.name)"/>
58
<xsl:value-of select="$base.name"/>
62
<xsl:when test="element-available('xalanredirect:write')">
63
<!-- Xalan doesn't make the chunks relative -->
64
<xsl:value-of select="concat($base.dir,$base.name)"/>
67
<xsl:message terminate="yes">
68
<xsl:text>Don't know how to chunk with </xsl:text>
69
<xsl:value-of select="system-property('xsl:vendor')"/>
75
<xsl:template name="write.chunk">
76
<xsl:param name="filename" select="''"/>
77
<xsl:param name="quiet" select="0"/>
79
<xsl:param name="method" select="$chunker.output.method"/>
80
<xsl:param name="encoding" select="$chunker.output.encoding"/>
81
<xsl:param name="indent" select="$chunker.output.indent"/>
82
<xsl:param name="omit-xml-declaration"
83
select="$chunker.output.omit-xml-declaration"/>
84
<xsl:param name="standalone" select="$chunker.output.standalone"/>
85
<xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
86
<xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
87
<xsl:param name="media-type" select="$chunker.output.media-type"/>
88
<xsl:param name="cdata-section-elements"
89
select="$chunker.output.cdata-section-elements"/>
91
<xsl:param name="content"/>
93
<xsl:if test="$quiet = 0">
95
<xsl:text>Writing </xsl:text>
96
<xsl:value-of select="$filename"/>
97
<xsl:if test="name(.) != ''">
98
<xsl:text> for </xsl:text>
99
<xsl:value-of select="name(.)"/>
101
<xsl:text>(</xsl:text>
102
<xsl:value-of select="@id"/>
103
<xsl:text>)</xsl:text>
110
<xsl:when test="element-available('exsl:document')">
112
<!-- Handle the permutations ... -->
113
<xsl:when test="$media-type != ''">
115
<xsl:when test="$doctype-public != '' and $doctype-system != ''">
116
<exsl:document href="{$filename}"
118
encoding="{$encoding}"
120
omit-xml-declaration="{$omit-xml-declaration}"
121
cdata-section-elements="{$cdata-section-elements}"
122
media-type="{$media-type}"
123
doctype-public="{$doctype-public}"
124
doctype-system="{$doctype-system}"
125
standalone="{$standalone}">
126
<xsl:copy-of select="$content"/>
129
<xsl:when test="$doctype-public != '' and $doctype-system = ''">
130
<exsl:document href="{$filename}"
132
encoding="{$encoding}"
134
omit-xml-declaration="{$omit-xml-declaration}"
135
cdata-section-elements="{$cdata-section-elements}"
136
media-type="{$media-type}"
137
doctype-public="{$doctype-public}"
138
standalone="{$standalone}">
139
<xsl:copy-of select="$content"/>
142
<xsl:when test="$doctype-public = '' and $doctype-system != ''">
143
<exsl:document href="{$filename}"
145
encoding="{$encoding}"
147
omit-xml-declaration="{$omit-xml-declaration}"
148
cdata-section-elements="{$cdata-section-elements}"
149
media-type="{$media-type}"
150
doctype-system="{$doctype-system}"
151
standalone="{$standalone}">
152
<xsl:copy-of select="$content"/>
155
<xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
156
<exsl:document href="{$filename}"
158
encoding="{$encoding}"
160
omit-xml-declaration="{$omit-xml-declaration}"
161
cdata-section-elements="{$cdata-section-elements}"
162
media-type="{$media-type}"
163
standalone="{$standalone}">
164
<xsl:copy-of select="$content"/>
171
<xsl:when test="$doctype-public != '' and $doctype-system != ''">
172
<exsl:document href="{$filename}"
174
encoding="{$encoding}"
176
omit-xml-declaration="{$omit-xml-declaration}"
177
cdata-section-elements="{$cdata-section-elements}"
178
doctype-public="{$doctype-public}"
179
doctype-system="{$doctype-system}"
180
standalone="{$standalone}">
181
<xsl:copy-of select="$content"/>
184
<xsl:when test="$doctype-public != '' and $doctype-system = ''">
185
<exsl:document href="{$filename}"
187
encoding="{$encoding}"
189
omit-xml-declaration="{$omit-xml-declaration}"
190
cdata-section-elements="{$cdata-section-elements}"
191
doctype-public="{$doctype-public}"
192
standalone="{$standalone}">
193
<xsl:copy-of select="$content"/>
196
<xsl:when test="$doctype-public = '' and $doctype-system != ''">
197
<exsl:document href="{$filename}"
199
encoding="{$encoding}"
201
omit-xml-declaration="{$omit-xml-declaration}"
202
cdata-section-elements="{$cdata-section-elements}"
203
doctype-system="{$doctype-system}"
204
standalone="{$standalone}">
205
<xsl:copy-of select="$content"/>
208
<xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
209
<exsl:document href="{$filename}"
211
encoding="{$encoding}"
213
omit-xml-declaration="{$omit-xml-declaration}"
214
cdata-section-elements="{$cdata-section-elements}"
215
standalone="{$standalone}">
216
<xsl:copy-of select="$content"/>
224
<xsl:when test="element-available('saxon:output')">
226
<!-- Handle the permutations ... -->
227
<xsl:when test="$media-type != ''">
229
<xsl:when test="$doctype-public != '' and $doctype-system != ''">
230
<saxon:output saxon:character-representation="{$saxon.character.representation}"
233
encoding="{$encoding}"
235
omit-xml-declaration="{$omit-xml-declaration}"
236
cdata-section-elements="{$cdata-section-elements}"
237
media-type="{$media-type}"
238
doctype-public="{$doctype-public}"
239
doctype-system="{$doctype-system}"
240
standalone="{$standalone}">
241
<xsl:copy-of select="$content"/>
244
<xsl:when test="$doctype-public != '' and $doctype-system = ''">
245
<saxon:output saxon:character-representation="{$saxon.character.representation}"
248
encoding="{$encoding}"
250
omit-xml-declaration="{$omit-xml-declaration}"
251
cdata-section-elements="{$cdata-section-elements}"
252
media-type="{$media-type}"
253
doctype-public="{$doctype-public}"
254
standalone="{$standalone}">
255
<xsl:copy-of select="$content"/>
258
<xsl:when test="$doctype-public = '' and $doctype-system != ''">
259
<saxon:output saxon:character-representation="{$saxon.character.representation}"
262
encoding="{$encoding}"
264
omit-xml-declaration="{$omit-xml-declaration}"
265
cdata-section-elements="{$cdata-section-elements}"
266
media-type="{$media-type}"
267
doctype-system="{$doctype-system}"
268
standalone="{$standalone}">
269
<xsl:copy-of select="$content"/>
272
<xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
273
<saxon:output saxon:character-representation="{$saxon.character.representation}"
276
encoding="{$encoding}"
278
omit-xml-declaration="{$omit-xml-declaration}"
279
cdata-section-elements="{$cdata-section-elements}"
280
media-type="{$media-type}"
281
standalone="{$standalone}">
282
<xsl:copy-of select="$content"/>
289
<xsl:when test="$doctype-public != '' and $doctype-system != ''">
290
<saxon:output saxon:character-representation="{$saxon.character.representation}"
293
encoding="{$encoding}"
295
omit-xml-declaration="{$omit-xml-declaration}"
296
cdata-section-elements="{$cdata-section-elements}"
297
doctype-public="{$doctype-public}"
298
doctype-system="{$doctype-system}"
299
standalone="{$standalone}">
300
<xsl:copy-of select="$content"/>
303
<xsl:when test="$doctype-public != '' and $doctype-system = ''">
304
<saxon:output saxon:character-representation="{$saxon.character.representation}"
307
encoding="{$encoding}"
309
omit-xml-declaration="{$omit-xml-declaration}"
310
cdata-section-elements="{$cdata-section-elements}"
311
doctype-public="{$doctype-public}"
312
standalone="{$standalone}">
313
<xsl:copy-of select="$content"/>
316
<xsl:when test="$doctype-public = '' and $doctype-system != ''">
317
<saxon:output saxon:character-representation="{$saxon.character.representation}"
320
encoding="{$encoding}"
322
omit-xml-declaration="{$omit-xml-declaration}"
323
cdata-section-elements="{$cdata-section-elements}"
324
doctype-system="{$doctype-system}"
325
standalone="{$standalone}">
326
<xsl:copy-of select="$content"/>
329
<xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
330
<saxon:output saxon:character-representation="{$saxon.character.representation}"
333
encoding="{$encoding}"
335
omit-xml-declaration="{$omit-xml-declaration}"
336
cdata-section-elements="{$cdata-section-elements}"
337
standalone="{$standalone}">
338
<xsl:copy-of select="$content"/>
346
<xsl:when test="element-available('xalanredirect:write')">
347
<!-- Xalan uses xalanredirect -->
348
<xalanredirect:write file="{$filename}">
349
<xsl:copy-of select="$content"/>
350
</xalanredirect:write>
354
<!-- it doesn't matter since we won't be making chunks... -->
355
<xsl:message terminate="yes">
356
<xsl:text>Can't make chunks with </xsl:text>
357
<xsl:value-of select="system-property('xsl:vendor')"/>
358
<xsl:text>'s processor.</xsl:text>
364
<xsl:template name="write.chunk.with.doctype">
365
<xsl:param name="filename" select="''"/>
366
<xsl:param name="quiet" select="0"/>
368
<xsl:param name="method" select="$chunker.output.method"/>
369
<xsl:param name="encoding" select="$chunker.output.encoding"/>
370
<xsl:param name="indent" select="$chunker.output.indent"/>
371
<xsl:param name="omit-xml-declaration"
372
select="$chunker.output.omit-xml-declaration"/>
373
<xsl:param name="standalone" select="$chunker.output.standalone"/>
374
<xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
375
<xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
376
<xsl:param name="media-type" select="$chunker.output.media-type"/>
377
<xsl:param name="cdata-section-elements"
378
select="$chunker.output.cdata-section-elements"/>
380
<xsl:param name="content"/>
382
<xsl:call-template name="write.chunk">
383
<xsl:with-param name="filename" select="$filename"/>
384
<xsl:with-param name="quiet" select="$quiet"/>
385
<xsl:with-param name="method" select="$method"/>
386
<xsl:with-param name="encoding" select="$encoding"/>
387
<xsl:with-param name="indent" select="$indent"/>
388
<xsl:with-param name="omit-xml-declaration" select="$omit-xml-declaration"/>
389
<xsl:with-param name="standalone" select="$standalone"/>
390
<xsl:with-param name="doctype-public" select="$doctype-public"/>
391
<xsl:with-param name="doctype-system" select="$doctype-system"/>
392
<xsl:with-param name="media-type" select="$media-type"/>
393
<xsl:with-param name="cdata-section-elements" select="$cdata-section-elements"/>
394
<xsl:with-param name="content" select="$content"/>
398
<xsl:template name="write.text.chunk">
399
<xsl:param name="filename" select="''"/>
400
<xsl:param name="quiet" select="0"/>
401
<xsl:param name="method" select="'text'"/>
402
<xsl:param name="encoding" select="$chunker.output.encoding"/>
403
<xsl:param name="media-type" select="$chunker.output.media-type"/>
404
<xsl:param name="content"/>
406
<xsl:call-template name="write.chunk">
407
<xsl:with-param name="filename" select="$filename"/>
408
<xsl:with-param name="quiet" select="$quiet"/>
409
<xsl:with-param name="method" select="$method"/>
410
<xsl:with-param name="encoding" select="$encoding"/>
411
<xsl:with-param name="indent" select="'no'"/>
412
<xsl:with-param name="omit-xml-declaration" select="'no'"/>
413
<xsl:with-param name="standalone" select="'no'"/>
414
<xsl:with-param name="doctype-public"/>
415
<xsl:with-param name="doctype-system"/>
416
<xsl:with-param name="media-type" select="$media-type"/>
417
<xsl:with-param name="cdata-section-elements"/>
418
<xsl:with-param name="content" select="$content"/>