Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / p4top5_perseus.xsl @ 187

History | View | Annotate | Download (25.3 kB)

1
<?xml version="1.0"?>
2
<xsl:stylesheet xmlns:edate="http://exslt.org/dates-and-times"
3
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tei="http://www.tei-c.org/ns/1.0"
4
  exclude-result-prefixes="tei edate" version="1.0">
5
  <!-- 
6
       
7
       P4 to P5 converter 
8
       
9
       Sebastian Rahtz <sebastian.rahtz@oucs.ox.ac.uk>
10
       
11
       $Date: 2007-11-01 16:33:34 +0000 (Thu, 01 Nov 2007) $  $Id: p4top5.xsl 3927 2007-11-01 16:33:34Z rahtz $
12
       
13
       Copyright 2007 TEI Consortium
14
       
15
       Permission is hereby granted, free of charge, to any person obtaining
16
       a copy of this software and any associated documentation gfiles (the
17
       ``Software''), to deal in the Software without restriction, including
18
       without limitation the rights to use, copy, modify, merge, publish,
19
       distribute, sublicense, and/or sell copies of the Software, and to
20
       permit persons to whom the Software is furnished to do so, subject to
21
       the following conditions:
22
       
23
       The above copyright notice and this permission notice shall be included
24
       in all copies or substantial portions of the Software.
25
       
26
  -->
27

    
28
  <!-- Added changes specific to BFM
29
       
30
       Alexei Lavrentiev
31
       
32
       2009-11-13
33
       
34
       p[@rend='gv'] - ab
35
       corr[@sic and @rend]
36
       
37
       2010-03-12
38
       including w into corr (for tokenised texts)
39
       
40
  -->
41
  <xsl:output method="xml" encoding="utf-8" cdata-section-elements="tei:eg"
42
    omit-xml-declaration="no"/>
43

    
44
  <xsl:variable name="processor">
45
    <xsl:value-of select="system-property('xsl:vendor')"/>
46
  </xsl:variable>
47

    
48
  <xsl:variable name="today">
49
    <xsl:choose>
50
      <xsl:when test="function-available('edate:date-time')">
51
        <xsl:value-of select="edate:date-time()"/>
52
      </xsl:when>
53
      <xsl:when test="contains($processor,'SAXON')">
54
        <xsl:value-of select="Date:toString(Date:new())" xmlns:Date="/java.util.Date"/>
55
      </xsl:when>
56
      <xsl:otherwise>0000-00-00</xsl:otherwise>
57
    </xsl:choose>
58
  </xsl:variable>
59

    
60
  <xsl:variable name="uc">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
61
  <xsl:variable name="lc">abcdefghijklmnopqrstuvwxyz</xsl:variable>
62

    
63
  <xsl:template match="*">
64
    <xsl:choose>
65
      <xsl:when test="namespace-uri()=''">
66
        <xsl:element namespace="http://www.tei-c.org/ns/1.0" name="{local-name(.)}">
67
          <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
68
        </xsl:element>
69
      </xsl:when>
70
      <xsl:otherwise>
71
        <xsl:copy>
72
          <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
73
        </xsl:copy>
74
      </xsl:otherwise>
75
    </xsl:choose>
76
  </xsl:template>
77

    
78

    
79
  <xsl:template match="@*|processing-instruction()|comment()">
80
    <xsl:copy/>
81
  </xsl:template>
82

    
83

    
84
  <xsl:template match="text()">
85
    <xsl:value-of select="."/>
86
  </xsl:template>
87

    
88

    
89
  <!-- change of name, or replaced by another element -->
90
  <xsl:template match="teiCorpus.2">
91
    <teiCorpus xmlns="http://www.tei-c.org/ns/1.0">
92
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
93
    </teiCorpus>
94
  </xsl:template>
95

    
96
  <xsl:template match="witness/@sigil">
97
    <xsl:attribute name="xml:id">
98
      <xsl:value-of select="."/>
99
    </xsl:attribute>
100
  </xsl:template>
101

    
102
  <xsl:template match="witList">
103
    <listWit xmlns="http://www.tei-c.org/ns/1.0">
104
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
105
    </listWit>
106
  </xsl:template>
107

    
108

    
109
  <xsl:template match="TEI.2">
110
    <TEI xmlns="http://www.tei-c.org/ns/1.0">
