source: trunk/Distribution/XSL/html/chunker.xsl@ 2

Last change on this file since 2 was 2, checked in by jkacer, 18 years ago

Added all DocBook Framework stuff:

  • DocBook DTD
  • Transformation software FOP 0.20.5 and Saxon 6
  • XSL styles
  • Rexx scripts

Also added some WarpIN-related stuff for creation of WarpIN installation packages.
This state corresponds to version 1.0.0 from November 2005, just slightly modified to carry versioning information (Rexx scripts).

File size: 19.7 KB
Line 
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"
7 version="1.1"
8 exclude-result-prefixes="doc"
9 extension-element-prefixes="saxon xalanredirect lxslt exsl">
10
11<!-- ********************************************************************
12 $Id: chunker.xsl,v 1.24 2003/11/30 19:42:23 bobstayton Exp $
13 ********************************************************************
14
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.
18
19 ******************************************************************** -->
20
21<!-- ==================================================================== -->
22
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. -->
26
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="''"/>
36
37<xsl:param name="saxon.character.representation" select="'entity;decimal'"/>
38
39<!-- ==================================================================== -->
40
41<xsl:template name="make-relative-filename">
42 <xsl:param name="base.dir" select="'./'"/>
43 <xsl:param name="base.name" select="''"/>
44
45 <xsl:choose>
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)"/>
50 </xsl:when>
51 <xsl:when test="element-available('exsl:document')">
52 <!-- EXSL document does make the chunks relative, I think -->
53 <xsl:choose>
54 <xsl:when test="count(parent::*) = 0">
55 <xsl:value-of select="concat($base.dir,$base.name)"/>
56 </xsl:when>
57 <xsl:otherwise>
58 <xsl:value-of select="$base.name"/>
59 </xsl:otherwise>
60 </xsl:choose>
61 </xsl:when>
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)"/>
65 </xsl:when>
66 <xsl:otherwise>
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')"/>
70 </xsl:message>
71 </xsl:otherwise>
72 </xsl:choose>
73</xsl:template>
74
75<xsl:template name="write.chunk">
76 <xsl:param name="filename" select="''"/>
77 <xsl:param name="quiet" select="0"/>
78
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"/>
90
91 <xsl:param name="content"/>
92
93 <xsl:if test="$quiet = 0">
94 <xsl:message>
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(.)"/>
100 <xsl:if test="@id">
101 <xsl:text>(</xsl:text>
102 <xsl:value-of select="@id"/>
103 <xsl:text>)</xsl:text>
104 </xsl:if>
105 </xsl:if>
106 </xsl:message>
107 </xsl:if>
108
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}"
117 method="{$method}"
118 encoding="{$encoding}"
119 indent="{$indent}"
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"/>
127 </exsl:document>
128 </xsl:when>
129 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
130 <exsl:document href="{$filename}"
131 method="{$method}"
132 encoding="{$encoding}"
133 indent="{$indent}"
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"/>
140 </exsl:document>
141 </xsl:when>
142 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
143 <exsl:document href="{$filename}"
144 method="{$method}"
145 encoding="{$encoding}"
146 indent="{$indent}"
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"/>
153 </exsl:document>
154 </xsl:when>
155 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
156 <exsl:document href="{$filename}"
157 method="{$method}"
158 encoding="{$encoding}"
159 indent="{$indent}"
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"/>
165 </exsl:document>
166 </xsl:otherwise>
167 </xsl:choose>
168 </xsl:when>
169 <xsl:otherwise>
170 <xsl:choose>
171 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
172 <exsl:document href="{$filename}"
173 method="{$method}"
174 encoding="{$encoding}"
175 indent="{$indent}"
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"/>
182 </exsl:document>
183 </xsl:when>
184 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
185 <exsl:document href="{$filename}"
186 method="{$method}"
187 encoding="{$encoding}"
188 indent="{$indent}"
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"/>
194 </exsl:document>
195 </xsl:when>
196 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
197 <exsl:document href="{$filename}"
198 method="{$method}"
199 encoding="{$encoding}"
200 indent="{$indent}"
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"/>
206 </exsl:document>
207 </xsl:when>
208 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
209 <exsl:document href="{$filename}"
210 method="{$method}"
211 encoding="{$encoding}"
212 indent="{$indent}"
213 omit-xml-declaration="{$omit-xml-declaration}"
214 cdata-section-elements="{$cdata-section-elements}"
215 standalone="{$standalone}">
216 <xsl:copy-of select="$content"/>
217 </exsl:document>
218 </xsl:otherwise>
219 </xsl:choose>
220 </xsl:otherwise>
221 </xsl:choose>
222 </xsl:when>
223
224 <xsl:when test="element-available('saxon:output')">
225 <xsl:choose>
226 <!-- Handle the permutations ... -->
227 <xsl:when test="$media-type != ''">
228 <xsl:choose>
229 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
230 <saxon:output saxon:character-representation="{$saxon.character.representation}"
231 href="{$filename}"
232 method="{$method}"
233 encoding="{$encoding}"
234 indent="{$indent}"
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"/>
242 </saxon:output>
243 </xsl:when>
244 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
245 <saxon:output saxon:character-representation="{$saxon.character.representation}"
246 href="{$filename}"
247 method="{$method}"
248 encoding="{$encoding}"
249 indent="{$indent}"
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"/>
256 </saxon:output>
257 </xsl:when>
258 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
259 <saxon:output saxon:character-representation="{$saxon.character.representation}"
260 href="{$filename}"
261 method="{$method}"
262 encoding="{$encoding}"
263 indent="{$indent}"
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"/>
270 </saxon:output>
271 </xsl:when>
272 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
273 <saxon:output saxon:character-representation="{$saxon.character.representation}"
274 href="{$filename}"
275 method="{$method}"
276 encoding="{$encoding}"
277 indent="{$indent}"
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"/>
283 </saxon:output>
284 </xsl:otherwise>
285 </xsl:choose>
286 </xsl:when>
287 <xsl:otherwise>
288 <xsl:choose>
289 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
290 <saxon:output saxon:character-representation="{$saxon.character.representation}"
291 href="{$filename}"
292 method="{$method}"
293 encoding="{$encoding}"
294 indent="{$indent}"
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"/>
301 </saxon:output>
302 </xsl:when>
303 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
304 <saxon:output saxon:character-representation="{$saxon.character.representation}"
305 href="{$filename}"
306 method="{$method}"
307 encoding="{$encoding}"
308 indent="{$indent}"
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"/>
314 </saxon:output>
315 </xsl:when>
316 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
317 <saxon:output saxon:character-representation="{$saxon.character.representation}"
318 href="{$filename}"
319 method="{$method}"
320 encoding="{$encoding}"
321 indent="{$indent}"
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"/>
327 </saxon:output>
328 </xsl:when>
329 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
330 <saxon:output saxon:character-representation="{$saxon.character.representation}"
331 href="{$filename}"
332 method="{$method}"
333 encoding="{$encoding}"
334 indent="{$indent}"
335 omit-xml-declaration="{$omit-xml-declaration}"
336 cdata-section-elements="{$cdata-section-elements}"
337 standalone="{$standalone}">
338 <xsl:copy-of select="$content"/>
339 </saxon:output>
340 </xsl:otherwise>
341 </xsl:choose>
342 </xsl:otherwise>
343 </xsl:choose>
344 </xsl:when>
345
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>
351 </xsl:when>
352
353 <xsl:otherwise>
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>
359 </xsl:message>
360 </xsl:otherwise>
361 </xsl:choose>
362</xsl:template>
363
364<xsl:template name="write.chunk.with.doctype">
365 <xsl:param name="filename" select="''"/>
366 <xsl:param name="quiet" select="0"/>
367
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"/>
379
380 <xsl:param name="content"/>
381
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"/>
395 </xsl:call-template>
396</xsl:template>
397
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"/>
405
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"/>
419 </xsl:call-template>
420</xsl:template>
421
422
423</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.