~zulcss/samba/server-dailies-3.0.37

« back to all changes in this revision

Viewing changes to docs-xml/xslt/db2latex-xsl/xsl/normalize-scape.mod.xsl

  • Committer: Chuck Short
  • Date: 2010-09-28 20:24:01 UTC
  • Revision ID: zulcss@ubuntu.com-20100928202401-tgh438aoatxv3zp3
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version='1.0'?>
 
2
<!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
 
3
<!--############################################################################# 
 
4
|       $Id: normalize-scape.mod.xsl,v 1.33 2004/01/26 09:40:12 j-devenish Exp $
 
5
|- #############################################################################
 
6
|       $Author: j-devenish $
 
7
|                                                                                                               
 
8
|   PURPOSE:
 
9
|       Escape LaTeX and normalize-space templates.
 
10
|    < > # $ % & ~ _ ^ \ { } |
 
11
+ ############################################################################## -->
 
12
 
 
13
<xsl:stylesheet 
 
14
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
15
        xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
 
16
        exclude-result-prefixes="doc" version='1.0'>
 
17
 
 
18
        <doc:reference id="normalize-scape" xmlns="">
 
19
                <referenceinfo>
 
20
                        <releaseinfo role="meta">
 
21
                                $Id: normalize-scape.mod.xsl,v 1.33 2004/01/26 09:40:12 j-devenish Exp $
 
22
                        </releaseinfo>
 
23
                        <authorgroup>
 
24
                                &ramon;
 
25
                                &james;
 
26
                        </authorgroup>
 
27
                        <copyright>
 
28
                                <year>2000</year><year>2001</year><year>2002</year><year>2003</year>
 
29
                                <holder>Ramon Casellas</holder>
 
30
                        </copyright>
 
31
                        <revhistory>
 
32
                                <doc:revision rcasver="1.30">&rev_2003_05;</doc:revision>
 
33
                        </revhistory>
 
34
                </referenceinfo>
 
35
                <title>Whitespace Normalization and Character Encoding <filename>normalize-scape.mod.xsl</filename></title>
 
36
                <partintro>
 
37
 
 
38
                        <para>Normalize whitespace and and escape <quote>active</quote> &latex; characters.</para>
 
39
                        <para>Includes the auto-generated <filename>scape.mod.xsl</filename> module.</para>
 
40
 
 
41
                </partintro>
 
42
        </doc:reference>
 
43
 
 
44
        <xsl:include href="scape.mod.xsl"/>
 
45
 
 
46
        <doc:template match="text()" xmlns="">
 
47
                <refpurpose>Process <literal>text()</literal> nodes</refpurpose>
 
48
                <doc:description>
 
49
                        <para>
 