111
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
112
    </TEI>
113
  </xsl:template>
114

    
115
  <xsl:template match="xref">
116
    <xsl:element namespace="http://www.tei-c.org/ns/1.0" name="ref">
117
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
118
    </xsl:element>
119
  </xsl:template>
120

    
121

    
122
  <xsl:template match="xptr">
123
    <xsl:element namespace="http://www.tei-c.org/ns/1.0" name="ptr">
124
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
125
    </xsl:element>
126
  </xsl:template>
127

    
128

    
129
  <xsl:template match="figure[@url]">
130
    <figure xmlns="http://www.tei-c.org/ns/1.0">
131
      <graphic xmlns="http://www.tei-c.org/ns/1.0">
132
        <xsl:copy-of select="@*"/>
133
      </graphic>
134
      <xsl:apply-templates/>
135
    </figure>
136
  </xsl:template>
137

    
138

    
139
  <xsl:template match="figure/@url"/>
140

    
141
  <xsl:template match="figure/@entity"/>
142

    
143
  <xsl:template match="figure[@entity]">
144
    <figure xmlns="http://www.tei-c.org/ns/1.0">
145
      <graphic xmlns="http://www.tei-c.org/ns/1.0" url="{unparsed-entity-uri(@entity)}">
146
        <xsl:apply-templates select="@*"/>
147
      </graphic>
148
      <xsl:apply-templates/>
149
    </figure>
150
  </xsl:template>
151

    
152
  <xsl:template match="event">
153
    <incident xmlns="http://www.tei-c.org/ns/1.0">
154
      <xsl:apply-templates select="@*|*|text()|comment()|processing-instruction()"/>
155
    </incident>
156
  </xsl:template>
157

    
158
  <xsl:template match="state">
159
    <refState xmlns="http://www.tei-c.org/ns/1.0">
160
      <xsl:apply-templates select="@*|*|text()|comment()|processing-instruction()"/>
161
    </refState>
162
  </xsl:template>
163

    
164

    
165
  <!-- lost elements -->
166
  <xsl:template match="dateRange">
167
    <date xmlns="http://www.tei-c.org/ns/1.0">
168
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
169
    </date>
170
  </xsl:template>
171

    
172

    
173
  <xsl:template match="dateRange/@from">
174
    <xsl:copy-of select="."/>
175
  </xsl:template>
176

    
177
  <xsl:template match="dateRange/@to">
178
    <xsl:copy-of select="."/>
179
  </xsl:template>
180

    
181
  <xsl:template match="language">
182
    <xsl:element namespace="http://www.tei-c.org/ns/1.0" name="language">
183
      <xsl:if test="@id">
184
        <xsl:attribute name="ident">
185
          <xsl:value-of select="@id"/>
186
        </xsl:attribute>
187
      </xsl:if>
188
      <xsl:apply-templates select="*|processing-instruction()|comment()|text()"/>
189
    </xsl:element>
190
  </xsl:template>
191

    
192
  <!-- attributes lost -->
193
  <!-- dropped from TEI. Added as new change records later -->
194
  <xsl:template match="@date.created"/>
195

    
196
  <xsl:template match="@date.updated"/>
197

    
198
  <!-- dropped from TEI. No replacement -->
199
  <xsl:template match="refsDecl/@doctype"/>
200

    
201
  <!-- attributes changed name -->
202

    
203
  <xsl:template match="date/@value">
204
    <xsl:attribute name="when">
205
      <xsl:value-of select="."/>
206
    </xsl:attribute>
207
  </xsl:template>
208

    
209

    
210
  <xsl:template match="@url">
211
    <xsl:attribute name="target">
212
      <xsl:value-of select="."/>
213
    </xsl:attribute>
214
  </xsl:template>
215

    
216

    
217
  <xsl:template match="@doc">
218
    <xsl:attribute name="target">
219
      <xsl:value-of select="unparsed-entity-uri(.)"/>
220
    </xsl:attribute>
221
  </xsl:template>
222

    
223

    
224
  <xsl:template match="@id">
225
    <xsl:choose>
226
      <xsl:when test="parent::lang">
227
        <xsl:attribute name="ident">
228
          <xsl:value-of select="."/>
229
        </xsl:attribute>
230
      </xsl:when>
231
      <xsl:otherwise>
