Debian Codegraph @

docbook-xsl-ns/xhtml/html.xsl

raw
1 <?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="d" version="1.0">
2
3 <!-- ********************************************************************
4
5 This file is part of the XSL DocBook Stylesheet distribution.
6 See ../README or http://cdn.docbook.org/release/xsl/current/ for
7 copyright and other information.
8
9 ******************************************************************** -->
10
11 <!-- These variables set the align attribute value for HTML output based on
12 the writing-mode specified in the gentext file for the document's lang. -->
13
14 <xsl:variable name="direction.align.start">
15 <xsl:choose>
16 <xsl:when test="starts-with($writing.mode, 'lr')">left</xsl:when>
17 <xsl:when test="starts-with($writing.mode, 'rl')">right</xsl:when>
18 <xsl:otherwise>left</xsl:otherwise>
19 </xsl:choose>
20 </xsl:variable>
21
22 <xsl:variable name="direction.align.end">
23 <xsl:choose>
24 <xsl:when test="starts-with($writing.mode, 'lr')">right</xsl:when>
25 <xsl:when test="starts-with($writing.mode, 'rl')">left</xsl:when>
26 <xsl:otherwise>right</xsl:otherwise>
27 </xsl:choose>
28 </xsl:variable>
29
30 <xsl:variable name="direction.mode">
31 <xsl:choose>
32 <xsl:when test="starts-with($writing.mode, 'lr')">ltr</xsl:when>
33 <xsl:when test="starts-with($writing.mode, 'rl')">rtl</xsl:when>
34 <xsl:otherwise>ltr</xsl:otherwise>
35 </xsl:choose>
36 </xsl:variable>
37
38 <!-- Support switching to <section> for HTML5 stylesheet -->
39 <!-- This is an internal variable that does not need to be set by a user -->
40 <xsl:variable name="div.element">div</xsl:variable>
41 <!-- Support turning off table border with border="" for HTML5 -->
42 <xsl:variable name="table.border.off">0</xsl:variable>
43
44 <!-- The generate.html.title template is currently used for generating HTML -->
45 <!-- "title" attributes for some inline elements only, but not for any -->
46 <!-- block elements. It is called in eleven places in the inline.xsl -->
47 <!-- file. But it's called by all the inline.* templates (e.g., -->
48 <!-- inline.boldseq), which in turn are called by other (element) -->
49 <!-- templates, so it results, currently, in supporting generation of the -->
50 <!-- HTML "title" attribute for a total of about 92 elements. -->
51 <!-- You can use mode="html.title.attribute" to get a title for -->
52 <!-- an element specified by a param, including targets of cross references. -->
53 <xsl:template name="generate.html.title">
54 <xsl:apply-templates select="." mode="html.title.attribute"/>
55 </xsl:template>
56
57 <xsl:template match="d:acronym|d:abbrev" mode="html.title.attribute">
58 <xsl:if test="d:alt">
59 <xsl:attribute name="title">
60 <xsl:value-of select="normalize-space(d:alt)"/>
61 </xsl:attribute>
62 </xsl:if>
63 </xsl:template>
64
65 <!-- Generate a title attribute for the context node -->
66 <!-- This may be the target of an xref -->
67 <xsl:template match="*" mode="html.title.attribute">
68 <xsl:variable name="is.title">
69 <xsl:call-template name="gentext.template.exists">
70 <xsl:with-param name="context" select="'title'"/>
71 <xsl:with-param name="name" select="local-name(.)"/>
72 <xsl:with-param name="lang">
73 <xsl:call-template name="l10n.language"/>
74 </xsl:with-param>
75 </xsl:call-template>
76 </xsl:variable>
77
78 <xsl:variable name="is.title-numbered">
79 <xsl:call-template name="gentext.template.exists">
80 <xsl:with-param name="context" select="'title-numbered'"/>
81 <xsl:with-param name="name" select="local-name(.)"/>
82 <xsl:with-param name="lang">
83 <xsl:call-template name="l10n.language"/>
84 </xsl:with-param>
85 </xsl:call-template>
86 </xsl:variable>
87
88 <xsl:variable name="is.title-unnumbered">
89 <xsl:call-template name="gentext.template.exists">
90 <xsl:with-param name="context" select="'title-unnumbered'"/>
91 <xsl:with-param name="name" select="local-name(.)"/>
92 <xsl:with-param name="lang">
93 <xsl:call-template name="l10n.language"/>
94 </xsl:with-param>
95 </xsl:call-template>
96 </xsl:variable>
97
98 <xsl:variable name="has.title.markup">
99 <xsl:apply-templates select="." mode="title.markup">
100 <xsl:with-param name="verbose" select="0"/>
101 </xsl:apply-templates>
102 </xsl:variable>
103
104 <xsl:variable name="gentext.title">
105 <xsl:if test="$has.title.markup != '???TITLE???' and ($is.title != 0 or $is.title-numbered != 0 or $is.title-unnumbered != 0)">
106 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
107 </xsl:if>
108 </xsl:variable>
109
110 <xsl:choose>
111 <xsl:when test="string-length($gentext.title) != 0">
112 <xsl:attribute name="title">
113 <xsl:value-of select="$gentext.title"/>
114 </xsl:attribute>
115 </xsl:when>
116 <!-- Fall back to alt if available -->
117 <xsl:when test="d:alt">
118 <xsl:attribute name="title">
119 <xsl:value-of select="normalize-space(d:alt)"/>
120 </xsl:attribute>
121 </xsl:when>
122 </xsl:choose>
123 </xsl:template>
124
125 <xsl:template match="d:qandaentry" mode="html.title.attribute">
126 <xsl:apply-templates select="d:question" mode="html.title.attribute"/>
127 </xsl:template>
128
129 <xsl:template match="d:question" mode="html.title.attribute">
130 <xsl:variable name="label.text">
131 <xsl:apply-templates select="." mode="qanda.label"/>
132 </xsl:variable>
133
134 <xsl:choose>
135 <xsl:when test="string-length($label.text) != 0">
136 <xsl:attribute name="title">
137 <xsl:value-of select="$label.text"/>
138 </xsl:attribute>
139 </xsl:when>
140 <!-- Fall back to alt if available -->
141 <xsl:when test="d:alt">
142 <xsl:attribute name="title">
143 <xsl:value-of select="normalize-space(d:alt)"/>
144 </xsl:attribute>
145 </xsl:when>
146 </xsl:choose>
147 </xsl:template>
148
149 <xsl:template name="dir">
150 <xsl:param name="inherit" select="0"/>
151
152 <xsl:variable name="dir">
153 <xsl:choose>
154 <xsl:when test="@dir">
155 <xsl:value-of select="@dir"/>
156 </xsl:when>
157 <xsl:when test="$inherit != 0">
158 <xsl:value-of select="ancestor::*/@dir[1]"/>
159 </xsl:when>
160 </xsl:choose>
161 </xsl:variable>
162
163 <xsl:if test="$dir != ''">
164 <xsl:attribute name="dir">
165 <xsl:value-of select="$dir"/>
166 </xsl:attribute>
167 </xsl:if>
168 </xsl:template>
169
170 <xsl:template name="anchor">
171 <xsl:param name="node" select="."/>
172 <xsl:param name="conditional" select="1"/>
173
174 <xsl:choose>
175 <xsl:when test="$generate.id.attributes != 0">
176 <!-- No named anchors output when this param is set -->
177 </xsl:when>
178 <xsl:when test="$conditional = 0 or $node/@id or $node/@xml:id">
179 <a>
180 <xsl:attribute name="id">
181 <xsl:call-template name="object.id">
182 <xsl:with-param name="object" select="$node"/>
183 </xsl:call-template>
184 </xsl:attribute>
185 </a>
186 </xsl:when>
187 </xsl:choose>
188 </xsl:template>
189
190 <xsl:template name="id.attribute">
191 <xsl:param name="node" select="."/>
192 <xsl:param name="conditional" select="1"/>
193 <xsl:choose>
194 <xsl:when test="$generate.id.attributes = 0">
195 <!-- No id attributes when this param is zero -->
196 </xsl:when>
197 <xsl:when test="$conditional = 0 or $node/@id or $node/@xml:id">
198 <xsl:attribute name="id">
199 <xsl:call-template name="object.id">
200 <xsl:with-param name="object" select="$node"/>
201 </xsl:call-template>
202 </xsl:attribute>
203 </xsl:when>
204 </xsl:choose>
205 </xsl:template>
206
207 <xsl:template name="href.target.uri">
208 <xsl:param name="context" select="."/>
209 <xsl:param name="object" select="."/>
210 <xsl:text>#</xsl:text>
211 <xsl:call-template name="object.id">
212 <xsl:with-param name="object" select="$object"/>
213 </xsl:call-template>
214 </xsl:template>
215
216 <xsl:template name="href.target">
217 <xsl:param name="context" select="."/>
218 <xsl:param name="object" select="."/>
219 <xsl:text>#</xsl:text>
220 <xsl:call-template name="object.id">
221 <xsl:with-param name="object" select="$object"/>
222 </xsl:call-template>
223 </xsl:template>
224
225 <xsl:template name="href.target.with.base.dir">
226 <xsl:param name="context" select="."/>
227 <xsl:param name="object" select="."/>
228 <xsl:if test="$manifest.in.base.dir = 0">
229 <xsl:value-of select="$chunk.base.dir"/>
230 </xsl:if>
231 <xsl:call-template name="href.target">
232 <xsl:with-param name="context" select="$context"/>
233 <xsl:with-param name="object" select="$object"/>
234 </xsl:call-template>
235 </xsl:template>
236
237 <xsl:template name="dingbat">
238 <xsl:param name="dingbat">bullet</xsl:param>
239 <xsl:call-template name="dingbat.characters">
240 <xsl:with-param name="dingbat" select="$dingbat"/>
241 </xsl:call-template>
242 </xsl:template>
243
244 <xsl:template name="dingbat.characters">
245 <!-- now that I'm using the real serializer, all that dingbat malarky -->
246 <!-- isn't necessary anymore... -->
247 <xsl:param name="dingbat">bullet</xsl:param>
248 <xsl:choose>
249 <xsl:when test="$dingbat='bullet'">&#8226;</xsl:when>
250 <xsl:when test="$dingbat='copyright'">&#169;</xsl:when>
251 <xsl:when test="$dingbat='trademark'">&#8482;</xsl:when>
252 <xsl:when test="$dingbat='trade'">&#8482;</xsl:when>
253 <xsl:when test="$dingbat='registered'">&#174;</xsl:when>
254 <xsl:when test="$dingbat='service'">(SM)</xsl:when>
255 <xsl:when test="$dingbat='nbsp'">&#160;</xsl:when>
256 <xsl:when test="$dingbat='ldquo'">&#8220;</xsl:when>
257 <xsl:when test="$dingbat='rdquo'">&#8221;</xsl:when>
258 <xsl:when test="$dingbat='lsquo'">&#8216;</xsl:when>
259 <xsl:when test="$dingbat='rsquo'">&#8217;</xsl:when>
260 <xsl:when test="$dingbat='em-dash'">&#8212;</xsl:when>
261 <xsl:when test="$dingbat='mdash'">&#8212;</xsl:when>
262 <xsl:when test="$dingbat='en-dash'">&#8211;</xsl:when>
263 <xsl:when test="$dingbat='ndash'">&#8211;</xsl:when>
264 <xsl:otherwise>
265 <xsl:text>&#8226;</xsl:text>
266 </xsl:otherwise>
267 </xsl:choose>
268 </xsl:template>
269
270 <xsl:template name="id.warning">
271 <xsl:if test="$id.warnings != 0 and not(@id) and not(@xml:id) and parent::*">
272 <xsl:variable name="title">
273 <xsl:choose>
274 <xsl:when test="d:title">
275 <xsl:value-of select="d:title[1]"/>
276 </xsl:when>
277 <xsl:when test="substring(local-name(*[1]), string-length(local-name(*[1])-3) = 'info') and *[1]/d:title">
278 <xsl:value-of select="*[1]/d:title[1]"/>
279 </xsl:when>
280 <xsl:when test="d:refmeta/d:refentrytitle">
281 <xsl:value-of select="d:refmeta/d:refentrytitle"/>
282 </xsl:when>
283 <xsl:when test="d:refnamediv/d:refname">
284 <xsl:value-of select="d:refnamediv/d:refname[1]"/>
285 </xsl:when>
286 </xsl:choose>
287 </xsl:variable>
288
289 <xsl:message>
290 <xsl:text>ID recommended on </xsl:text>
291 <xsl:value-of select="local-name(.)"/>
292 <xsl:if test="$title != ''">
293 <xsl:text>: </xsl:text>
294 <xsl:choose>
295 <xsl:when test="string-length($title) &gt; 40">
296 <xsl:value-of select="substring($title,1,40)"/>
297 <xsl:text>...</xsl:text>
298 </xsl:when>
299 <xsl:otherwise>
300 <xsl:value-of select="$title"/>
301 </xsl:otherwise>
302 </xsl:choose>
303 </xsl:if>
304 </xsl:message>
305 </xsl:if>
306 </xsl:template>
307
308 <xsl:template name="generate.class.attribute">
309 <xsl:param name="class" select="local-name(.)"/>
310 <xsl:apply-templates select="." mode="class.attribute">
311 <xsl:with-param name="class" select="$class"/>
312 </xsl:apply-templates>
313 </xsl:template>
314
315 <xsl:template match="*" mode="class.attribute">
316 <xsl:param name="class" select="local-name(.)"/>
317 <!-- permit customization of class attributes -->
318 <!-- Use element name by default -->
319 <xsl:variable name="class.value">
320 <xsl:apply-templates select="." mode="class.value">
321 <xsl:with-param name="class" select="$class"/>
322 </xsl:apply-templates>
323 </xsl:variable>
324
325 <xsl:if test="string-length(normalize-space($class.value)) != 0">
326 <xsl:attribute name="class">
327 <xsl:value-of select="$class.value"/>
328 </xsl:attribute>
329 </xsl:if>
330 </xsl:template>
331
332 <xsl:template match="*" mode="class.value">
333 <xsl:param name="class" select="local-name(.)"/>
334 <!-- permit customization of class value only -->
335 <!-- Use element name by default -->
336 <xsl:value-of select="$class"/>
337 </xsl:template>
338
339 <!-- Apply common attributes such as class, lang, dir -->
340 <xsl:template name="common.html.attributes">
341 <xsl:param name="inherit" select="0"/>
342 <xsl:param name="class" select="local-name(.)"/>
343 <xsl:apply-templates select="." mode="common.html.attributes">
344 <xsl:with-param name="class" select="$class"/>
345 <xsl:with-param name="inherit" select="$inherit"/>
346 </xsl:apply-templates>
347 </xsl:template>
348
349 <xsl:template match="*" mode="common.html.attributes">
350 <xsl:param name="class" select="local-name(.)"/>
351 <xsl:param name="inherit" select="0"/>
352 <xsl:call-template name="generate.html.lang"/>
353 <xsl:call-template name="dir">
354 <xsl:with-param name="inherit" select="$inherit"/>
355 </xsl:call-template>
356 <xsl:apply-templates select="." mode="class.attribute">
357 <xsl:with-param name="class" select="$class"/>
358 </xsl:apply-templates>
359 <xsl:call-template name="its.attributes">
360 <xsl:with-param name="inherit" select="$inherit"/>
361 </xsl:call-template>
362 </xsl:template>
363
364 <!-- Apply common attributes not including class -->
365 <xsl:template name="locale.html.attributes">
366 <xsl:apply-templates select="." mode="locale.html.attributes"/>
367 </xsl:template>
368
369 <xsl:template match="*" mode="locale.html.attributes">
370 <xsl:call-template name="generate.html.lang"/>
371 <xsl:call-template name="dir"/>
372 <xsl:call-template name="its.attributes"/>
373 </xsl:template>
374
375 <!-- Pass through any lang attributes -->
376 <xsl:template name="generate.html.lang">
377 <xsl:apply-templates select="." mode="html.lang.attribute"/>
378 </xsl:template>
379
380 <xsl:template match="*" mode="html.lang.attribute">
381 <!-- match the attribute name to the output type -->
382 <xsl:choose>
383 <xsl:when test="@lang and $stylesheet.result.type = 'html'">
384 <xsl:attribute name="lang">
385 <xsl:value-of select="@lang"/>
386 </xsl:attribute>
387 </xsl:when>
388 <xsl:when test="@lang and $stylesheet.result.type = 'xhtml'">
389 <xsl:attribute name="xml:lang">
390 <xsl:value-of select="@lang"/>
391 </xsl:attribute>
392 </xsl:when>
393 <xsl:when test="@xml:lang and $stylesheet.result.type = 'html'">
394 <xsl:attribute name="lang">
395 <xsl:value-of select="@xml:lang"/>
396 </xsl:attribute>
397 </xsl:when>
398 <xsl:when test="@xml:lang and $stylesheet.result.type = 'xhtml'">
399 <xsl:attribute name="xml:lang">
400 <xsl:value-of select="@xml:lang"/>
401 </xsl:attribute>
402 </xsl:when>
403 </xsl:choose>
404 </xsl:template>
405
406 <!-- ==================================================================== -->
407 <!-- Insert link to css or insert literal CSS in head element -->
408 <xsl:template name="generate.css">
409 <xsl:choose>
410 <xsl:when test="$generate.css.header = 0">
411 <xsl:call-template name="generate.css.links"/>
412 </xsl:when>
413 <xsl:otherwise>
414 <xsl:call-template name="generate.css.headers"/>
415 </xsl:otherwise>
416 </xsl:choose>
417 </xsl:template>
418
419 <xsl:template name="generate.css.headers">
420 <xsl:call-template name="generate.default.css.header"/>
421 <xsl:call-template name="generate.custom.css.header"/>
422 </xsl:template>
423
424 <xsl:template name="generate.default.css.header">
425 <xsl:if test="$make.clean.html != 0 and $docbook.css.source != ''">
426 <!-- Select default file relative to stylesheet -->
427 <xsl:variable name="css.node" select="document($docbook.css.source)/*[1]"/>
428
429 <xsl:call-template name="output.css.header">
430 <xsl:with-param name="css.node" select="$css.node"/>
431 </xsl:call-template>
432 </xsl:if>
433 </xsl:template>
434
435 <xsl:template name="generate.custom.css.header">
436 <xsl:if test="$custom.css.source != ''">
437 <!-- Select custom file relative to document -->
438 <xsl:variable name="css.node" select="document($custom.css.source,.)/*[1]"/>
439
440 <xsl:call-template name="output.css.header">
441 <xsl:with-param name="css.node" select="$css.node"/>
442 </xsl:call-template>
443 </xsl:if>
444 </xsl:template>
445
446 <xsl:template name="output.css.header">
447 <xsl:param name="css.node"/>
448
449 <xsl:choose>
450 <xsl:when test="count($css.node) = 0">
451 </xsl:when>
452 <xsl:otherwise>
453 <style type="text/css">
454 <xsl:copy-of select="$css.node/text()"/>
455 </style>
456 </xsl:otherwise>
457 </xsl:choose>
458 </xsl:template>
459
460 <!-- ==================================================================== -->
461 <xsl:template name="generate.css.links">
462 <xsl:call-template name="generate.default.css.link"/>
463 <xsl:call-template name="generate.custom.css.link"/>
464 </xsl:template>
465
466 <xsl:template name="generate.default.css.link">
467 <xsl:if test="$make.clean.html != 0 and $docbook.css.link != 0 and $docbook.css.source != ''">
468 <xsl:variable name="filename">
469 <xsl:call-template name="css.output.filename">
470 <xsl:with-param name="src" select="$docbook.css.source"/>
471 </xsl:call-template>
472 </xsl:variable>
473
474 <xsl:call-template name="make.css.link">
475 <xsl:with-param name="css.filename" select="$filename"/>
476 </xsl:call-template>
477 </xsl:if>
478 </xsl:template>
479
480 <xsl:template name="generate.custom.css.link">
481 <xsl:if test="$custom.css.source != ''">
482 <xsl:variable name="filename">
483 <xsl:call-template name="css.output.filename">
484 <xsl:with-param name="src" select="$custom.css.source"/>
485 </xsl:call-template>
486 </xsl:variable>
487
488 <xsl:call-template name="make.css.link">
489 <xsl:with-param name="css.filename" select="$filename"/>
490 </xsl:call-template>
491 </xsl:if>
492 </xsl:template>
493
494 <!-- a CSS link reference must take into account the relative
495 path to a CSS file when chunked HTML is output to more than one directory -->
496 <xsl:template name="make.css.link">
497 <xsl:param name="css.filename" select="''"/>
498
499 <xsl:variable name="href">
500 <xsl:call-template name="relative.path.link">
501 <xsl:with-param name="target.pathname" select="$css.filename"/>
502 </xsl:call-template>
503 </xsl:variable>
504
505 <xsl:if test="string-length($css.filename) != 0">
506 <link rel="stylesheet" type="text/css" href="{$href}"/>
507 </xsl:if>
508 </xsl:template>
509
510 <!-- And the same applies to script links -->
511 <xsl:template name="make.script.link">
512 <xsl:param name="script.filename" select="''"/>
513
514 <xsl:variable name="src">
515 <xsl:call-template name="relative.path.link">
516 <xsl:with-param name="target.pathname" select="$script.filename"/>
517 </xsl:call-template>
518 </xsl:variable>
519
520 <xsl:if test="string-length($script.filename) != 0">
521 <script>
522 <xsl:attribute name="src">
523 <xsl:value-of select="$src"/>
524 </xsl:attribute>
525 <xsl:attribute name="type">
526 <xsl:value-of select="$html.script.type"/>
527 </xsl:attribute>
528 <xsl:call-template name="other.script.attributes">
529 <xsl:with-param name="script.filename" select="$script.filename"/>
530 </xsl:call-template>
531 </script>
532 </xsl:if>
533 </xsl:template>
534
535 <xsl:template name="other.script.attributes">
536 <xsl:param name="script.filename"/>
537 <!-- Placeholder template to allow customization to
538 insert additional script element attributes if needed -->
539 </xsl:template>
540
541 <xsl:template name="relative.path.link">
542 <xsl:param name="target.pathname"/>
543
544 <xsl:variable name="href.to.uri" select="$target.pathname"/>
545
546 <xsl:variable name="href.from.uri">
547 <xsl:call-template name="href.target.uri">
548 <xsl:with-param name="object" select="."/>
549 </xsl:call-template>
550 </xsl:variable>
551
552 <xsl:variable name="href.to">
553 <xsl:call-template name="trim.common.uri.paths">
554 <xsl:with-param name="uriA" select="$href.to.uri"/>
555 <xsl:with-param name="uriB" select="$href.from.uri"/>
556 <xsl:with-param name="return" select="'A'"/>
557 </xsl:call-template>
558 </xsl:variable>
559
560 <xsl:variable name="href.from">
561 <xsl:call-template name="trim.common.uri.paths">
562 <xsl:with-param name="uriA" select="$href.to.uri"/>
563 <xsl:with-param name="uriB" select="$href.from.uri"/>
564 <xsl:with-param name="return" select="'B'"/>
565 </xsl:call-template>
566 </xsl:variable>
567 <xsl:variable name="depth">
568 <xsl:call-template name="count.uri.path.depth">
569 <xsl:with-param name="filename" select="$href.from"/>
570 </xsl:call-template>
571 </xsl:variable>
572 <xsl:variable name="href">
573 <xsl:call-template name="copy-string">
574 <xsl:with-param name="string" select="'../'"/>
575 <xsl:with-param name="count" select="$depth"/>
576 </xsl:call-template>
577 <xsl:value-of select="$href.to"/>
578 </xsl:variable>
579
580 <xsl:value-of select="$href"/>
581 </xsl:template>
582
583 <!-- ==================================================================== -->
584
585 <xsl:template name="generate.css.files">
586 <xsl:call-template name="generate.default.css.file"/>
587 <xsl:call-template name="generate.custom.css.file"/>
588 </xsl:template>
589
590 <xsl:template name="generate.default.css.file">
591 <xsl:if test="$make.clean.html != 0 and $generate.css.header = 0 and $docbook.css.source != ''">
592 <!-- Select default file relative to stylesheet -->
593 <xsl:variable name="css.node" select="document($docbook.css.source)/*[1]"/>
594
595 <xsl:call-template name="generate.css.file">
596 <xsl:with-param name="src" select="$docbook.css.source"/>
597 <xsl:with-param name="css.node" select="$css.node"/>
598 </xsl:call-template>
599 </xsl:if>
600 </xsl:template>
601
602 <xsl:template name="generate.custom.css.file">
603 <xsl:if test="$custom.css.source != '' and $generate.css.header = 0">
604 <!-- Select custom file relative to document -->
605 <xsl:variable name="css.node" select="document($custom.css.source,.)/*[1]"/>
606
607 <xsl:call-template name="generate.css.file">
608 <xsl:with-param name="src" select="$custom.css.source"/>
609 <xsl:with-param name="css.node" select="$css.node"/>
610 </xsl:call-template>
611 </xsl:if>
612 </xsl:template>
613
614 <xsl:template name="generate.css.file">
615 <xsl:param name="css.node"/>
616 <xsl:param name="src" select="''"/>
617
618 <xsl:variable name="css.text" select="$css.node/text()"/>
619
620 <xsl:choose>
621 <xsl:when test="count($css.node) = 0">
622 <xsl:message>
623 <xsl:text>ERROR: no root element for CSS source file'</xsl:text>
624 <xsl:value-of select="$src"/>
625 <xsl:text>'.</xsl:text>
626 </xsl:message>
627 </xsl:when>
628 <xsl:otherwise>
629 <xsl:variable name="filename">
630 <xsl:call-template name="css.output.pathname">
631 <xsl:with-param name="src" select="$src"/>
632 <xsl:with-param name="content" select="$css.node"/>
633 </xsl:call-template>
634 </xsl:variable>
635
636 <xsl:call-template name="write.text.chunk">
637 <xsl:with-param name="filename" select="$filename"/>
638 <xsl:with-param name="content" select="$css.text"/>
639 </xsl:call-template>
640
641 </xsl:otherwise>
642 </xsl:choose>
643 </xsl:template>
644
645 <xsl:template name="css.output.filename">
646 <xsl:param name="content"/>
647 <xsl:param name="src" select="''"/>
648
649 <xsl:variable name="candidate">
650 <xsl:choose>
651 <xsl:when test="string-length($src) = 0">
652 <xsl:message>
653 <xsl:text>ERROR: missing CSS input filename.</xsl:text>
654 </xsl:message>
655 </xsl:when>
656 <xsl:when test="substring($src,string-length($src)-3) = '.xml'">
657 <xsl:value-of select="substring($src, 1, string-length($src) - 4)"/>
658 </xsl:when>
659 <xsl:otherwise>
660 <xsl:value-of select="$src"/>
661 </xsl:otherwise>
662 </xsl:choose>
663 </xsl:variable>
664 <xsl:value-of select="$candidate"/>
665 </xsl:template>
666
667 <xsl:template name="css.output.pathname">
668 <xsl:param name="content"/>
669 <xsl:param name="src" select="''"/>
670
671 <xsl:variable name="file">
672 <xsl:call-template name="css.output.filename">
673 <xsl:with-param name="content" select="$content"/>
674 <xsl:with-param name="src" select="$src"/>
675 </xsl:call-template>
676 </xsl:variable>
677
678 <xsl:variable name="path" select="concat($chunk.base.dir, $file)"/>
679 <xsl:value-of select="$path"/>
680
681 </xsl:template>
682
683 </xsl:stylesheet>