50
 
 
51
                                Handles regular text content (i.e. <literal>#PCDATA</literal>)
 
52
                                from &docbook; documents.
 
53
 
 
54
                        </para>
 
55
                </doc:description>
 
56
                <doc:variables>
 
57
                        &no_var;
 
58
                </doc:variables>
 
59
                <doc:notes>
 
60
                        <para>
 
61
 
 
62
                                For most elements, &latex; active characters
 
63
                                will be escaped using the <xref linkend="template.scape"/>
 
64
                                template.
 
65
                                However, for text within the following elements, the
 
66
                                <xref linkend="template.scape-verbatim"/> template
 
67
                                will be used to typeset monospace text:
 
68
                                <doc:db>literal</doc:db>,
 
69
                                <doc:db>filename</doc:db>,
 
70
                                <doc:db>userinput</doc:db>,
 
71
                                <doc:db>systemitem</doc:db>,
 
72
                                <doc:db>prompt</doc:db>,
 
73
                                <doc:db>email</doc:db>,
 
74
                                <doc:db>sgmltag</doc:db>.
 
75
 
 
76
                        </para>
 
77
                        <para>
 
78
 
 
79
                                In all cases, interior whitespace will be normalised according
 
80
                                to the XSLT specification with the additional feature that
 
81
                                leading and trailing whitespace will be elided (as expected
 
82
                                with SGML parsers).
 
83
 
 
84
                        </para>
 
85
                </doc:notes>
 
86
                <doc:seealso>
 
87
                        <itemizedlist>
 
88
                                <listitem><simpara><xref linkend="gentext"/></simpara></listitem>
 
89
                                <listitem><simpara><xref linkend="param.latex.inputenc"/></simpara></listitem>
 
90
                        </itemizedlist>
 
91
                </doc:seealso>
 
92
        </doc:template>
 
93
        <xsl:template match="text()" name="text">
 
94
                <xsl:call-template name="trim-outer">
 
95
                        <xsl:with-param name="string">
 
96
                                <xsl:choose>
 
97
                                        <xsl:when test="ancestor::literal|ancestor::filename|ancestor::userinput|ancestor::systemitem|ancestor::prompt|ancestor::email|ancestor::sgmltag">
 
98
                                                <xsl:call-template name="scape-verbatim">
 
99
                                                        <xsl:with-param name="string" select="."/>
 
100
                                                </xsl:call-template>
 
101
                                        </xsl:when>
 
102
                                        <xsl:otherwise>
 
103
                                                <xsl:call-template name="scape">
 
104
                                                        <xsl:with-param name="string" select="."/>
 
105
                                                </xsl:call-template>
 
106
                                        </xsl:otherwise>
 
107
                                </xsl:choose>
 
108
                        </xsl:with-param>
 
109
                </xsl:call-template>
 
110
        </xsl:template>
 
111
 
 
112
        <!--
 
113
        <xsl:template match="abbrev/text()">
 
114
                <xsl:variable name="string">
 
115
                        <xsl:call-template name="text"/>
 
116
                </xsl:variable>
 
117
                <xsl:call-template name="string-replace">
 
118
                        <xsl:with-param name="to">.\ </xsl:with-param>
 
119
                        <xsl:with-param name="from">. </xsl:with-param>
 
120
                        <xsl:with-param name="string" select="$string"/>
 
121
                </xsl:call-template>
 
122
        </xsl:template>
 
123
        -->
 
124
 
 
125
        <doc:template match="text()" mode="xref.text" xmlns="">
 
126
                <refpurpose>Process <literal>text()</literal> nodes</refpurpose>
 
127
                <doc:description>
 
128
                        <para>
 
129
 
 
130
                                Handles regular text content (i.e. <literal>#PCDATA</literal>)
 
131
                                from &docbook; documents when they are forming the displayed
 
132
                                text of an <doc:db>xref</doc:db>.
 
133
 
 
134
                        </para>
 
135
                </doc:description>
 
136
                <doc:variables>
 
137
                        &no_var;
 
138
                </doc:variables>
 
139
                <doc:notes>
 
140
                        <para>
 
141
 
 
142
                                &latex; active characters will be escaped using the <xref
 
143
                                linkend="template.scape"/> template.
 
144
 
 
145
                        </para>
 
146
                        <para>
 
147
 
 
148
                                In all cases, interior whitespace will be normalised according
 
149
                                to the XSLT specification with the additional feature that
 
150
                                leading and trailing whitespace will be elided (as expected
 
151
                                with SGML parsers).
 
152
 
 
153
                        </para>
 
154
                </doc:notes>
 
155
        </doc:template>
 
156
    <xsl:template match="text()" mode="xref.text">
 
157
                <xsl:call-template name="trim-outer">
 
158
                        <xsl:with-param name="string">
 
159
                                <xsl:call-template name="scape">
 
160
                                        <xsl:with-param name="string" select="."/>
 
161
                                </xsl:call-template>
 
162
                        </xsl:with-param>
 
163
                </xsl:call-template>
 
164
    </xsl:template>
 
165
 
 
166
        <doc:template match="text()" mode="xref-to" xmlns="">
 
167
                <refpurpose>Process <literal>text()</literal> nodes</refpurpose>
 
168
                <doc:description>
 
169
                        <para>
 
170
 
 
171
                                Handles regular text content (i.e. <literal>#PCDATA</literal>)
 
172
                                from &docbook; documents when they are forming the displayed
 
173
                                text of an <doc:db>xref</doc:db>.
 
174
 
 
175
                        </para>
 
176
                </doc:description>
 
177
                <doc:variables>
 
178
                        &no_var;
 
179
                </doc:variables>
 
180
                <doc:notes>
 
181
                        <para>
 
182
 
 
183
                                &latex; active characters will be escaped using the <xref
 
184
                                linkend="template.scape"/> template.
 
185
 
 
186
                        </para>
 
187
                        <para>
 
188
 
 
189
                                In all cases, interior whitespace will be normalised according
 
190
                                to the XSLT specification with the additional feature that
 
191
                                leading and trailing whitespace will be elided (as expected
 
192
                                with SGML parsers).
 
193
 
 
194
                        </para>
 
195
                </doc:notes>
 
196
        </doc:template>
 
197
    <xsl:template match="text()" mode="xref-to">
 
198
                <xsl:call-template name="trim-outer">
 
199
                        <xsl:with-param name="string">
 
200
                                <xsl:call-template name="scape">
 
201
                                        <xsl:with-param name="string" select="."/>
 
202
                                </xsl:call-template>
 
203
                        </xsl:with-param>
 
204
                </xsl:call-template>
 
205
    </xsl:template>
 
206
 
 
207
        <doc:template match="text()" mode="latex.verbatim" xmlns="">
 
208
                <refpurpose>Process <literal>text()</literal> nodes</refpurpose>
 
209
                <doc:description>
 
210
                        <para>
 
211
 
 
212
                                Handles regular text content (i.e. <literal>#PCDATA</literal>)
 
213
                                from &docbook; documents with they occur within certain
 
214
                                <quote>verbatim</quote>-mode elements.
 
215
 
 
216
                        </para>
 
217
                </doc:description>
 
218
                <doc:variables>
 
219
                        <variablelist>
 
220
                                <varlistentry>
 
221
                                        <term><xref linkend="param.latex.trim.verbatim"/></term>
 
222
                                        <listitem><simpara>
 
223
                                                When this variable is enabled, leading and trailing whitespace
 
224
                                                will be elided. Otherwise, all text is used verbatim.
 
225
                                        </simpara></listitem>
 
226
                                </varlistentry>
 
227
                        </variablelist>
 
228
                </doc:variables>
 
229
                <doc:notes>
 
230
                        <para>
 
231
 
 
232
                                Unlike other <literal>text()</literal> templates, &latex;
 
233
                                characters are not escaped by this template. This will result
 
234
                                in invalid output in some instances. However, it is currently
 
235
                                necessary for <quote>verbatim</quote>-mode support. Whitespace
 
236
                                is neither normalised nor elided.
 
237
 
 
238
                        </para>
 
239
                </doc:notes>
 
240
        </doc:template>
 
241
    <xsl:template match="text()" mode="latex.verbatim">
 
242
                <xsl:choose>
 
243
                        <xsl:when test="$latex.trim.verbatim=1">
 
244
                                <xsl:call-template name="trim.verbatim"/>
 
245
                        </xsl:when>
 
246
                        <xsl:otherwise>
 
247
                                <xsl:value-of select="."/> 
 
248
                        </xsl:otherwise>
 
249
                </xsl:choose>
 
250
    </xsl:template>
 
251
 
 
252
        <doc:template match="text()" mode="slash.hyphen" xmlns="">
 
253
                <refpurpose>Process <literal>text()</literal> nodes</refpurpose>
 
254
                <doc:description>
 
255
                        <para>
 
256
 
 
257
                                Handles URL text content from &docbook; documents.
 
258
 
 
259
                        </para>
 
260
                </doc:description>
 
261
                <doc:variables>
 
262
                        &no_var;
 
263
                </doc:variables>
 
264
                <doc:notes>
 
265
                        <para>
 
266
 
 
267
                                This template is only used by <xref
 
268
                                linkend="template.generate.string.url"/> and only when <xref
 
269
                                linkend="param.latex.hyphenation.tttricks"/> is disabled.
 
270
                                &latex; active characters will be escaped or hyphenated in a
 
271
                                fashion that is tailored for URLs via
 
272
                                <xref linkend="template.scape.slash.hyphen"/>.
 
273
 
 
274
                        </para>
 
275
                </doc:notes>
 
276
        </doc:template>
 
277
    <xsl:template match="text()" mode="slash.hyphen">
 
278
                <xsl:call-template name="trim-outer">
 
279
                        <xsl:with-param name="string">
 
280
                                <xsl:call-template name="scape.slash.hyphen">
 
281
                                        <xsl:with-param name="string" select="." />
 
282
                                </xsl:call-template>
 
283
                        </xsl:with-param>
 
284
                </xsl:call-template>
 
285
        </xsl:template>
 
286
 
 
287
        <doc:template name="trim-outer" xmlns="">
 
288
                <refpurpose>Whitespace Normalization and Discretionary Elision</refpurpose>
 
289
                <doc:description>
 
290
                        <para>
 
291
 
 
292
                                This template is used by various <literal>text()</literal>
 
293
                                templates to normalise interior whitespace and trim whitespace
 
294
                                that occurs at the start or end of a &docbook; element's
 
295
                                content.
 
296
 
 
297
                        </para>
 
298
                </doc:description>
 
299
                <doc:variables>
 
300
                        &no_var;
 
301
                </doc:variables>
 
302
                <doc:params>
 
303
                        <variablelist>
 
304
                                <varlistentry>
 
305
                                        <term>string</term>
 
306
                                        <listitem><simpara>The text to be processed.</simpara></listitem>
 
307
                                </varlistentry>
 
308
                        </variablelist>
 
309
                </doc:params>
 
310
                <doc:notes>
 
311
                        <para>
 
312
 
 
313
                                The template is normally called when the context node is within
 
314
                                a &docbook; document. The elision of leading or trailing
 
315
                                whitespace is dependent on values of the XPath functions
 
316
                                <function condition="xpath">position()</function> and <function
 
317
                                condition="xpath">last()</function>. This is similar to the
 
318
                                handling of whitespace by SGML parsers and allows authors to
 
319
                                format their XML documents with <quote>pretty</quote>
 
320
                                indentation without causing spurious whitespace in &latex;.
 
321
 
 
322
                        </para>
 
323
                        <para>
 
324
 
 
325
                                In all cases, interiour whitespace will be normalised with the
 
326
                                XPath <function condition="xpath">normalize-space()</function>
 
327
                                function. This is necessary to prevent blank-line problems in
 
328
                                &latex;.
 
329
 
 
330
                        </para>
 
331
                </doc:notes>
 
332
        </doc:template>
 
333
        <xsl:template name="trim-outer">
 
334
                <xsl:param name="string"/>
 
335
                <xsl:variable name="trimleft" select="position()=1"/>
 
336
                <xsl:variable name="trimright" select="position()=last()"/>
 
337
                <xsl:choose>
 
338
                        <xsl:when test="$trimleft and not($trimright)">
 
339
                                <xsl:value-of select="substring-before(normalize-space(concat($string,'$$')),'$$')"/>
 
340
                        </xsl:when>
 
341
                        <xsl:when test="$trimright and not($trimleft)">
 
342
                                <xsl:value-of select="substring-after(normalize-space(concat('$$',$string)),'$$')"/>
 
343
                        </xsl:when>
 
344
                        <xsl:when test="$trimleft and $trimright">
 
345
                                <xsl:value-of select="normalize-space($string)"/>
 
346
                        </xsl:when>
 
347
                        <xsl:otherwise>
 
348
                                <xsl:value-of select="substring-after(substring-before(normalize-space(concat('$$',$string,'$$$')),'$$$'),'$$')"/>
 
349
                        </xsl:otherwise>
 
350
                </xsl:choose>
 
351
        </xsl:template>
 
352
 
 
353
        <doc:template name="scape.slash.hyphen" xmlns="">
 
354
                <refpurpose>Process URL text</refpurpose>
 
355
                <doc:description>
 
356
                        <para>
 
357
 
 
358
                                Escapes or hyphenates &latex; active characters is URLs.
 
359
 
 
360
                        </para>
 
361
                </doc:description>
 
362
                <doc:variables>
 
363
                        &no_var;
 
364
                </doc:variables>
 
365
                <doc:params>
 
366
                        <variablelist>
 
367
                                <varlistentry>
 
368
                                        <term>string</term>
 
369
                                        <listitem><simpara>The URL text to be processed.</simpara></listitem>
 
370
                                </varlistentry>
 
371
                        </variablelist>
 
372
                </doc:params>
 
373
                <doc:notes>
 
374
                        <para>
 
375
 
 
376
                                This template is called by <xref
 
377
                                linkend="template.text()-slash.hyphen"/>. Text will be escaped
 
378
                                and hyphenated by the <xref linkend="template.scape-slash"/>
 
379
                                template, except that any portion up to <literal>://</literal>
 
380
                                will not be treated specially.
 
381
 
 
382
                        </para>
 
383
                </doc:notes>
 
384
        </doc:template>
 
385
        <xsl:template name="scape.slash.hyphen">
 
386
        <xsl:param name="string" />
 
387
        <xsl:choose>
 
388
                <xsl:when test="contains($string,'://')">
 
389
                        <xsl:call-template name="scape-slash">
 
390
                                <xsl:with-param name="string">
 
391
                                        <xsl:value-of select="substring-before($string,'://')"/>
 
392
                                        <xsl:value-of select="'://'"/>
 
393
                                        <xsl:call-template name="scape">
 
394
                                                <xsl:with-param name="string" select="substring-after($string,'://')"/>
 
395
                                        </xsl:call-template>
 
396
                                </xsl:with-param>
 
397
                        </xsl:call-template>
 
398
                </xsl:when>
 
399
                <xsl:otherwise>
 
400
                        <xsl:call-template name="scape-slash">
 
401
                                <xsl:with-param name="string">
 
402
                                        <xsl:call-template name="scape">
 
403
                                                <xsl:with-param name="string" select="$string"/>
 
404
                                        </xsl:call-template>
 
405
                                </xsl:with-param>
 
406
                        </xsl:call-template>
 
407
                </xsl:otherwise>
 
408
        </xsl:choose>
 
409
        </xsl:template>
 
410
 
 
411
        <doc:template name="normalize-scape" xmlns="">
 
412
                <refpurpose>Character Escaping and Whitespace Normalization</refpurpose>
 
413
                <doc:description>
 
414
                        <para>
 
415
 
 
416
                                This template is used by various templates to escape &latex;
 
417
                                active characters and to normalise whitespace.
 
418
 
 
419
                        </para>
 
420
                </doc:description>
 
421
                <doc:variables>
 
422
                        &no_var;
 
423
                </doc:variables>
 
424
                <doc:params>
 
425
                        <variablelist>
 
426
                                <varlistentry>
 
427
                                        <term>string</term>
 
428
                                        <listitem><simpara>The text to be processed.</simpara></listitem>
 
429
                                </varlistentry>
 
430
                        </variablelist>
 
431
                </doc:params>
 
432
                <doc:notes>
 
433
                        <para>
 
434
 
 
435
                                This template will call the <xref linkend="template.scape"/>
 
436
                                template and process its output with the XPath
 
437
                                <function condition="xpath">normalize-space</function>
 
438
                                function.
 
439
 
 
440
                        </para>
 
441
                </doc:notes>
 
442
        </doc:template>
 
443
        <xsl:template name="normalize-scape">
 
444
                <xsl:param name="string"/>
 
445
                <xsl:variable name="result">
 
446
                        <xsl:call-template name="scape">
 
447
                                <xsl:with-param name="string" select="$string"/>
 
448
                        </xsl:call-template>
 
449
                </xsl:variable>
 
450
                <xsl:value-of select="normalize-space($result)"/>
 
451
        </xsl:template>
 
452
 
 
453
        <doc:template name="string-replace" xmlns="">
 
454
                <refpurpose>Search-and-replace</refpurpose>
 
455
                <doc:description>
 
456
                        <para>
 
457
 
 
458
                                This template performs search-and-replace to modify all
 
459
                                instances of a substring.
 
460
 
 
461
                        </para>
 
462
                </doc:description>
 
463
                <doc:variables>
 
464
                        &no_var;
 
465
                </doc:variables>
 
466
                <doc:params>
 
467
                        <variablelist>
 
468
                                <varlistentry>
 
469
                                        <term>string</term>
 
470
                                        <listitem><simpara>The text to be searched.</simpara></listitem>
 
471
                                </varlistentry>
 
472
                                <varlistentry>
 
473
                                        <term>from</term>
 
474
                                        <listitem><simpara>The text (substring) to be replaced.</simpara></listitem>
 
475
                                </varlistentry>
 
476
                                <varlistentry>
 
477
                                        <term>to</term>
 
478
                                        <listitem><simpara>The text that replaces the <literal>from</literal> text.</simpara></listitem>
 
479
                                </varlistentry>
 
480
                        </variablelist>
 
481
                </doc:params>
 
482
                <doc:notes>
 
483
                        <para>
 
484
 
 
485
                                This template will search within the <literal>string</literal>
 
486
                                text for all occurrences of <literal>from</literal> and replace
 
487
                                them with the <literal>to</literal> text.
 
488
 
 
489
                        </para>
 
490
                </doc:notes>
 
491
        </doc:template>
 
492
        <xsl:template name="string-replace">
 
493
                <xsl:param name="string"/>
 
494
                <xsl:param name="from"/>
 
495
                <xsl:param name="to"/>
 
496
 
 
497
                <xsl:choose>
 
498
                        <xsl:when test="contains($string, $from)">
 
499
 
 
500
                        <xsl:variable name="before" select="substring-before($string, $from)"/>
 
501
                        <xsl:variable name="after" select="substring-after($string, $from)"/>
 
502
                        <xsl:variable name="prefix" select="concat($before, $to)"/>
 
503
 
 
504
                        <xsl:value-of select="$before"/>
 
505
                        <xsl:value-of select="$to"/>
 
506
                        <xsl:call-template name="string-replace">
 
507
                                <xsl:with-param name="string" select="$after"/>
 
508
                                <xsl:with-param name="from" select="$from"/>
 
509
                                <xsl:with-param name="to" select="$to"/>
 
510
                        </xsl:call-template>
 
511
                        </xsl:when>
 
512
                        <xsl:otherwise>
 
513
                        <xsl:value-of select="$string"/>
 
514
                        </xsl:otherwise>
 
515
                </xsl:choose>
 
516
        </xsl:template>
 
517
 
 
518
    <!--  
 
519
    (c) David Carlisle
 
520
    replace all occurences of the character(s) `from'
 
521
    by the string `to' in the string `string'.
 
522
    <xsl:template name="string-replace" >
 
523
        <xsl:param name="string"/>
 
524
        <xsl:param name="from"/>
 
525
        <xsl:param name="to"/>
 
526
        <xsl:choose>
 
527
            <xsl:when test="contains($string,$from)">
 
528
                <xsl:value-of select="substring-before($string,$from)"/>
 
529
                <xsl:value-of select="$to"/>
 
530
                <xsl:call-template name="string-replace">
 
531
                    <xsl:with-param name="string" select="substring-after($string,$from)"/>
 
532
                    <xsl:with-param name="from" select="$from"/>
 
533
                    <xsl:with-param name="to" select="$to"/>
 
534
                </xsl:call-template>
 
535
            </xsl:when>
 
536
            <xsl:otherwise>
 
537
                <xsl:value-of select="$string"/>
 
538
            </xsl:otherwise>
 
539
        </xsl:choose>
 
540
    </xsl:template>
 
541
    -->
 
542
 
 
543
        <xsl:template name="trim.verbatim">
 
544
                <xsl:variable name="before" select="preceding-sibling::node()"/>
 
545
                <xsl:variable name="after" select="following-sibling::node()"/>
 
546
 
 
547
                <xsl:variable name="conts" select="."/>
 
548
 
 
549
                <xsl:variable name="contsl">
 
550
                        <xsl:choose>
 
551
                                <xsl:when test="count($before) = 0">
 
552
                                        <xsl:call-template name="remove-lf-left">
 
553
                                                <xsl:with-param name="astr" select="$conts"/>
 
554
                                        </xsl:call-template>
 
555
                                </xsl:when>
 
556
                                <xsl:otherwise>
 
557
                                        <xsl:value-of select="$conts"/>
 
558
                                </xsl:otherwise>
 
559
                        </xsl:choose>
 
560
                </xsl:variable>
 
561
 
 
562
                <xsl:variable name="contslr">
 
563
                        <xsl:choose>
 
564
                                <xsl:when test="count($after) = 0">
 
565
                                        <xsl:call-template name="remove-ws-right">
 
566
                                                <xsl:with-param name="astr" select="$contsl"/>
 
567
                                        </xsl:call-template>
 
568
                                </xsl:when>
 
569
                                <xsl:otherwise>
 
570
                                        <xsl:value-of select="$contsl"/>
 
571
                                </xsl:otherwise>
 
572
                        </xsl:choose>
 
573
                </xsl:variable>
 
574
 
 
575
                <xsl:value-of select="$contslr"/>
 
576
        </xsl:template>
 
577
 
 
578
        <xsl:template name="remove-lf-left">
 
579
                <xsl:param name="astr"/>
 
580
                <xsl:choose>
 
581
                        <xsl:when test="starts-with($astr,'&#xA;') or
 
582
                                        starts-with($astr,'&#xD;') or
 
583
                                        starts-with($astr,'&#x20;') or
 
584
                                        starts-with($astr,'&#x9;')">
 
585
                                <xsl:call-template name="remove-lf-left">
 
586
                                        <xsl:with-param name="astr" select="substring($astr, 2)"/>
 
587
                                </xsl:call-template>
 
588
                        </xsl:when>
 
589
                        <xsl:otherwise>
 
590
                                <xsl:value-of select="$astr"/>
 
591
                        </xsl:otherwise>
 
592
                </xsl:choose>
 
593
        </xsl:template>
 
594
 
 
595
        <xsl:template name="remove-ws-right">
 
596
                <xsl:param name="astr"/>
 
597
                <xsl:variable name="last-char">
 
598
                        <xsl:value-of select="substring($astr, string-length($astr), 1)"/>
 
599
                </xsl:variable>
 
600
                <xsl:choose>
 
601
                        <xsl:when test="($last-char = '&#xA;') or
 
602
                                        ($last-char = '&#xD;') or
 
603
                                        ($last-char = '&#x20;') or
 
604
                                        ($last-char = '&#x9;')">
 
605
                                <xsl:call-template name="remove-ws-right">
 
606
                                        <xsl:with-param name="astr" select="substring($astr, 1, string-length($astr) - 1)"/>
 
607
                                </xsl:call-template>
 
608
                        </xsl:when>
 
609
                        <xsl:otherwise>
 
610
                                <xsl:value-of select="$astr"/>
 
611
                        </xsl:otherwise>
 
612
                </xsl:choose>
 
613
        </xsl:template>
 
614
 
 
615
</xsl:stylesheet>