232
        <xsl:attribute name="xml:id">
233
          <xsl:value-of select="."/>
234
        </xsl:attribute>
235
      </xsl:otherwise>
236
    </xsl:choose>
237
  </xsl:template>
238

    
239

    
240
  <xsl:template match="@lang">
241
    <xsl:attribute name="xml:lang">
242
      <xsl:value-of select="."/>
243
    </xsl:attribute>
244
  </xsl:template>
245

    
246

    
247
  <xsl:template match="change/@date"/>
248

    
249
  <xsl:template match="date/@certainty">
250
    <xsl:attribute name="cert">
251
      <xsl:value-of select="."/>
252
    </xsl:attribute>
253
  </xsl:template>
254

    
255
  <!-- all pointing attributes preceded by # -->
256

    
257
  <xsl:template match="variantEncoding/@location">
258
    <xsl:copy-of select="."/>
259
  </xsl:template>
260

    
261
  <xsl:template
262
    match="@ana|@active|@adj|@adjFrom|@adjTo|@children|@children|@class|@code|@code|@copyOf|@corresp|@decls|@domains|@end|@exclude|@fVal|@feats|@follow|@from|@hand|@inst|@langKey|@location|@mergedin|@new|@next|@old|@origin|@otherLangs|@parent|@passive|@perf|@prev|@render|@resp|@sameAs|@scheme|@script|@select|@since|@start|@synch|@target|@targetEnd|@to|@to|@value|@value|@who|@wit">
263
    <xsl:attribute name="{name(.)}">
264
      <xsl:call-template name="splitter">
265
        <xsl:with-param name="val">
266
          <xsl:value-of select="."/>
267
        </xsl:with-param>
268
      </xsl:call-template>
269
    </xsl:attribute>
270
  </xsl:template>
271

    
272

    
273
  <xsl:template name="splitter">
274
    <xsl:param name="val"/>
275
    <xsl:choose>
276
      <xsl:when test="contains($val,' ')">
277
        <xsl:text>#</xsl:text>
278
        <xsl:value-of select="substring-before($val,' ')"/>
279
        <xsl:text> </xsl:text>
280
        <xsl:call-template name="splitter">
281
          <xsl:with-param name="val">
282
            <xsl:value-of select="substring-after($val,' ')"/>
283
          </xsl:with-param>
284
        </xsl:call-template>
285
      </xsl:when>
286
      <xsl:otherwise>
287
        <xsl:text>#</xsl:text>
288
        <xsl:value-of select="$val"/>
289
      </xsl:otherwise>
290
    </xsl:choose>
291
  </xsl:template>
292

    
293

    
294
  <!-- fool around with selected elements -->
295

    
296

    
297
  <!-- imprint is no longer allowed inside bibl -->
298
  <xsl:template match="bibl/imprint">
299
    <xsl:apply-templates/>
300
  </xsl:template>
301

    
302
  <xsl:template match="editionStmt/editor">
303
    <respStmt xmlns="http://www.tei-c.org/ns/1.0">
304
      <resp>
305
        <xsl:value-of select="@role"/>
306
      </resp>
307
      <name>
308
        <xsl:apply-templates/>
309
      </name>
310
    </respStmt>
311
  </xsl:template>
312

    
313
  <!-- header -->
314
  <!-- BFM special treatment 
315
  <xsl:template match="teiHeader">
316
    <teiHeader xmlns="http://www.tei-c.org/ns/1.0">
317
      <xsl:apply-templates select="@*|*|comment()|processing-instruction()"/>
318
      
319
      <xsl:if test="not(revisionDesc) and (@date.created or @date.updated)">
320
	<revisionDesc  xmlns="http://www.tei-c.org/ns/1.0">
321
	  <xsl:if test="@date.updated">
322
	    <change  xmlns="http://www.tei-c.org/ns/1.0">>
323
	    <label>updated</label>
324
	    <date  xmlns="http://www.tei-c.org/ns/1.0">
325
	      <xsl:value-of select="@date.updated"/>
326
	    </date>
327
	    <label  xmlns="http://www.tei-c.org/ns/1.0">Date edited</label>
328
	    </change>
329
	  </xsl:if>
330
	  <xsl:if test="@date.created">
331
	    <change  xmlns="http://www.tei-c.org/ns/1.0">
332
	      <label>created</label>
