Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / docx / utils / verbatim / verbatim.xsl @ 187

History | View | Annotate | Download (25.4 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dbk="http://docbook.org/ns/docbook" xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:teix="http://www.tei-c.org/ns/Examples" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" exclude-result-prefixes="xlink xhtml dbk rng sch m tei teix atom">
3
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
4
    <desc>
5
      <p> TEI stylesheet for creating verbatim XML </p>
6
      <p>This software is dual-licensed:
7

    
8
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
9
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
10

    
11
2. http://www.opensource.org/licenses/BSD-2-Clause
12
		
13
All rights reserved.
14

    
15
Redistribution and use in source and binary forms, with or without
16
modification, are permitted provided that the following conditions are
17
met:
18

    
19
* Redistributions of source code must retain the above copyright
20
notice, this list of conditions and the following disclaimer.
21

    
22
* Redistributions in binary form must reproduce the above copyright
23
notice, this list of conditions and the following disclaimer in the
24
documentation and/or other materials provided with the distribution.
25

    
26
This software is provided by the copyright holders and contributors
27
"as is" and any express or implied warranties, including, but not
28
limited to, the implied warranties of merchantability and fitness for
29
a particular purpose are disclaimed. In no event shall the copyright
30
holder or contributors be liable for any direct, indirect, incidental,
31
special, exemplary, or consequential damages (including, but not
32
limited to, procurement of substitute goods or services; loss of use,
33
data, or profits; or business interruption) however caused and on any
34
theory of liability, whether in contract, strict liability, or tort
35
(including negligence or otherwise) arising in any way out of the use
36
of this software, even if advised of the possibility of such damage.
37
</p>
38
      <p>Author: See AUTHORS</p>
39
      <p>Id: $Id: verbatim.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
40
      <p>Copyright: 2008, TEI Consortium</p>
41
    </desc>
42
  </doc>
43
  <xsl:strip-space elements="teix:* rng:* xsl:* xhtml:* atom:* m:*"/>
44
  <xsl:param name="startComment">&lt;span class="comment"&gt;</xsl:param>
45
  <xsl:param name="endComment">&lt;/span&gt;</xsl:param>
46
  <xsl:param name="startElement">&lt;span class="element"&gt;</xsl:param>
47
  <xsl:param name="endElement">&lt;/span&gt;</xsl:param>
48
  <xsl:param name="startElementName">&lt;span class="elementname"&gt;</xsl:param>
49
  <xsl:param name="endElementName">&lt;/span&gt;</xsl:param>
50
  <xsl:param name="startAttribute">&lt;span class="attribute"&gt;</xsl:param>
51
  <xsl:param name="endAttribute">&lt;/span&gt;</xsl:param>
52
  <xsl:param name="startAttributeValue">&lt;span class="attributevalue"&gt;</xsl:param>
53
  <xsl:param name="endAttributeValue">&lt;/span&gt;</xsl:param>
54
  <xsl:param name="startNamespace">&lt;span class="namespace"&gt;</xsl:param>
55
  <xsl:param name="endNamespace">&lt;/span&gt;</xsl:param>
56
  <xsl:param name="spaceCharacter">&#160;</xsl:param>
57
  <xsl:param name="showNamespaceDecls">true</xsl:param>
58
  <xsl:param name="forceWrap">false</xsl:param>
59
  <xsl:param name="wrapLength">65</xsl:param>
60
  <xsl:param name="attLength">40</xsl:param>
61
  <xsl:param name="attsOnSameLine">3</xsl:param>
62
  <xsl:key name="Namespaces" match="*[ancestor::teix:egXML]" use="namespace-uri()"/>
63
  <xsl:key name="Namespaces" match="*[not(ancestor::*)]" use="namespace-uri()"/>
64
  <xsl:template name="verbatim-newLine"/>
65
  <xsl:template name="verbatim-getNamespacePrefix">
66
    <xsl:variable name="ns" select="namespace-uri()"/>
67
    <xsl:choose>
68
      <xsl:when test="$ns='http://www.w3.org/XML/1998/namespace'">xml</xsl:when>
69
      <xsl:when test="$ns='http://www.tei-c.org/ns/1.0'">tei</xsl:when>
70
      <xsl:when test="$ns='http://docbook.org/ns/docbook'">dbk</xsl:when>
71
      <xsl:when test="$ns='http://www.w3.org/2001/XMLSchema'">xsd</xsl:when>
72
      <xsl:when test="$ns='http://www.ascc.net/xml/schematron'">sch</xsl:when>
73
      <xsl:when test="$ns='http://www.w3.org/1998/Math/MathML'">m</xsl:when>
74
      <xsl:when test="$ns='http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0'">nvdl</xsl:when>
75
      <xsl:when test="$ns='http://relaxng.org/ns/compatibility/annotations/1.0'">a</xsl:when>
76
      <xsl:when test="$ns='http://www.w3.org/1999/xhtml'">xhtml</xsl:when>
77
      <xsl:when test="$ns='http://www.w3.org/1999/xlink'">xlink</xsl:when>
78
      <xsl:when test="$ns='http://relaxng.org/ns/structure/1.0'">rng</xsl:when>
79
      <xsl:when test="$ns='http://earth.google.com/kml/2.1'">kml</xsl:when>
80
      <xsl:when test="$ns='http://www.w3.org/2005/11/its'">its</xsl:when>
81
      <xsl:when test="$ns='http://www.w3.org/1999/XSL/Transform'">xsl</xsl:when>
82
      <xsl:when test="$ns='http://www.w3.org/2005/Atom'">atom</xsl:when>
83
      <xsl:when test="$ns='http://purl.org/rss/1.0/modules/event/'">ev</xsl:when>
84
    </xsl:choose>
85
  </xsl:template>
86
  <xsl:template name="verbatim-lineBreak">
87
    <xsl:param name="id"/>
88
    <xsl:text>&#10;</xsl:text>
89
  </xsl:template>
90
  <xsl:template match="comment()" mode="verbatim">
91
    <xsl:choose>
92
      <xsl:when test="ancestor::Wrapper"/>
93
      <xsl:when test="ancestor::xhtml:Wrapper"/>
94
      <xsl:otherwise>
95
        <xsl:call-template name="verbatim-lineBreak">
96
          <xsl:with-param name="id">21</xsl:with-param>
97
        </xsl:call-template>
98
        <xsl:value-of disable-output-escaping="yes" select="$startComment"/>
99
        <xsl:text>&lt;!--</xsl:text>
100
        <xsl:choose>
101
          <xsl:when test="$forceWrap='true'">
102
            <xsl:call-template name="verbatim-reformatText">
103
              <xsl:with-param name="sofar">0</xsl:with-param>
104
              <xsl:with-param name="indent">
105
                <xsl:text> </xsl:text>
106
              </xsl:with-param>
107
              <xsl:with-param name="text">
108
                <xsl:value-of select="normalize-space(.)"/>
109
              </xsl:with-param>
110
            </xsl:call-template>
111
          </xsl:when>
112
          <xsl:otherwise>
113
            <xsl:value-of select="."/>
114
          </xsl:otherwise>
115
        </xsl:choose>
116
        <xsl:text>--&gt;</xsl:text>
117
        <xsl:value-of disable-output-escaping="yes" select="$endComment"/>
118
      </xsl:otherwise>
119
    </xsl:choose>
120
  </xsl:template>
121
  <xsl:template match="text()" mode="verbatim">
122
    <xsl:choose>
123
      <xsl:when test="$forceWrap='true'">
124
        <xsl:variable name="indent">
125
          <xsl:for-each select="parent::*">
126
            <xsl:call-template name="verbatim-makeIndent"/>
127
          </xsl:for-each>
128
        </xsl:variable>
129
        <xsl:if test="string-length(.)&gt;$wrapLength or parent::sch:assert">
130
          <xsl:text>&#10;</xsl:text>
131
          <xsl:value-of select="$indent"/>
132
        </xsl:if>
133
        <xsl:call-template name="verbatim-reformatText">
134
          <xsl:with-param name="sofar">0</xsl:with-param>
135
          <xsl:with-param name="indent">
136
            <xsl:value-of select="$indent"/>
137
          </xsl:with-param>
138
          <xsl:with-param name="text">
139
            <xsl:value-of select="normalize-space(.)"/>
140
          </xsl:with-param>
141
        </xsl:call-template>
142
        <xsl:if test="string-length(.)&gt;$wrapLength or parent::sch:assert">
143
          <xsl:text>&#10;</xsl:text>
144
          <xsl:value-of select="$indent"/>
145
        </xsl:if>
146
      </xsl:when>
147
      <xsl:when test="not(preceding-sibling::node() or         contains(.,'&#10;'))">
148
        <xsl:if test="starts-with(.,' ')">
149
          <xsl:text> </xsl:text>
150
        </xsl:if>
151
        <xsl:call-template name="verbatim-Text">
152
          <xsl:with-param name="words">
153
            <xsl:value-of select="normalize-space(.)"/>
154
          </xsl:with-param>
155
        </xsl:call-template>
156
        <xsl:if test="substring(.,string-length(.),1)=' '">
157
          <xsl:text> </xsl:text>
158
        </xsl:if>
159
      </xsl:when>
160
      <xsl:when test="normalize-space(.)=''">
161
        <xsl:for-each select="following-sibling::*[1]">
162
          <xsl:call-template name="verbatim-lineBreak">
163
            <xsl:with-param name="id">7</xsl:with-param>
164
          </xsl:call-template>
165
          <xsl:call-template name="verbatim-makeIndent"/>
166
        </xsl:for-each>
167
      </xsl:when>
168
      <xsl:otherwise>
169
        <xsl:call-template name="verbatim-wraptext">
170
          <xsl:with-param name="count">0</xsl:with-param>
171
          <xsl:with-param name="indent">
172
            <xsl:for-each select="parent::*">
173
              <xsl:call-template name="verbatim-makeIndent"/>
174
            </xsl:for-each>
175
          </xsl:with-param>
176
          <xsl:with-param name="text">
177
            <xsl:choose>
178
              <xsl:when test="starts-with(.,'&#10;') and not          (preceding-sibling::node())">
179
                <xsl:value-of select="translate(substring(.,2),'&#10;','⌤')"/>
180
              </xsl:when>
181
              <xsl:otherwise>
182
                <xsl:value-of select="translate(.,'&#10;','⌤')"/>
183
              </xsl:otherwise>
184
            </xsl:choose>
185
          </xsl:with-param>
186
        </xsl:call-template>
187
        <!--
188
	<xsl:if test="substring(.,string-length(.))=' '">
189
	  <xsl:text> </xsl:text>
190
	</xsl:if>
191
	-->
192
      </xsl:otherwise>
193
    </xsl:choose>
194
  </xsl:template>
195
  <xsl:template name="verbatim-reformatText">
196
    <xsl:param name="indent"/>
197
    <xsl:param name="text"/>
198
    <xsl:param name="sofar"/>
199
    <xsl:choose>
200
      <xsl:when test="$sofar&gt;$wrapLength">
201
        <xsl:text>&#10;</xsl:text>
202
        <xsl:value-of select="$indent"/>
203
        <xsl:call-template name="verbatim-reformatText">
204
          <xsl:with-param name="text">
205
            <xsl:value-of select="$text"/>
206
          </xsl:with-param>
207
          <xsl:with-param name="sofar">
208
            <xsl:text>0</xsl:text>
209
          </xsl:with-param>
210
          <xsl:with-param name="indent">
211
            <xsl:value-of select="$indent"/>
212
          </xsl:with-param>
213
        </xsl:call-template>
214
      </xsl:when>
215
      <xsl:when test="not(contains($text,' '))">
216
        <xsl:call-template name="verbatim-Text">
217
          <xsl:with-param name="words">
218
            <xsl:value-of select="$text"/>
219
          </xsl:with-param>
220
        </xsl:call-template>
221
      </xsl:when>
222
      <xsl:otherwise>
223
        <xsl:variable name="chunk">
224
          <xsl:value-of select="substring-before($text,' ')"/>
225
        </xsl:variable>
226
        <xsl:call-template name="verbatim-Text">
227
          <xsl:with-param name="words">
228
            <xsl:value-of select="$chunk"/>
229
            <xsl:text> </xsl:text>
230
          </xsl:with-param>
231
        </xsl:call-template>
232
        <xsl:call-template name="verbatim-reformatText">
233
          <xsl:with-param name="text">
234
            <xsl:value-of select="substring-after($text,' ')"/>
235
          </xsl:with-param>
236
          <xsl:with-param name="sofar">
237
            <xsl:value-of select="$sofar + string-length($chunk) + 1"/>
238
          </xsl:with-param>
239
          <xsl:with-param name="indent">
240
            <xsl:value-of select="$indent"/>
241
          </xsl:with-param>
242
        </xsl:call-template>
243
      </xsl:otherwise>
244
    </xsl:choose>
245
  </xsl:template>
246
  <xsl:template name="verbatim-wraptext">
247
    <xsl:param name="indent"/>
248
    <xsl:param name="text"/>
249
    <xsl:param name="count">0</xsl:param>
250
    <xsl:variable name="finalSpace">
251
      <xsl:choose>
252
        <xsl:when test="substring($text,string-length($text),1)=' '">
253
          <xsl:text> </xsl:text>
254
        </xsl:when>
255
        <xsl:when test="substring($text,string-length($text),1)='⌤'">
256
          <xsl:text> </xsl:text>
257
        </xsl:when>
258
        <xsl:otherwise>
259
          <xsl:text/>
260
        </xsl:otherwise>
261
      </xsl:choose>
262
    </xsl:variable>
263
    <!--
264
<xsl:message>my text is [<xsl:value-of select="$text"/>]</xsl:message>
265
<xsl:message>my space is [<xsl:value-of select="$finalSpace"/>]</xsl:message>
266
-->
267
    <xsl:choose>
268
      <xsl:when test="normalize-space($text)=''"/>
269
      <xsl:when test="contains($text,'⌤')">
270
        <xsl:if test="$count &gt; 0">
271
          <xsl:value-of select="$indent"/>
272
          <xsl:text> </xsl:text>
273
        </xsl:if>
274
        <xsl:if test="starts-with($text,' ')">
275
          <xsl:text> </xsl:text>
276
        </xsl:if>
277
        <xsl:call-template name="verbatim-Text">
278
          <xsl:with-param name="words">
279
            <xsl:value-of select="normalize-space(substring-before($text,'⌤'))"/>
280
          </xsl:with-param>
281
        </xsl:call-template>
282
        <!--	<xsl:if test="not(substring-after($text,'&#10;')='')">-->
283
        <xsl:call-template name="verbatim-lineBreak">
284
          <xsl:with-param name="id">6</xsl:with-param>
285
        </xsl:call-template>
286
        <xsl:value-of select="$indent"/>
287
        <xsl:call-template name="verbatim-wraptext">
288
          <xsl:with-param name="indent">
289
            <xsl:value-of select="$indent"/>
290
          </xsl:with-param>
291
          <xsl:with-param name="text">
292
            <xsl:value-of select="normalize-space(substring-after($text,'⌤'))"/>
293
            <xsl:value-of select="$finalSpace"/>
294
          </xsl:with-param>
295
          <xsl:with-param name="count">
296
            <xsl:value-of select="$count + 1"/>
297
          </xsl:with-param>
298
        </xsl:call-template>
299
      </xsl:when>
300
      <xsl:otherwise>
301
        <xsl:if test="starts-with($text,' ')">
302
          <xsl:text> </xsl:text>
303
        </xsl:if>
304
        <xsl:if test="$count &gt; 0 and parent::*">
305
          <xsl:value-of select="$indent"/>
306
          <xsl:text> </xsl:text>
307
        </xsl:if>
308
        <xsl:call-template name="verbatim-Text">
309
          <xsl:with-param name="words">
310
            <xsl:value-of select="normalize-space($text)"/>
311
            <xsl:value-of select="$finalSpace"/>
312
          </xsl:with-param>
313
        </xsl:call-template>
314
      </xsl:otherwise>
315
    </xsl:choose>
316
  </xsl:template>
317
  <xsl:template name="verbatim-Text">
318
    <xsl:param name="words"/>
319
    <xsl:analyze-string select="." regex="(&amp;)">
320
      <xsl:matching-substring>
321
        <xsl:text>&amp;amp;</xsl:text>
322
      </xsl:matching-substring>
323
      <xsl:non-matching-substring>
324
        <xsl:value-of select="."/>
325
      </xsl:non-matching-substring>
326
    </xsl:analyze-string>
327
  </xsl:template>
328
  <xsl:template match="*" mode="verbatim">
329
    <xsl:choose>
330
      <xsl:when test="parent::xhtml:Wrapper"/>
331
      <!--      <xsl:when test="child::node()[last()]/self::text()[not(.='')] and child::node()[1]/self::text()[not(.='')]"/>-->
332
      <xsl:when test="not(parent::*)  or parent::teix:egXML">
333
        <xsl:choose>
334
          <xsl:when test="preceding-sibling::node()[1][self::text()]      and following-sibling::node()[1][self::text()]"/>
335
          <xsl:when test="preceding-sibling::*">
336
            <xsl:call-template name="verbatim-lineBreak">
337
              <xsl:with-param name="id">-1</xsl:with-param>
338
            </xsl:call-template>
339
          </xsl:when>
340
          <xsl:otherwise>
341
            <xsl:call-template name="verbatim-newLine"/>
342
            <!-- <xsl:call-template name="makeIndent"/>-->
343
          </xsl:otherwise>
344
        </xsl:choose>
345
      </xsl:when>
346
      <xsl:when test="not(preceding-sibling::node())">
347
        <xsl:call-template name="verbatim-lineBreak">
348
          <xsl:with-param name="id">-2</xsl:with-param>
349
        </xsl:call-template>
350
        <xsl:call-template name="verbatim-makeIndent"/>
351
      </xsl:when>
352
      <xsl:when test="preceding-sibling::node()[1]/self::*">
353
        <xsl:call-template name="verbatim-lineBreak">
354
          <xsl:with-param name="id">1</xsl:with-param>
355
        </xsl:call-template>
356
        <xsl:call-template name="verbatim-makeIndent"/>
357
      </xsl:when>
358
      <xsl:when test="preceding-sibling::node()[1]/self::text()"> </xsl:when>
359
      <xsl:otherwise>
360
        <xsl:call-template name="verbatim-lineBreak">
361
          <xsl:with-param name="id">9</xsl:with-param>
362
        </xsl:call-template>
363
        <xsl:call-template name="verbatim-makeIndent"/>
364
      </xsl:otherwise>
365
    </xsl:choose>
366
    <xsl:value-of disable-output-escaping="yes" select="$startElement"/>
367
    <xsl:text>&lt;</xsl:text>
368
    <xsl:call-template name="verbatim-makeElementName">
369
      <xsl:with-param name="start">true</xsl:with-param>
370
    </xsl:call-template>
371
    <xsl:apply-templates select="@*" mode="verbatim"/>
372
    <xsl:if test="$showNamespaceDecls='true' or parent::teix:egXML[@rend='full']">
373
      <!--
374
	  <xsl:variable name="me" select="."/>
375
	  <xsl:message><xsl:value-of select="name()"/>: </xsl:message>
376
	  <xsl:for-each select="in-scope-prefixes(.)">
377
	  <xsl:message>  .. <xsl:value-of select="."/>: <xsl:value-of select="namespace-uri-for-prefix(.,$me)"/> </xsl:message>
378
	  </xsl:for-each>
379
      -->
380
      <!-- 2009-02-01 stop emitting xmlns at all -->
381
      <!--
382
      <xsl:choose>
383
        <xsl:when test="not(parent::*)">
384
          <xsl:apply-templates select="." mode="ns"/>
385
        </xsl:when>
386
        <xsl:when test="parent::teix:egXML and not(preceding-sibling::*)">
387
          <xsl:apply-templates select="." mode="ns"/>
388
        </xsl:when>
389
      </xsl:choose>
390
      -->
391
    </xsl:if>
392
    <xsl:choose>
393
      <xsl:when test="child::node()">
394
        <xsl:text>&gt;</xsl:text>
395
        <xsl:value-of disable-output-escaping="yes" select="$endElement"/>
396
        <xsl:apply-templates mode="verbatim"/>
397
        <xsl:choose>
398
          <xsl:when test="child::node()[last()]/self::text() and child::node()[1]/self::text()"/>
399
          <xsl:when test="not(parent::*)  or parent::teix:egXML">
400
            <xsl:call-template name="verbatim-lineBreak">
401
              <xsl:with-param name="id">23</xsl:with-param>
402
            </xsl:call-template>
403
          </xsl:when>
404
          <xsl:when test="child::node()[last()]/self::text()[normalize-space(.)='']">
405
            <xsl:call-template name="verbatim-lineBreak">
406
              <xsl:with-param name="id">3</xsl:with-param>
407
            </xsl:call-template>
408
            <xsl:call-template name="verbatim-makeIndent"/>
409
          </xsl:when>
410
          <xsl:when test="child::node()[last()]/self::comment()">
411
            <xsl:call-template name="verbatim-lineBreak">
412
              <xsl:with-param name="id">4</xsl:with-param>
413
            </xsl:call-template>
414
            <xsl:call-template name="verbatim-makeIndent"/>
415
          </xsl:when>
416
          <xsl:when test="child::node()[last()]/self::*">
417
            <xsl:call-template name="verbatim-lineBreak">
418
              <xsl:with-param name="id">5</xsl:with-param>
419
            </xsl:call-template>
420
            <xsl:call-template name="verbatim-makeIndent"/>
421
          </xsl:when>
422
        </xsl:choose>
423
        <xsl:value-of disable-output-escaping="yes" select="$startElement"/>
424
        <xsl:text>&lt;/</xsl:text>
425
        <xsl:call-template name="verbatim-makeElementName">
426
          <xsl:with-param name="start">false</xsl:with-param>
427
        </xsl:call-template>
428
        <xsl:text>&gt;</xsl:text>
429
        <xsl:value-of disable-output-escaping="yes" select="$endElement"/>
430
      </xsl:when>
431
      <xsl:otherwise>
432
        <xsl:text>/&gt;</xsl:text>
433
        <xsl:value-of disable-output-escaping="yes" select="$endElement"/>
434
      </xsl:otherwise>
435
    </xsl:choose>
436
  </xsl:template>
437
  <xsl:template name="verbatim-createElement">
438
    <xsl:param name="special"/>
439
    <xsl:param name="name"/>
440
    <xsl:value-of select="$name"/>
441
  </xsl:template>
442
  <xsl:template name="verbatim-createAttribute">
443
    <xsl:param name="name"/>
444
    <xsl:value-of select="$name"/>
445
  </xsl:template>
446
  <xsl:template name="verbatim-makeElementName">
447
    <xsl:param name="start"/>
448
    <!-- get namespace prefix -->
449
    <xsl:variable name="ns-prefix">
450
      <xsl:call-template name="verbatim-getNamespacePrefix"/>
451
    </xsl:variable>
452
    <xsl:variable name="ns-parent">
453
      <xsl:for-each select="parent::*">
454
        <xsl:value-of select="namespace-uri()"/>
455
      </xsl:for-each>
456
    </xsl:variable>
457
    <xsl:variable name="ns">
458
      <xsl:value-of select="namespace-uri()"/>
459
    </xsl:variable>
460
    <xsl:choose>
461
      <xsl:when test="namespace-uri()='http://www.tei-c.org/ns/Examples'">
462
        <xsl:call-template name="verbatim-createElement">
463
          <xsl:with-param name="name" select="local-name(.)"/>
464
          <xsl:with-param name="special"/>
465
        </xsl:call-template>
466
      </xsl:when>
467
      <xsl:when test="string-length($ns-prefix) &gt; 0">
468
        <xsl:call-template name="verbatim-createElement">
469
          <xsl:with-param name="name" select="concat($ns-prefix,concat(':',local-name(.)))"/>
470
          <xsl:with-param name="special"/>
471
        </xsl:call-template>
472
      </xsl:when>
473
      <xsl:when test="$ns-parent=$ns">
474
        <xsl:call-template name="verbatim-createElement">
475
          <xsl:with-param name="name" select="local-name(.)"/>
476
          <xsl:with-param name="special"/>
477
        </xsl:call-template>
478
      </xsl:when>
479
      <xsl:when test="not($ns='')">
480
        <xsl:call-template name="verbatim-createElement">
481
          <xsl:with-param name="name" select="local-name(.)"/>
482
          <xsl:with-param name="special"/>
483
        </xsl:call-template>
484
        <xsl:if test="$start='true'">
485
          <xsl:text> xmlns="</xsl:text>
486
          <xsl:value-of select="namespace-uri()"/>
487
          <xsl:text>"</xsl:text>
488
          <xsl:call-template name="verbatim-lineBreak">
489
            <xsl:with-param name="id">5</xsl:with-param>
490
          </xsl:call-template>
491
          <xsl:call-template name="verbatim-makeIndent"/>
492
        </xsl:if>
493
      </xsl:when>
494
      <xsl:otherwise>
495
        <xsl:value-of disable-output-escaping="yes" select="$startElementName"/>
496
        <xsl:value-of select="local-name(.)"/>
497
        <xsl:value-of disable-output-escaping="yes" select="$endElementName"/>
498
      </xsl:otherwise>
499
    </xsl:choose>
500
  </xsl:template>
501
  <xsl:template name="verbatim-makeIndent">
502
    <xsl:variable name="depth" select="count(ancestor::*[not(namespace-uri()='http://www.tei-c.org/ns/1.0')])"/>
503
    <xsl:call-template name="verbatim-makeSpace">
504
      <xsl:with-param name="d">
505
        <xsl:value-of select="$depth"/>
506
      </xsl:with-param>
507
    </xsl:call-template>
508
  </xsl:template>
509
  <xsl:template name="verbatim-makeSpace">
510
    <xsl:param name="d"/>
511
    <xsl:if test="number($d)&gt;1">
512
      <xsl:value-of select="$spaceCharacter"/>
513
      <xsl:call-template name="verbatim-makeSpace">
514
        <xsl:with-param name="d">
515
          <xsl:value-of select="$d -1"/>
516
        </xsl:with-param>
517
      </xsl:call-template>
518
    </xsl:if>
519
  </xsl:template>
520
  <xsl:template match="@*" mode="verbatim">
521
    <xsl:variable name="L">
522
      <xsl:for-each select="../@*">
523
        <xsl:value-of select="."/>
524
      </xsl:for-each>
525
    </xsl:variable>
526
    <xsl:if test="count(../@*)&gt;$attsOnSameLine or      string-length($L)&gt;$attLength or     ancestor::tei:cell[not(@rend='wovenodd-col2')] or     namespace-uri()='http://www.w3.org/2005/11/its' or     string-length(.)+string-length(name(.)) &gt;     $attLength">
527
      <xsl:call-template name="verbatim-lineBreak">
528
        <xsl:with-param name="id">5</xsl:with-param>
529
      </xsl:call-template>
530
      <xsl:call-template name="verbatim-makeIndent"/>
531
    </xsl:if>
532
    <xsl:value-of select="$spaceCharacter"/>
533
    <xsl:variable name="ns-prefix">
534
      <xsl:call-template name="verbatim-getNamespacePrefix"/>
535
    </xsl:variable>
536
    <xsl:variable name="name">
537
      <xsl:choose>
538
        <xsl:when test="string-length($ns-prefix) &gt; 0">
539
          <xsl:value-of select="$ns-prefix"/>
540
          <xsl:text>:</xsl:text>
541
          <xsl:value-of select="local-name(.)"/>
542
        </xsl:when>
543
        <xsl:otherwise>
544
          <xsl:value-of select="local-name(.)"/>
545
        </xsl:otherwise>
546
      </xsl:choose>
547
    </xsl:variable>
548
    <xsl:call-template name="verbatim-createAttribute">
549
      <xsl:with-param name="name" select="$name"/>
550
    </xsl:call-template>
551
    <xsl:text>="</xsl:text>
552
    <xsl:value-of disable-output-escaping="yes" select="$startAttributeValue"/>
553
    <xsl:apply-templates select="." mode="attributetext"/>
554
    <xsl:value-of disable-output-escaping="yes" select="$endAttributeValue"/>
555
    <xsl:text>"</xsl:text>
556
  </xsl:template>
557
  <xsl:template match="@*" mode="attributetext">
558
    <xsl:choose>
559
      <xsl:when test="string-length(.)&gt;$attLength and contains(.,' ')">
560
        <xsl:call-template name="verbatim-reformatText">
561
          <xsl:with-param name="sofar">0</xsl:with-param>
562
          <xsl:with-param name="indent">
563
            <xsl:text> </xsl:text>
564
          </xsl:with-param>
565
          <xsl:with-param name="text">
566
            <xsl:value-of select="normalize-space(.)"/>
567
          </xsl:with-param>
568
        </xsl:call-template>
569
      </xsl:when>
570
      <xsl:otherwise>
571
        <xsl:value-of select="."/>
572
      </xsl:otherwise>
573
    </xsl:choose>
574
  </xsl:template>
575
  <xsl:template match="text()|comment()|processing-instruction()" mode="ns"/>
576
  <xsl:template match="@*|*" mode="ns">
577
    <xsl:variable name="ns" select="namespace-uri()"/>
578
    <xsl:choose>
579
      <xsl:when test="$ns=''"/>
580
      <xsl:when test="$ns='http://relaxng.org/ns/structure/1.0'"/>
581
      <xsl:when test="$ns='http://www.w3.org/2001/XInclude'"/>
582
      <xsl:when test="$ns='http://www.tei-c.org/ns/Examples'"/>
583
      <xsl:when test="$ns='http://www.ascc.net/xml/schematron'"/>
584
      <xsl:when test="$ns='http://relaxng.org/ns/compatibility/annotations/1.0'"/>
585
      <xsl:when test="$ns='http://www.w3.org/XML/1998/namespace'"/>
586
      <xsl:otherwise>
587
      </xsl:otherwise>
588
    </xsl:choose>
589
    <xsl:apply-templates mode="ns" select="@*|*"/>
590
  </xsl:template>
591
  <xsl:template name="ns">
592
    <xsl:param name="nsname"/>
593
    <xsl:call-template name="verbatim-lineBreak">
594
      <xsl:with-param name="id">22</xsl:with-param>
595
    </xsl:call-template>
596
    <xsl:text>&#160;&#160;&#160;</xsl:text>
597
    <xsl:text>xmlns:</xsl:text>
598
    <xsl:value-of select="name(.)"/>
599
    <xsl:text>="</xsl:text>
600
    <xsl:value-of select="."/>
601
    <xsl:text>"</xsl:text>
602
  </xsl:template>
603
</xsl:stylesheet>