source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/html/chunker.xsl@ 51fa34f

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 51fa34f was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 20.5 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:redirect="http://xml.apache.org/xalan/redirect"
5 xmlns:exsl="http://exslt.org/common"
6 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
7 version="1.0"
8 exclude-result-prefixes="doc"
9 extension-element-prefixes="saxon redirect lxslt exsl">
10
11<!-- ********************************************************************
12 $Id$
13 ********************************************************************
14
15 This file is part of the XSL DocBook Stylesheet distribution.
16 See ../README or http://docbook.sf.net/release/xsl/current/ for
17 copyright and other information.
18
19 ******************************************************************** -->
20
21<!-- ==================================================================== -->
22
23<!-- This stylesheet works with XSLT implementations that support -->
24<!-- exsl:document, saxon:output, or Xalan's redirect: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<xsl:param name="chunker.output.quiet" select="0"/>
37
38<xsl:param name="saxon.character.representation" select="'entity;decimal'"/>
39
40<!-- ==================================================================== -->
41
42<xsl:template name="make-relative-filename">
43 <xsl:param name="base.dir" select="'./'"/>
44 <xsl:param name="base.name" select="''"/>
45
46 <xsl:choose>
47 <!-- put Saxon first to work around a bug in libxslt -->
48 <xsl:when test="element-available('saxon:output')">
49 <!-- Saxon doesn't make the chunks relative -->
50 <xsl:value-of select="concat($base.dir,$base.name)"/>
51 </xsl:when>
52 <xsl:when test="element-available('exsl:document')">
53 <!-- EXSL document does make the chunks relative, I think -->
54 <xsl:choose>
55 <xsl:when test="count(parent::*) = 0">
56 <xsl:value-of select="concat($base.dir,$base.name)"/>
57 </xsl:when>
58 <xsl:otherwise>
59 <xsl:value-of select="$base.name"/>
60 </xsl:otherwise>
61 </xsl:choose>
62 </xsl:when>
63 <xsl:when test="element-available('redirect:write')">
64 <!-- Xalan doesn't make the chunks relative -->
65 <xsl:value-of select="concat($base.dir,$base.name)"/>
66 </xsl:when>
67 <xsl:otherwise>
68 <xsl:message terminate="yes">
69 <xsl:text>Don't know how to chunk with </xsl:text>
70 <xsl:value-of select="system-property('xsl:vendor')"/>
71 </xsl:message>
72 </xsl:otherwise>
73 </xsl:choose>
74</xsl:template>
75
76<xsl:template name="write.chunk">
77 <xsl:param name="filename" select="''"/>
78 <xsl:param name="quiet" select="$chunker.output.quiet"/>
79 <xsl:param name="suppress-context-node-name" select="0"/>
80 <xsl:param name="message-prolog"/>
81 <xsl:param name="message-epilog"/>
82
83 <xsl:param name="method" select="$chunker.output.method"/>
84 <xsl:param name="encoding" select="$chunker.output.encoding"/>
85 <xsl:param name="indent" select="$chunker.output.indent"/>
86 <xsl:param name="omit-xml-declaration"
87 select="$chunker.output.omit-xml-declaration"/>
88 <xsl:param name="standalone" select="$chunker.output.standalone"/>
89 <xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
90 <xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
91 <xsl:param name="media-type" select="$chunker.output.media-type"/>
92 <xsl:param name="cdata-section-elements"
93 select="$chunker.output.cdata-section-elements"/>
94
95 <xsl:param name="content"/>
96
97 <xsl:if test="$quiet = 0">
98 <xsl:message>
99 <xsl:if test="not($message-prolog = '')">
100 <xsl:value-of select="$message-prolog"/>
101 </xsl:if>
102 <xsl:text>Writing </xsl:text>
103 <xsl:value-of select="$filename"/>
104 <xsl:if test="name(.) != '' and $suppress-context-node-name = 0">
105 <xsl:text> for </xsl:text>
106 <xsl:value-of select="name(.)"/>
107 <xsl:if test="@id or @xml:id">
108 <xsl:text>(</xsl:text>
109 <xsl:value-of select="(@id|@xml:id)[1]"/>
110 <xsl:text>)</xsl:text>
111 </xsl:if>
112 </xsl:if>
113 <xsl:if test="not($message-epilog = '')">
114 <xsl:value-of select="$message-epilog"/>
115 </xsl:if>
116 </xsl:message>
117 </xsl:if>
118
119 <xsl:choose>
120 <xsl:when test="element-available('exsl:document')">
121 <xsl:choose>
122 <!-- Handle the permutations ... -->
123 <xsl:when test="$media-type != ''">
124 <xsl:choose>
125 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
126 <exsl:document href="{$filename}"
127 method="{$method}"
128 encoding="{$encoding}"
129 indent="{$indent}"
130 omit-xml-declaration="{$omit-xml-declaration}"
131 cdata-section-elements="{$cdata-section-elements}"
132 media-type="{$media-type}"
133 doctype-public="{$doctype-public}"
134 doctype-system="{$doctype-system}"
135 standalone="{$standalone}">
136 <xsl:copy-of select="$content"/>
137 </exsl:document>
138 </xsl:when>
139 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
140 <exsl:document href="{$filename}"
141 method="{$method}"
142 encoding="{$encoding}"
143 indent="{$indent}"
144 omit-xml-declaration="{$omit-xml-declaration}"
145 cdata-section-elements="{$cdata-section-elements}"
146 media-type="{$media-type}"
147 doctype-public="{$doctype-public}"
148 standalone="{$standalone}">
149 <xsl:copy-of select="$content"/>
150 </exsl:document>
151 </xsl:when>
152 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
153 <exsl:document href="{$filename}"
154 method="{$method}"
155 encoding="{$encoding}"
156 indent="{$indent}"
157 omit-xml-declaration="{$omit-xml-declaration}"
158 cdata-section-elements="{$cdata-section-elements}"
159 media-type="{$media-type}"
160 doctype-system="{$doctype-system}"
161 standalone="{$standalone}">
162 <xsl:copy-of select="$content"/>
163 </exsl:document>
164 </xsl:when>
165 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
166 <exsl:document href="{$filename}"
167 method="{$method}"
168 encoding="{$encoding}"
169 indent="{$indent}"
170 omit-xml-declaration="{$omit-xml-declaration}"
171 cdata-section-elements="{$cdata-section-elements}"
172 media-type="{$media-type}"
173 standalone="{$standalone}">
174 <xsl:copy-of select="$content"/>
175 </exsl:document>
176 </xsl:otherwise>
177 </xsl:choose>
178 </xsl:when>
179 <xsl:otherwise>
180 <xsl:choose>
181 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
182 <exsl:document href="{$filename}"
183 method="{$method}"
184 encoding="{$encoding}"
185 indent="{$indent}"
186 omit-xml-declaration="{$omit-xml-declaration}"
187 cdata-section-elements="{$cdata-section-elements}"
188 doctype-public="{$doctype-public}"
189 doctype-system="{$doctype-system}"
190 standalone="{$standalone}">
191 <xsl:copy-of select="$content"/>
192 </exsl:document>
193 </xsl:when>
194 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
195 <exsl:document href="{$filename}"
196 method="{$method}"
197 encoding="{$encoding}"
198 indent="{$indent}"
199 omit-xml-declaration="{$omit-xml-declaration}"
200 cdata-section-elements="{$cdata-section-elements}"
201 doctype-public="{$doctype-public}"
202 standalone="{$standalone}">
203 <xsl:copy-of select="$content"/>
204 </exsl:document>
205 </xsl:when>
206 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
207 <exsl:document href="{$filename}"
208 method="{$method}"
209 encoding="{$encoding}"
210 indent="{$indent}"
211 omit-xml-declaration="{$omit-xml-declaration}"
212 cdata-section-elements="{$cdata-section-elements}"
213 doctype-system="{$doctype-system}"
214 standalone="{$standalone}">
215 <xsl:copy-of select="$content"/>
216 </exsl:document>
217 </xsl:when>
218 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
219 <exsl:document href="{$filename}"
220 method="{$method}"
221 encoding="{$encoding}"
222 indent="{$indent}"
223 omit-xml-declaration="{$omit-xml-declaration}"
224 cdata-section-elements="{$cdata-section-elements}"
225 standalone="{$standalone}">
226 <xsl:copy-of select="$content"/>
227 </exsl:document>
228 </xsl:otherwise>
229 </xsl:choose>
230 </xsl:otherwise>
231 </xsl:choose>
232 </xsl:when>
233
234 <xsl:when test="element-available('saxon:output')">
235 <xsl:choose>
236 <!-- Handle the permutations ... -->
237 <xsl:when test="$media-type != ''">
238 <xsl:choose>
239 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
240 <saxon:output saxon:character-representation="{$saxon.character.representation}"
241 href="{$filename}"
242 method="{$method}"
243 encoding="{$encoding}"
244 indent="{$indent}"
245 omit-xml-declaration="{$omit-xml-declaration}"
246 cdata-section-elements="{$cdata-section-elements}"
247 media-type="{$media-type}"
248 doctype-public="{$doctype-public}"
249 doctype-system="{$doctype-system}"
250 standalone="{$standalone}">
251 <xsl:copy-of select="$content"/>
252 </saxon:output>
253 </xsl:when>
254 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
255 <saxon:output saxon:character-representation="{$saxon.character.representation}"
256 href="{$filename}"
257 method="{$method}"
258 encoding="{$encoding}"
259 indent="{$indent}"
260 omit-xml-declaration="{$omit-xml-declaration}"
261 cdata-section-elements="{$cdata-section-elements}"
262 media-type="{$media-type}"
263 doctype-public="{$doctype-public}"
264 standalone="{$standalone}">
265 <xsl:copy-of select="$content"/>
266 </saxon:output>
267 </xsl:when>
268 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
269 <saxon:output saxon:character-representation="{$saxon.character.representation}"
270 href="{$filename}"
271 method="{$method}"
272 encoding="{$encoding}"
273 indent="{$indent}"
274 omit-xml-declaration="{$omit-xml-declaration}"
275 cdata-section-elements="{$cdata-section-elements}"
276 media-type="{$media-type}"
277 doctype-system="{$doctype-system}"
278 standalone="{$standalone}">
279 <xsl:copy-of select="$content"/>
280 </saxon:output>
281 </xsl:when>
282 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
283 <saxon:output saxon:character-representation="{$saxon.character.representation}"
284 href="{$filename}"
285 method="{$method}"
286 encoding="{$encoding}"
287 indent="{$indent}"
288 omit-xml-declaration="{$omit-xml-declaration}"
289 cdata-section-elements="{$cdata-section-elements}"
290 media-type="{$media-type}"
291 standalone="{$standalone}">
292 <xsl:copy-of select="$content"/>
293 </saxon:output>
294 </xsl:otherwise>
295 </xsl:choose>
296 </xsl:when>
297 <xsl:otherwise>
298 <xsl:choose>
299 <xsl:when test="$doctype-public != '' and $doctype-system != ''">
300 <saxon:output saxon:character-representation="{$saxon.character.representation}"
301 href="{$filename}"
302 method="{$method}"
303 encoding="{$encoding}"
304 indent="{$indent}"
305 omit-xml-declaration="{$omit-xml-declaration}"
306 cdata-section-elements="{$cdata-section-elements}"
307 doctype-public="{$doctype-public}"
308 doctype-system="{$doctype-system}"
309 standalone="{$standalone}">
310 <xsl:copy-of select="$content"/>
311 </saxon:output>
312 </xsl:when>
313 <xsl:when test="$doctype-public != '' and $doctype-system = ''">
314 <saxon:output saxon:character-representation="{$saxon.character.representation}"
315 href="{$filename}"
316 method="{$method}"
317 encoding="{$encoding}"
318 indent="{$indent}"
319 omit-xml-declaration="{$omit-xml-declaration}"
320 cdata-section-elements="{$cdata-section-elements}"
321 doctype-public="{$doctype-public}"
322 standalone="{$standalone}">
323 <xsl:copy-of select="$content"/>
324 </saxon:output>
325 </xsl:when>
326 <xsl:when test="$doctype-public = '' and $doctype-system != ''">
327 <saxon:output saxon:character-representation="{$saxon.character.representation}"
328 href="{$filename}"
329 method="{$method}"
330 encoding="{$encoding}"
331 indent="{$indent}"
332 omit-xml-declaration="{$omit-xml-declaration}"
333 cdata-section-elements="{$cdata-section-elements}"
334 doctype-system="{$doctype-system}"
335 standalone="{$standalone}">
336 <xsl:copy-of select="$content"/>
337 </saxon:output>
338 </xsl:when>
339 <xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> -->
340 <saxon:output saxon:character-representation="{$saxon.character.representation}"
341 href="{$filename}"
342 method="{$method}"
343 encoding="{$encoding}"
344 indent="{$indent}"
345 omit-xml-declaration="{$omit-xml-declaration}"
346 cdata-section-elements="{$cdata-section-elements}"
347 standalone="{$standalone}">
348 <xsl:copy-of select="$content"/>
349 </saxon:output>
350 </xsl:otherwise>
351 </xsl:choose>
352 </xsl:otherwise>
353 </xsl:choose>
354 </xsl:when>
355
356 <xsl:when test="element-available('redirect:write')">
357 <!-- Xalan uses redirect -->
358 <redirect:write file="{$filename}">
359 <xsl:copy-of select="$content"/>
360 </redirect:write>
361 </xsl:when>
362
363 <xsl:otherwise>
364 <!-- it doesn't matter since we won't be making chunks... -->
365 <xsl:message terminate="yes">
366 <xsl:text>Can't make chunks with </xsl:text>
367 <xsl:value-of select="system-property('xsl:vendor')"/>
368 <xsl:text>'s processor.</xsl:text>
369 </xsl:message>
370 </xsl:otherwise>
371 </xsl:choose>
372</xsl:template>
373
374<xsl:template name="write.chunk.with.doctype">
375 <xsl:param name="filename" select="''"/>
376 <xsl:param name="quiet" select="$chunker.output.quiet"/>
377
378 <xsl:param name="method" select="$chunker.output.method"/>
379 <xsl:param name="encoding" select="$chunker.output.encoding"/>
380 <xsl:param name="indent" select="$chunker.output.indent"/>
381 <xsl:param name="omit-xml-declaration"
382 select="$chunker.output.omit-xml-declaration"/>
383 <xsl:param name="standalone" select="$chunker.output.standalone"/>
384 <xsl:param name="doctype-public" select="$chunker.output.doctype-public"/>
385 <xsl:param name="doctype-system" select="$chunker.output.doctype-system"/>
386 <xsl:param name="media-type" select="$chunker.output.media-type"/>
387 <xsl:param name="cdata-section-elements"
388 select="$chunker.output.cdata-section-elements"/>
389
390 <xsl:param name="content"/>
391
392 <xsl:call-template name="write.chunk">
393 <xsl:with-param name="filename" select="$filename"/>
394 <xsl:with-param name="quiet" select="$quiet"/>
395 <xsl:with-param name="method" select="$method"/>
396 <xsl:with-param name="encoding" select="$encoding"/>
397 <xsl:with-param name="indent" select="$indent"/>
398 <xsl:with-param name="omit-xml-declaration" select="$omit-xml-declaration"/>
399 <xsl:with-param name="standalone" select="$standalone"/>
400 <xsl:with-param name="doctype-public" select="$doctype-public"/>
401 <xsl:with-param name="doctype-system" select="$doctype-system"/>
402 <xsl:with-param name="media-type" select="$media-type"/>
403 <xsl:with-param name="cdata-section-elements" select="$cdata-section-elements"/>
404 <xsl:with-param name="content" select="$content"/>
405 </xsl:call-template>
406</xsl:template>
407
408<xsl:template name="write.text.chunk">
409 <xsl:param name="filename" select="''"/>
410 <xsl:param name="quiet" select="$chunker.output.quiet"/>
411 <xsl:param name="suppress-context-node-name" select="0"/>
412 <xsl:param name="message-prolog"/>
413 <xsl:param name="message-epilog"/>
414 <xsl:param name="method" select="'text'"/>
415 <xsl:param name="encoding" select="$chunker.output.encoding"/>
416 <xsl:param name="media-type" select="$chunker.output.media-type"/>
417 <xsl:param name="content"/>
418
419 <xsl:call-template name="write.chunk">
420 <xsl:with-param name="filename" select="$filename"/>
421 <xsl:with-param name="quiet" select="$quiet"/>
422 <xsl:with-param name="suppress-context-node-name" select="$suppress-context-node-name"/>
423 <xsl:with-param name="message-prolog" select="$message-prolog"/>
424 <xsl:with-param name="message-epilog" select="$message-epilog"/>
425 <xsl:with-param name="method" select="$method"/>
426 <xsl:with-param name="encoding" select="$encoding"/>
427 <xsl:with-param name="indent" select="'no'"/>
428 <xsl:with-param name="omit-xml-declaration" select="'no'"/>
429 <xsl:with-param name="standalone" select="'no'"/>
430 <xsl:with-param name="doctype-public"/>
431 <xsl:with-param name="doctype-system"/>
432 <xsl:with-param name="media-type" select="$media-type"/>
433 <xsl:with-param name="cdata-section-elements"/>
434 <xsl:with-param name="content" select="$content"/>
435 </xsl:call-template>
436</xsl:template>
437
438
439</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.