333
	      <date  xmlns="http://www.tei-c.org/ns/1.0">
334
		<xsl:value-of select="@date.created"/>
335
	      </date>
336
	      <label  xmlns="http://www.tei-c.org/ns/1.0">Date created</label>
337
	    </change>
338
	  </xsl:if>
339
	</revisionDesc>
340
      </xsl:if>
341
     [comment]
342
	  <change when="{$today}"  xmlns="http://www.tei-c.org/ns/1.0">Converted to TEI P5 XML by p4top5.xsl
343
	  written by Sebastian
344
	  Rahtz at Oxford University Computing Services.</change>
345
	  </revisionDesc>
346
	  </xsl:if>
347
      [/comment]
348
    </teiHeader>
349
  </xsl:template>
350
  -->
351
  <xsl:template match="revisionDesc">
352
    <revisionDesc xmlns="http://www.tei-c.org/ns/1.0">
353
      <xsl:apply-templates select="@*|*|comment()|processing-instruction()"/>
354
    </revisionDesc>
355
  </xsl:template>
356

    
357
  <xsl:template match="publicationStmt">
358
    <publicationStmt xmlns="http://www.tei-c.org/ns/1.0">
359
      <xsl:apply-templates select="@*|*|comment()|processing-instruction()"/>
360
      <!--
361
	  <availability xmlns="http://www.tei-c.org/ns/1.0">
362
	  <p xmlns="http://www.tei-c.org/ns/1.0">Licensed under <ptr xmlns="http://www.tei-c.org/ns/1.0" target="http://creativecommons.org/licenses/by-sa/2.0/uk/"/></p>
363
	  </availability>
364
      -->
365
    </publicationStmt>
366
  </xsl:template>
367

    
368
  <!-- space does not have @extent any more -->
369
  <xsl:template match="space/@extent">
370
    <xsl:attribute name="quantity">
371
      <xsl:value-of select="."/>
372
    </xsl:attribute>
373
  </xsl:template>
374

    
375
  <!-- tagsDecl has a compulsory namespace child now -->
376
  <xsl:template match="tagsDecl">
377
    <xsl:if test="*">
378
      <tagsDecl xmlns="http://www.tei-c.org/ns/1.0">
379
        <namespace name="http://www.tei-c.org/ns/1.0">
380
          <xsl:apply-templates select="*|comment()|processing-instruction"/>
381
        </namespace>
382
      </tagsDecl>
383
    </xsl:if>
384
  </xsl:template>
385

    
386
  <!-- orgTitle inside orgName? redundant -->
387
  <xsl:template match="orgName/orgTitle">
388
    <xsl:apply-templates/>
389
  </xsl:template>
390

    
391
  <!-- no need for empty <p> in sourceDesc -->
392
  <xsl:template match="sourceDesc/p[string-length(.)=0]"/>
393

    
394
  <!-- start creating the new choice element -->
395
  <!-- corr & sic elements: BFM special treatment 
396
  <xsl:template match="corr[@sic]">
397
    <choice  xmlns="http://www.tei-c.org/ns/1.0">
398
      <corr  xmlns="http://www.tei-c.org/ns/1.0">
399
	<xsl:value-of select="text()" />
400
      </corr>
401
      <sic  xmlns="http://www.tei-c.org/ns/1.0">
402
	<xsl:value-of select="@sic" />
403
      </sic>
404
    </choice>
405
  </xsl:template>
406
  
407
  <xsl:template match="sic[@corr]">
408
    <choice  xmlns="http://www.tei-c.org/ns/1.0">
409
      <sic  xmlns="http://www.tei-c.org/ns/1.0">
410
	<xsl:value-of select="text()" />
411
      </sic>
412
      <corr  xmlns="http://www.tei-c.org/ns/1.0">
413
	<xsl:value-of select="@corr" />
414
      </corr>
415
    </choice>
416
  </xsl:template>
417
  -->
418
  <xsl:template match="abbr[@expan]">
419
    <choice xmlns="http://www.tei-c.org/ns/1.0">
420
      <abbr xmlns="http://www.tei-c.org/ns/1.0">
421
        <xsl:value-of select="text()"/>
422
      </abbr>
423
      <expan xmlns="http://www.tei-c.org/ns/1.0">
424
        <xsl:value-of select="@expan"/>
425
      </expan>
426
    </choice>
427
  </xsl:template>
428

    
429
  <xsl:template match="expan[@abbr]">
430
    <choice xmlns="http://www.tei-c.org/ns/1.0">
431
      <expan xmlns="http://www.tei-c.org/ns/1.0">
432
        <xsl:value-of select="text()"/>
433
      </expan>
434
      <abbr xmlns="http://www.tei-c.org/ns/1.0">
435
        <xsl:value-of select="@abbr"/>
436
      </abbr>
437
    </choice>
438
  </xsl:template>
439

    
440
  <!-- special consideration for <change> element -->
441
  <xsl:template match="change">
442
    <change xmlns="http://www.tei-c.org/ns/1.0">
443

    
444
      <xsl:apply-templates select="date"/>
445

    
446
      <xsl:if test="respStmt/resp">
447
        <label>
448
          <xsl:value-of select="respStmt/resp/text()"/>
449
        </label>
450
      </xsl:if>
451
      <xsl:for-each select="respStmt/name">
452
        <name xmlns="http://www.tei-c.org/ns/1.0">
453
          <xsl:apply-templates select="@*|*|comment()|processing-instruction()|text()"/>
454
        </name>
455
      </xsl:for-each>
456
      <xsl:for-each select="item">
457
        <xsl:apply-templates select="@*|*|comment()|processing-instruction()|text()"/>
458
      </xsl:for-each>
459
    </change>
460
  </xsl:template>
461

    
462

    
463
  <xsl:template match="respStmt[resp]">
464
    <respStmt xmlns="http://www.tei-c.org/ns/1.0">
465
      <xsl:choose>
466
        <xsl:when test="resp/name">
467
          <resp xmlns="http://www.tei-c.org/ns/1.0">
468
            <xsl:value-of select="resp/text()"/>
469
          </resp>
470
          <xsl:for-each select="resp/name">
471
            <name xmlns="http://www.tei-c.org/ns/1.0">
472
              <xsl:apply-templates/>
473
            </name>
474
          </xsl:for-each>
475
        </xsl:when>
476
        <xsl:otherwise>
477
          <xsl:apply-templates/>
478
          <name xmlns="http://www.tei-c.org/ns/1.0"> </name>
479
        </xsl:otherwise>
480
      </xsl:choose>
481
    </respStmt>
482
  </xsl:template>
483

    
484
  <xsl:template match="q/@direct"/>
485

    
486
  <xsl:template match="q">
487
    <q xmlns="http://www.tei-c.org/ns/1.0">
488
      <xsl:apply-templates select="@*|*|comment()|processing-instruction()|text()"/>
489
    </q>
490
  </xsl:template>
491

    
492

    
493
  <!-- if we are reading the P4 with a DTD,
494
       we need to avoid copying the default values
495
       of attributes -->
496

    
497
  <xsl:template match="@targOrder">
498
    <xsl:if test="not(translate(.,$uc,$lc) ='u')">
499
      <xsl:attribute name="targOrder">
500
        <xsl:value-of select="."/>
501
      </xsl:attribute>
502
    </xsl:if>
503
  </xsl:template>
504

    
505

    
506
  <xsl:template match="@opt">
507
    <xsl:if test="not(translate(.,$uc,$lc) ='n')">
508
      <xsl:attribute name="opt">
509
        <xsl:value-of select="."/>
510
      </xsl:attribute>
511
    </xsl:if>
512
  </xsl:template>
513

    
514

    
515
  <xsl:template match="@to">
516
    <xsl:if test="not(translate(.,$uc,$lc) ='ditto')">
517
      <xsl:attribute name="to">
518
        <xsl:value-of select="."/>
519
      </xsl:attribute>
520
    </xsl:if>
521
  </xsl:template>
522

    
523

    
524
  <xsl:template match="@default">
525
    <xsl:choose>
526
      <xsl:when test="translate(.,$uc,$lc)= 'no'"/>
527
      <xsl:otherwise>
528
        <xsl:attribute name="default">
529
          <xsl:value-of select="."/>
530
        </xsl:attribute>
531
      </xsl:otherwise>
532
    </xsl:choose>
533
  </xsl:template>
534

    
535

    
536
  <xsl:template match="@part">
537
    <xsl:if test="not(translate(.,$uc,$lc) ='n')">
538
      <xsl:attribute name="part">
539
        <xsl:value-of select="."/>
540
      </xsl:attribute>
541
    </xsl:if>
542
  </xsl:template>
543

    
544

    
545
  <xsl:template match="@full">
546
    <xsl:if test="not(translate(.,$uc,$lc) ='yes')">
547
      <xsl:attribute name="full">
548
        <xsl:value-of select="."/>
549
      </xsl:attribute>
550
    </xsl:if>
551
  </xsl:template>
552

    
553

    
554
  <xsl:template match="@from">
555
    <xsl:if test="not(translate(.,$uc,$lc) ='root')">
556
      <xsl:attribute name="from">
557
        <xsl:value-of select="."/>
558
      </xsl:attribute>
559
    </xsl:if>
560
  </xsl:template>
561

    
562

    
563
  <xsl:template match="@status">
564
    <xsl:choose>
565
      <xsl:when test="parent::teiHeader">
566
        <xsl:if test="not(translate(.,$uc,$lc) ='new')">
567
          <xsl:attribute name="status">
568
            <xsl:value-of select="."/>
569
          </xsl:attribute>
570
        </xsl:if>
571
      </xsl:when>
572
      <xsl:when test="parent::del">
573
        <xsl:if test="not(translate(.,$uc,$lc) ='unremarkable')">
574
          <xsl:attribute name="status">
575
            <xsl:value-of select="."/>
576
          </xsl:attribute>
577
        </xsl:if>
578
      </xsl:when>
579
      <xsl:otherwise>
580
        <xsl:attribute name="status">
581
          <xsl:value-of select="."/>
582
        </xsl:attribute>
583
      </xsl:otherwise>
584
    </xsl:choose>
585
  </xsl:template>
586

    
587

    
588
  <xsl:template match="@place">
589
    <xsl:if test="not(translate(.,$uc,$lc) ='unspecified')">
590
      <xsl:attribute name="place">
591
        <xsl:value-of select="."/>
592
      </xsl:attribute>
593
    </xsl:if>
594
  </xsl:template>
595

    
596

    
597
  <xsl:template match="@sample">
598
    <xsl:if test="not(translate(.,$uc,$lc) ='complete')">
599
      <xsl:attribute name="sample">
600
        <xsl:value-of select="."/>
601
      </xsl:attribute>
602
    </xsl:if>
603
  </xsl:template>
604

    
605

    
606
  <xsl:template match="@org">
607
    <xsl:if test="not(translate(.,$uc,$lc) ='uniform')">
608
      <xsl:attribute name="org">
609
        <xsl:value-of select="."/>
610
      </xsl:attribute>
611
    </xsl:if>
612
  </xsl:template>
613

    
614
  <xsl:template match="teiHeader/@type">
615
    <xsl:if test="not(translate(.,$uc,$lc) ='text')">
616
      <xsl:attribute name="type">
617
        <xsl:value-of select="."/>
618
      </xsl:attribute>
619
    </xsl:if>
620
  </xsl:template>
621

    
622
  <!-- yes|no to boolean -->
623

    
624
  <xsl:template match="@anchored">
625
    <xsl:attribute name="anchored">
626
      <xsl:choose>
627
        <xsl:when test="translate(.,$uc,$lc)='yes'">true</xsl:when>
628
        <xsl:when test="translate(.,$uc,$lc)='no'">false</xsl:when>
629
      </xsl:choose>
630
    </xsl:attribute>
631
  </xsl:template>
632

    
633
  <xsl:template match="sourceDesc/@default"/>
634

    
635
  <xsl:template match="@tei">
636
    <xsl:attribute name="tei">
637
      <xsl:choose>
638
        <xsl:when test="translate(.,$uc,$lc)='yes'">true</xsl:when>
639
        <xsl:when test="translate(.,$uc,$lc)='no'">false</xsl:when>
640
      </xsl:choose>
641
    </xsl:attribute>
642
  </xsl:template>
643

    
644
  <xsl:template match="@langKey"/>
645

    
646
  <xsl:template match="@TEIform"/>
647

    
648
  <!-- assorted atts -->
649
  <xsl:template match="@old"/>
650

    
651
  <xsl:template match="@mergedin">
652
    <xsl:attribute name="mergedIn">
653
      <xsl:value-of select="."/>
654
    </xsl:attribute>
655
  </xsl:template>
656

    
657
  <!-- deal with the loss of div0 -->
658

    
659
  <xsl:template match="div1|div2|div3|div4|div5|div6">
660
    <xsl:variable name="divName">
661
      <xsl:choose>
662
        <xsl:when test="ancestor::div0">
663
          <xsl:text>div</xsl:text>
664
          <xsl:value-of select="number(substring-after(local-name(.),'div')) + 1"/>
665
        </xsl:when>
666
        <xsl:otherwise>
667
          <xsl:value-of select="local-name()"/>
668
        </xsl:otherwise>
669
      </xsl:choose>
670
    </xsl:variable>
671
    <xsl:element name="{$divName}" namespace="http://www.tei-c.org/ns/1.0">
672
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
673
    </xsl:element>
674
  </xsl:template>
675

    
676
  <xsl:template match="div0">
677
    <div1 xmlns="http://www.tei-c.org/ns/1.0">
678
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
679
    </div1>
680
  </xsl:template>
681
  
682
 <xsl:template match="l">
683
   <xsl:apply-templates/>
684
 </xsl:template>
685
  
686
  <xsl:template match="lb">
687
    <xsl:text>&#xA;</xsl:text>
688
    <lb xmlns="http://www.tei-c.org/ns/1.0">
689
      <xsl:apply-templates select="@*"></xsl:apply-templates>
690
    </lb>
691
  </xsl:template>
692
  
693
  <xsl:template match="sp[child::l]">
694
    <sp xmlns="http://www.tei-c.org/ns/1.0">
695
      <xsl:apply-templates select="@*"/>
696
      <xsl:text>&#xA;</xsl:text>
697
      <xsl:apply-templates select="speaker"/>
698
      <xsl:text>&#xA;</xsl:text>
699
      <ab><xsl:apply-templates select="l|lb"/></ab>
700
    </sp>
701
  </xsl:template>
702

    
703
<!--
704
  <!-\- BFM specific -\->
705

    
706
  <xsl:template match="p[@rend]">
707
    <ab xmlns="http://www.tei-c.org/ns/1.0">
708
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
709
    </ab>
710
  </xsl:template>
711

    
712
  <!-\- reducing header -\->
713
  <xsl:template match="teiHeader">
714
    <teiHeader xmlns="http://www.tei-c.org/ns/1.0">
715
      <xsl:apply-templates select="fileDesc"/>
716
    </teiHeader>
717
  </xsl:template>
718

    
719
  <xsl:template match="fileDesc">
720
    <fileDesc xmlns="http://www.tei-c.org/ns/1.0">
721
      <xsl:apply-templates select="titleStmt"/>
722
      <publicationStmt xmlns="http://www.tei-c.org/ns/1.0"><p xmlns="http://www.tei-c.org/ns/1.0"></p></publicationStmt><sourceDesc xmlns="http://www.tei-c.org/ns/1.0"><p xmlns="http://www.tei-c.org/ns/1.0"></p></sourceDesc>
723
    </fileDesc>
724
  </xsl:template>
725
  
726
  <xsl:template match="titleStmt">
727
    <titleStmt xmlns="http://www.tei-c.org/ns/1.0">
728
      <xsl:choose>
729
        <xsl:when test="descendant::title[@type='normal']">
730
          <xsl:apply-templates select="title[@type='normal']|author"/>
731
        </xsl:when>
732
        <xsl:otherwise>
733
          <title xmlns="http://www.tei-c.org/ns/1.0"><xsl:value-of select="descendant::title[1]"/></title>
734
        </xsl:otherwise>
735
      </xsl:choose>
736
      
737
    </titleStmt>
738
  </xsl:template>
739
  
740

    
741
  <xsl:template name="corr-crochets">
742
    <xsl:value-of select="substring-before(@rend,'[')"/>
743
    <xsl:element name="supplied" namespace="http://www.tei-c.org/ns/1.0">
744
      <xsl:if test="string-length(@sic) &gt; 0">
745
        <xsl:attribute name="rend">word_part</xsl:attribute>
746
      </xsl:if>
747
      <xsl:value-of select="substring-before(substring-after(@rend,'['),']')"/>
748
    </xsl:element>
749
    <xsl:value-of select="substring-after(@rend,']')"/>
750
  </xsl:template>
751

    
752
  <xsl:template match="corr[@sic]">
753
    <choice xmlns="http://www.tei-c.org/ns/1.0">
754
      <xsl:element name="corr" namespace="http://www.tei-c.org/ns/1.0">
755
        <xsl:if test="@resp">
756
          <xsl:attribute name="resp">
757
            <xsl:value-of select="@resp"/>
758
          </xsl:attribute>
759
        </xsl:if>
760
        <xsl:if test="@rend[not(contains(.,'crochets')) and not(contains(.,'['))]">
761
          <xsl:attribute name="rend">
762
            <xsl:value-of select="@rend"/>
763
          </xsl:attribute>
764
        </xsl:if>
765
        <xsl:choose>
766
          <xsl:when test="contains(@rend,'[') and contains(@rend,']')">
767
            <xsl:choose>
768
              <xsl:when test="child::w">
769
                <xsl:text>&#xA;</xsl:text>
770
                <xsl:element name="w" namespace="http://www.tei-c.org/ns/1.0">
771
                  <xsl:call-template name="corr-crochets"/>
772
                </xsl:element>
773
                <xsl:text>&#xA;</xsl:text>
774
              </xsl:when>
775
              <xsl:otherwise>
776
                <xsl:call-template name="corr-crochets"/>
777
              </xsl:otherwise>
778
            </xsl:choose>
779
          </xsl:when>
780
          <xsl:when test="string-length(@sic) = 0">
781
            <xsl:element name="supplied" namespace="http://www.tei-c.org/ns/1.0">
782
              <xsl:apply-templates select="@resp|@rend|*|text()"/>
783
            </xsl:element>
784
          </xsl:when>
785
          <xsl:otherwise>
786
            <xsl:apply-templates select="@resp|@rend|*|text()"/>
787
          </xsl:otherwise>
788
        </xsl:choose>
789
      </xsl:element>
790
      <xsl:element name="sic" namespace="http://www.tei-c.org/ns/1.0">
791
        <xsl:value-of select="@sic"/>
792
      </xsl:element>
793
    </choice>
794
  </xsl:template>
795

    
796
  <xsl:template match="sic[@corr]">
797
    <choice xmlns="http://www.tei-c.org/ns/1.0">
798
      <xsl:element name="corr" namespace="http://www.tei-c.org/ns/1.0">
799
        <xsl:if test="@resp">
800
          <xsl:attribute name="resp">
801
            <xsl:value-of select="@resp"/>
802
          </xsl:attribute>
803
        </xsl:if>
804
        <xsl:if test="@rend[not(contains(.,'crochets')) and not(contains(.,'['))]">
805
          <xsl:attribute name="rend">
806
            <xsl:value-of select="@rend"/>
807
          </xsl:attribute>
808
        </xsl:if>
809
        <xsl:choose>
810
          <xsl:when test="contains(@rend,'[') and contains(@rend,']')">
811
            <xsl:choose>
812
              <xsl:when test="child::w">
813
                <xsl:text>&#xA;</xsl:text>
814
                <xsl:element name="w" namespace="http://www.tei-c.org/ns/1.0">
815
                  <xsl:call-template name="corr-crochets"/>
816
                </xsl:element>
817
                <xsl:text>&#xA;</xsl:text>
818
              </xsl:when>
819
              <xsl:otherwise>
820
                <xsl:call-template name="corr-crochets"/>
821
              </xsl:otherwise>
822
            </xsl:choose>
823
          </xsl:when>
824
          <xsl:when test="string-length(.) = 0">
825
            <xsl:element name="supplied" namespace="http://www.tei-c.org/ns/1.0">
826
              <xsl:apply-templates select="@resp|@rend|*|text()"/>
827
            </xsl:element>
828
          </xsl:when>
829
          <xsl:otherwise>
830
            <xsl:apply-templates select="@resp|@rend"/>
831
            <xsl:value-of select="@corr"/>
832
          </xsl:otherwise>
833
        </xsl:choose>
834
      </xsl:element>
835
      <xsl:element name="sic" namespace="http://www.tei-c.org/ns/1.0">
836
        <xsl:apply-templates/>
837
      </xsl:element>
838
    </choice>
839
  </xsl:template>
840

    
841

    
842
-->
843
</xsl:stylesheet>