Revision 729

tmp/trunk/org.txm.setups/shared/all/xsl/svn2cl.xsl (revision 729)
1
<?xml version="1.0" encoding="utf-8"?>
2

  
3
<!--
4
	USAGE:
5
	svn log --xml --verbose > foo.txt
6
	xsltproc etc/svn2cl.xsl foo.txt > ChangeLog
7

  
8

  
9
   svn2cl.xsl - xslt stylesheet for converting svn log to a normal
10
                changelog
11

  
12
   version 0.11
13

  
14
   Usage (replace ++ with two minus signs which aren't allowed
15
   inside xml comments):
16
     svn ++verbose ++xml log | \
17
       xsltproc ++stringparam strip-prefix `basename $(pwd)` \
18
                ++stringparam linelen 75 \
19
                ++stringparam groupbyday yes \
20
                ++stringparam separate-daylogs yes \
21
                ++stringparam include-rev yes \
22
                ++stringparam include-actions yes \
23
                ++stringparam breakbeforemsg yes/2 \
24
                ++stringparam reparagraph yes \
25
                ++stringparam authorsfile FILE \
26
                ++stringparam ignore-message-starting \
27
                svn2cl.xsl - > ChangeLog
28

  
29
   This file is based on several implementations of this conversion
30
   that I was not completely happy with and some other common
31
   xslt constructs found on the web.
32

  
33
   Copyright (C) 2004, 2005, 2006, 2007 Arthur de Jong.
34

  
35
   Redistribution and use in source and binary forms, with or without
36
   modification, are permitted provided that the following conditions
37
   are met:
38
   1. Redistributions of source code must retain the above copyright
39
      notice, this list of conditions and the following disclaimer.
40
   2. Redistributions in binary form must reproduce the above copyright
41
      notice, this list of conditions and the following disclaimer in
42
      the documentation and/or other materials provided with the
43
      distribution.
44
   3. The name of the author may not be used to endorse or promote
45
      products derived from this software without specific prior
46
      written permission.
47

  
48
   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
49
   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51
   ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
52
   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53
   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
54
   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
55
   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
56
   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
57
   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
58
   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59

  
60
-->
61

  
62
<!DOCTYPE xsl:stylesheet [
63
 <!ENTITY tab "&#9;">
64
 <!ENTITY newl "&#38;#xA;">
65
 <!ENTITY space "&#32;">
66
]>
67

  
68
<xsl:stylesheet
69
  version="1.0"
70
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
71

  
72
 <xsl:output
73
   method="text"
74
   encoding="utf-8"
75
   media-type="text/plain"
76
   omit-xml-declaration="yes"
77
   standalone="yes"
78
   indent="no" />
79

  
80
 <xsl:strip-space elements="*" />
81

  
82
 <!-- the prefix of pathnames to strip -->
83
 <xsl:param name="strip-prefix" select="'/'" />
84

  
85
 <!-- the length of a line to wrap messages at -->
86
 <xsl:param name="linelen" select="75" />
87

  
88
 <!-- whether entries should be grouped by day -->
89
 <xsl:param name="groupbyday" select="'no'" />
90

  
91
 <!-- whether to seperate log messages by empty lines -->
92
 <xsl:param name="separate-daylogs" select="'no'" />
93

  
94
 <!-- whether a revision number should be included -->
95
 <xsl:param name="include-rev" select="'no'" />
96

  
97
 <!-- whether aaction labels should be added to files -->
98
 <xsl:param name="include-actions" select="'no'" />
99

  
100
 <!-- whether the log message should start on a new line -->
101
 <xsl:param name="breakbeforemsg" select="'no'" />
102

  
103
 <!-- whether the message should be rewrapped within one paragraph -->
104
 <xsl:param name="reparagraph" select="'no'" />
105

  
106
 <!-- whether certain messages should be ignored -->
107
 <xsl:param name="ignore-message-starting" select="''" />
108

  
109
 <!-- location of authors file if any -->
110
 <xsl:param name="authorsfile" select="''" />
111
 <xsl:key name="author-lookup" match="author" use="@uid" />
112
 <xsl:variable name="authors-top" select="document($authorsfile)/authors" />
113

  
114
 <!-- match the topmost log entry -->
115
 <xsl:template match="log">
116
  <xsl:choose>
117
   <xsl:when test="$ignore-message-starting != ''">
118
    <!-- only handle logentries with don't contain the string -->
119
    <xsl:apply-templates select="logentry[not(starts-with(msg,$ignore-message-starting))]" />
120
   </xsl:when>
121
   <xsl:otherwise>
122
    <xsl:apply-templates select="logentry" />
123
   </xsl:otherwise>
124
  </xsl:choose>
125
  <!-- add newlines at the end of the changelog -->
126
  <xsl:text>&newl;</xsl:text>
127
 </xsl:template>
128

  
129
 <!-- format one entry from the log -->
130
 <xsl:template match="logentry">
131
  <xsl:choose>
132
   <!-- if we're grouping we should omit some headers -->
133
   <xsl:when test="$groupbyday='yes'">
134
    <!-- save log entry number -->
135
    <xsl:variable name="pos" select="position()" />
136
    <!-- fetch previous entry's date -->
137
    <xsl:variable name="prevdate">
138
     <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date" />
139
    </xsl:variable>
140
    <!-- fetch previous entry's author -->
141
    <xsl:variable name="prevauthor">
142
     <xsl:value-of select="normalize-space(../logentry[position()=(($pos)-1)]/author)" />
143
    </xsl:variable>
144
    <!-- fetch this entry's date -->
145
    <xsl:variable name="date">
146
     <xsl:apply-templates select="date" />
147
    </xsl:variable>
148
    <!-- fetch this entry's author -->
149
    <xsl:variable name="author">
150
     <xsl:value-of select="normalize-space(author)" />
151
    </xsl:variable>
152
    <!-- check if header is changed -->
153
    <xsl:if test="($prevdate!=$date) or ($prevauthor!=$author)">
154
     <!-- add newline -->
155
     <xsl:if test="not(position()=1)">
156
      <xsl:text>&newl;</xsl:text>
157
     </xsl:if>
158
     <!-- date -->
159
     <xsl:value-of select="$date" />
160
     <!-- two spaces -->
161
     <xsl:text>&space;&space;</xsl:text>
162
     <!-- author's name -->
163
     <xsl:apply-templates select="author" />
164
     <!-- two newlines -->
165
     <xsl:text>&newl;</xsl:text>
166
     <xsl:if test="$separate-daylogs!='yes'"><xsl:text>&newl;</xsl:text></xsl:if>
167
    </xsl:if>
168
   </xsl:when>
169
   <!-- write the log header -->
170
   <xsl:otherwise>
171
    <!-- add newline -->
172
    <xsl:if test="not(position()=1)">
173
     <xsl:text>&newl;</xsl:text>
174
    </xsl:if>
175
    <!-- date -->
176
    <xsl:apply-templates select="date" />
177
    <!-- two spaces -->
178
    <xsl:text>&space;&space;</xsl:text>
179
    <!-- author's name -->
180
    <xsl:apply-templates select="author" />
181
    <!-- two newlines -->
182
    <xsl:text>&newl;&newl;</xsl:text>
183
   </xsl:otherwise>
184
  </xsl:choose>
185
  <!-- get paths string -->
186
  <xsl:variable name="paths">
187
   <xsl:apply-templates select="paths" />
188
  </xsl:variable>
189
  <!-- get revision number -->
190
  <xsl:variable name="rev">
191
   <xsl:if test="$include-rev='yes'">
192
    <xsl:text>[r</xsl:text>
193
    <xsl:value-of select="@revision" />
194
    <xsl:text>]&space;</xsl:text>
195
   </xsl:if>
196
  </xsl:variable>
197
  <!-- trim trailing newlines -->
198
  <xsl:variable name="msg">
199
   <!-- add a line break before the log message -->
200
   <xsl:choose>
201
    <xsl:when test="$breakbeforemsg='yes'">
202
     <xsl:text>&newl;</xsl:text>
203
    </xsl:when>
204
    <xsl:when test="number($breakbeforemsg)&gt;0">
205
     <xsl:call-template name="newlines">
206
      <xsl:with-param name="count" select="number($breakbeforemsg)" />
207
     </xsl:call-template>
208
    </xsl:when>
209
   </xsl:choose>
210
   <xsl:call-template name="trim-newln">
211
    <xsl:with-param name="txt" select="msg" />
212
   </xsl:call-template>
213
  </xsl:variable>
214
  <!-- add newline here if separate-daylogs is in effect -->
215
  <xsl:if test="$groupbyday='yes' and $separate-daylogs='yes'"><xsl:text>&newl;</xsl:text></xsl:if>
216
  <!-- first line is indented (other indents are done in wrap template) -->
217
  <xsl:text>&tab;*&space;</xsl:text>
218
  <!-- set up the text to wrap -->
219
  <xsl:variable name="txt">
220
   <xsl:value-of select="$rev" />
221
   <xsl:if test="$paths!=''">
222
    <xsl:value-of select="concat($paths,':&space;')" />
223
   </xsl:if>
224
   <xsl:value-of select="$msg" />
225
  </xsl:variable>
226
  <!-- print the paths and message nicely wrapped -->
227
  <xsl:call-template name="wrap">
228
   <xsl:with-param name="txt" select="$txt" />
229
  </xsl:call-template>
230
 </xsl:template>
231

  
232
 <!-- format date -->
233
 <xsl:template match="date">
234
  <xsl:variable name="date" select="normalize-space(.)" />
235
  <!-- output date part -->
236
  <xsl:value-of select="substring($date,1,10)" />
237
  <!-- output time part -->
238
  <xsl:if test="$groupbyday!='yes'">
239
   <xsl:text>&space;</xsl:text>
240
   <xsl:value-of select="substring($date,12,5)" />
241
  </xsl:if>
242
 </xsl:template>
243

  
244
 <!-- format author -->
245
 <xsl:template match="author">
246
  <xsl:variable name="uid" select="normalize-space(.)" />
247
  <!-- try to lookup author in authorsfile -->
248
  <xsl:choose>
249
   <xsl:when test="$authorsfile!=''">
250
    <xsl:for-each select="$authors-top">
251
     <xsl:variable name="author" select="key('author-lookup',$uid)" />
252
     <!-- present result -->
253
     <xsl:choose>
254
      <xsl:when test="string($author/.)">
255
       <xsl:apply-templates select="$author/node()" mode="copy" />
256
      </xsl:when>
257
      <xsl:otherwise>
258
       <xsl:value-of select="$uid" />
259
      </xsl:otherwise>
260
     </xsl:choose>
261
    </xsl:for-each>
262
   </xsl:when>
263
   <xsl:otherwise>
264
    <xsl:value-of select="$uid" />
265
   </xsl:otherwise>
266
  </xsl:choose>
267
 </xsl:template>
268

  
269
 <!-- copy but normalize text -->
270
 <xsl:template match="text()" mode="copy">
271
  <xsl:value-of select="normalize-space(.)" />
272
 </xsl:template>
273

  
274
 <!-- simple copy template -->
275
 <xsl:template match="@*|node()" mode="copy">
276
  <xsl:copy>
277
   <xsl:apply-templates select="@*|node()" mode="copy" />
278
  </xsl:copy>
279
 </xsl:template>
280

  
281
 <!-- present a list of paths names -->
282
 <xsl:template match="paths">
283
  <xsl:choose>
284
   <!-- only handle paths that begin with the path and strip the path -->
285
   <xsl:when test="$strip-prefix != ''">
286
    <!-- if strip-prefix does not start with a slash, prepend it -->
287
    <xsl:variable name="tmpstrip1">
288
     <xsl:choose>
289
      <xsl:when test="starts-with($strip-prefix,'/')">
290
       <xsl:value-of select="$strip-prefix" />
291
      </xsl:when>
292
      <xsl:otherwise>
293
       <xsl:value-of select="concat('/',$strip-prefix)" />
294
      </xsl:otherwise>
295
     </xsl:choose>
296
    </xsl:variable>
297
    <!-- strip trailing slash from strip-prefix -->
298
    <xsl:variable name="tmpstrip2">
299
     <xsl:choose>
300
      <xsl:when test="substring($tmpstrip1,string-length($tmpstrip1),1)='/'">
301
       <xsl:value-of select="substring($tmpstrip1,1,string-length($tmpstrip1)-1)" />
302
      </xsl:when>
303
      <xsl:otherwise>
304
       <xsl:value-of select="$tmpstrip1" />
305
      </xsl:otherwise>
306
     </xsl:choose>
307
    </xsl:variable>
308
    <!-- filter on all entries within directory -->
309
    <xsl:for-each select="path[starts-with(concat(normalize-space(.),'/'),concat($tmpstrip2,'/'))]">
310
     <xsl:sort select="normalize-space(.)" data-type="text" />
311
     <!-- unless we are the first entry, add a comma -->
312
     <xsl:if test="not(position()=1)">
313
      <xsl:text>,&space;</xsl:text>
314
     </xsl:if>
315
     <!-- print the path name -->
316
     <xsl:call-template name="printpath">
317
      <xsl:with-param name="path" select="substring(normalize-space(.),string-length($strip-prefix)+3)" />
318
     </xsl:call-template>
319
     <!-- add the action flag -->
320
     <xsl:if test="$include-actions='yes'">
321
      <xsl:apply-templates select="." mode="action"/>
322
     </xsl:if>
323
    </xsl:for-each>
324
   </xsl:when>
325
   <!-- print a simple list of all paths -->
326
   <xsl:otherwise>
327
    <xsl:for-each select="path">
328
     <xsl:sort select="normalize-space(.)" data-type="text" />
329
     <!-- unless we are the first entry, add a comma -->
330
     <xsl:if test="not(position()=1)">
331
      <xsl:text>,&space;</xsl:text>
332
     </xsl:if>
333
     <!-- print the path name -->
334
     <xsl:value-of select="normalize-space(.)" />
335
     <!-- add the action flag -->
336
     <xsl:if test="$include-actions='yes'">
337
      <xsl:apply-templates select="." mode="action"/>
338
     </xsl:if>
339
    </xsl:for-each>
340
   </xsl:otherwise>
341
  </xsl:choose>
342
 </xsl:template>
343

  
344
 <xsl:template match="path" mode="action">
345
  <xsl:choose>
346
   <xsl:when test="@action='D'">
347
    <xsl:text>[DEL]</xsl:text>
348
   </xsl:when>
349
   <xsl:when test="@copyfrom-path">
350
    <xsl:text>[CPY]</xsl:text>
351
   </xsl:when>
352
   <xsl:when test="@action='D'">
353
    <xsl:text>[ADD]</xsl:text>
354
   </xsl:when>
355
  </xsl:choose>
356
 </xsl:template>
357

  
358
 <!-- transform path to something printable -->
359
 <xsl:template name="printpath">
360
  <!-- fetch the pathname -->
361
  <xsl:param name="path" />
362
  <!-- strip leading slash -->
363
  <xsl:variable name="tmp1">
364
   <xsl:choose>
365
    <xsl:when test="starts-with($path,'/')">
366
     <xsl:value-of select="substring($path,2)" />
367
    </xsl:when>
368
    <xsl:otherwise>
369
     <xsl:value-of select="$path" />
370
    </xsl:otherwise>
371
   </xsl:choose>
372
  </xsl:variable>
373
  <!-- translate empty string to dot -->
374
  <xsl:choose>
375
   <xsl:when test="$tmp1 = ''">
376
    <xsl:text>.</xsl:text>
377
   </xsl:when>
378
   <xsl:otherwise>
379
    <xsl:value-of select="$tmp1" />
380
   </xsl:otherwise>
381
  </xsl:choose>
382
 </xsl:template>
383

  
384
 <!-- string-wrapping template -->
385
 <xsl:template name="wrap">
386
  <xsl:param name="txt" />
387
  <xsl:variable name="normtxt" select="normalize-space($txt)" />
388
  <xsl:choose>
389
   <xsl:when test="contains($txt,'&newl;')">
390
     <!-- text contains newlines, do the first line -->
391
     <xsl:call-template name="wrap">
392
      <xsl:with-param name="txt" select="substring-before($txt,'&newl;')" />
393
     </xsl:call-template>
394
     <!-- print tab -->
395
     <xsl:text>&tab;&space;&space;</xsl:text>
396
     <!-- wrap the rest of the text -->
397
     <xsl:call-template name="wrap">
398
      <xsl:with-param name="txt" select="substring-after($txt,'&newl;')" />
399
     </xsl:call-template>
400
   </xsl:when>
401
   <xsl:when test="(string-length($normtxt) &lt; (($linelen)-9)) or not(contains($normtxt,' '))">
402
    <!-- this is easy, nothing to do -->
403
    <xsl:value-of select="$normtxt" />
404
    <!-- add newline -->
405
    <xsl:text>&newl;</xsl:text>
406
   </xsl:when>
407
   <xsl:otherwise>
408
    <!-- find the first line -->
409
    <xsl:variable name="tmp" select="substring($normtxt,1,(($linelen)-9))" />
410
    <xsl:variable name="line">
411
     <xsl:choose>
412
      <!-- if our attempt contains spaces wrap on that -->
413
      <xsl:when test="contains($tmp,' ')">
414
       <xsl:call-template name="find-line">
415
        <xsl:with-param name="txt" select="$tmp" />
416
       </xsl:call-template>
417
      </xsl:when>
418
      <!-- otherwise use the first non-space characters from the text -->
419
      <xsl:otherwise>
420
       <xsl:value-of select="substring-before($normtxt,' ')" />
421
      </xsl:otherwise>
422
     </xsl:choose>
423
    </xsl:variable>
424
    <!-- print line -->
425
    <xsl:value-of select="$line" />
426
    <!-- print newline and tab -->
427
    <xsl:text>&newl;&tab;&space;&space;</xsl:text>
428
    <!-- wrap the rest of the text -->
429
    <xsl:call-template name="wrap">
430
     <xsl:with-param name="txt" select="normalize-space(substring($normtxt,string-length($line)+1))" />
431
    </xsl:call-template>
432
   </xsl:otherwise>
433
  </xsl:choose>
434
 </xsl:template>
435

  
436
 <!-- template to trim line to contain space as last char -->
437
 <xsl:template name="find-line">
438
  <xsl:param name="txt" />
439
  <xsl:choose>
440
   <xsl:when test="substring($txt,string-length($txt),1)=' '">
441
    <xsl:value-of select="substring($txt,1,string-length($txt)-1)" />
442
   </xsl:when>
443
   <xsl:otherwise>
444
    <xsl:call-template name="find-line">
445
     <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" />
446
    </xsl:call-template>
447
   </xsl:otherwise>
448
  </xsl:choose>
449
 </xsl:template>
450

  
451
 <!-- template to trim trailing and starting newlines -->
452
 <xsl:template name="trim-newln">
453
  <xsl:param name="txt" />
454
  <xsl:choose>
455
   <!-- find starting newlines -->
456
   <xsl:when test="substring($txt,1,1) = '&newl;'">
457
    <xsl:call-template name="trim-newln">
458
     <xsl:with-param name="txt" select="substring($txt,2)" />
459
    </xsl:call-template>
460
   </xsl:when>
461
   <!-- find trailing newlines -->
462
   <xsl:when test="substring($txt,string-length($txt),1) = '&newl;'">
463
    <xsl:call-template name="trim-newln">
464
     <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" />
465
    </xsl:call-template>
466
   </xsl:when>
467
   <!-- if the message has paragrapgs, find the first one -->
468
   <xsl:when test="$reparagraph='yes' and contains($txt,'&newl;&newl;')">
469
     <!-- remove newlines from first paragraph -->
470
     <xsl:value-of select="normalize-space(substring-before($txt,'&newl;&newl;'))" />
471
     <!-- paragraph separator -->
472
     <xsl:text>&newl;&newl;</xsl:text>
473
     <!-- do the rest of the text -->
474
     <xsl:call-template name="trim-newln">
475
      <xsl:with-param name="txt" select="substring-after($txt,'&newl;&newl;')" />
476
     </xsl:call-template>
477
   </xsl:when>
478
   <!-- remove more single newlines -->
479
   <xsl:when test="$reparagraph='yes'">
480
    <xsl:value-of select="normalize-space($txt)" />
481
   </xsl:when>
482
   <!-- no newlines found, we're done -->
483
   <xsl:otherwise>
484
    <xsl:value-of select="$txt" />
485
   </xsl:otherwise>
486
  </xsl:choose>
487
 </xsl:template>
488

  
489
 <!-- insert a number of newlines -->
490
 <xsl:template name="newlines">
491
  <xsl:param name="count" />
492
  <xsl:text>&newl;</xsl:text>
493
  <xsl:if test="$count&gt;1">
494
   <xsl:call-template name="newlines">
495
    <xsl:with-param name="count" select="($count)-1" />
496
   </xsl:call-template>
497
  </xsl:if>
498
 </xsl:template>
499

  
500
</xsl:stylesheet>
tmp/trunk/org.txm.setups/shared/all/xsl/txm-filter-teifrantext-xmlw.xsl (revision 729)
1
<?xml version="1.0"?>
2
<xsl:stylesheet
3
  xmlns:xd="http://www.pnp-software.com/XSLTdoc"
4
  xmlns:edate="http://exslt.org/dates-and-times"
5
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tei="http://www.tei-c.org/ns/1.0"
6
  exclude-result-prefixes="tei edate xd" version="2.0">
7
  
8
  <xsl:import href="txm-filter-teip5-xmlw-preserve.xsl"/>
9
  
10
  <xd:doc type="stylesheet">
11
    <xd:short>
12
      Feuille de style de préparation des fichiers TEI de la Revue
13
      Discours à l'importation TXM dans un format xml simple. 
14
    </xd:short>
15
    <xd:detail>
16
      This stylesheet is free software; you can redistribute it and/or
17
      modify it under the terms of the GNU Lesser General Public
18
      License as published by the Free Software Foundation; either
19
      version 3 of the License, or (at your option) any later version.
20
      
21
      This stylesheet is distributed in the hope that it will be useful,
22
      but WITHOUT ANY WARRANTY; without even the implied warranty of
23
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24
      Lesser General Public License for more details.
25
      
26
      You should have received a copy of GNU Lesser Public License with
27
      this stylesheet. If not, see http://www.gnu.org/licenses/lgpl.html
28
    </xd:detail>
29
    <xd:author>Alexei Lavrentiev alexei.lavrentev@ens-lyon.fr</xd:author>
30
    <xd:copyright>2012, CNRS / ICAR (ICAR3 LinCoBaTO)</xd:copyright>
31
  </xd:doc>
32
  
33
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/>
34

  
35
  <!--<xsl:variable name="langue"><xsl:value-of select="lower-case(//tei:teiHeader[1]/tei:profileDesc[1]/tei:langUsage[1]/tei:language[1])"/></xsl:variable>-->
36

  
37
<!-- On injecte les mots clés dans la langue de l'article et on ne garde que l'abstract dans la langue de l'article -->
38
  
39
  <xsl:template match="text()">
40
    <xsl:analyze-string select="." regex="&amp;lt;|&amp;gt;|&amp;|&lt;|&gt;|--|\*(\w+)">
41
      <xsl:matching-substring>
42
        <xsl:choose>
43
          <xsl:when test="matches(.,'&amp;lt;')">
44
            <xsl:text>‹</xsl:text>
45
          </xsl:when>
46
          <xsl:when test="matches(.,'&amp;gt;')">
47
            <xsl:text>›</xsl:text>
48
          </xsl:when>
49
          <!--          <xsl:when test="matches(.,'&amp;')">
50
            <!-\-<expan xmlns="http://www.tei-c.org/ns/1.0">and</expan>-\->
51
          	<xsl:text>&amp;amp;</xsl:text>
52
          </xsl:when>-->
53
          <xsl:when test="matches(.,'&lt;')">
54
            <xsl:text>‹</xsl:text>
55
          </xsl:when>
56
          <xsl:when test="matches(.,'&gt;')">
57
            <xsl:text>›</xsl:text>
58
          </xsl:when>
59
          <!-- pose problème si se trouve dans les notes transformés en commentaires xml par le tokeniseur -->
60
          <xsl:when test="matches(.,'--')">
61
            <xsl:text> - </xsl:text>
62
          </xsl:when>
63
          <!-- spécial Frantext!!! -->
64
          <xsl:when test="matches(.,'\*(\w+)')">
65
            <w xmlns="http://www.tei-c.org/ns/1.0" type="maj"><xsl:value-of select="regex-group(1)"/></w>
66
          </xsl:when>
67
          <xsl:otherwise>
68
            <xsl:value-of select="."/>
69
          </xsl:otherwise>
70
        </xsl:choose>
71
      </xsl:matching-substring>
72
      <xsl:non-matching-substring>         
73
        <xsl:value-of select="."/>
74
      </xsl:non-matching-substring>      
75
    </xsl:analyze-string>
76
  </xsl:template>
77
  
78
  <xsl:template match="tei:text">
79
    <xsl:copy>
80
      <xsl:apply-templates/>
81
    </xsl:copy>
82
  </xsl:template>
83
  
84
<xsl:template match="tei:div">
85
  <xsl:copy>
86
    <xsl:attribute name="n"><xsl:value-of select="count(preceding-sibling::tei:div) + 1"/></xsl:attribute>
87
    <xsl:apply-templates select="@*"/>
88
    <xsl:apply-templates/>
89
  </xsl:copy>
90
</xsl:template>
91
  
92
</xsl:stylesheet>
tmp/trunk/org.txm.setups/shared/all/xsl/txm-filter-corpusakkadien-xmlw_syllabes.xsl (revision 729)
1
<?xml version="1.0"?>
2
<xsl:stylesheet
3
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
  xmlns:xd="http://www.pnp-software.com/XSLTdoc"
5
 version="2.0">
6
  
7
  <xd:doc type="stylesheet">
8
    <xd:short>
9
      Cette feuille de style permet de préparer les transcriptions de tablettes
10
      d'argile (projet UMR PROCLAC) à l'import XML/W + CSV de TXM en tokenisant
11
      le corpus au niveau des syllabes.
12
      Les propriétés de mots sont projetées vers les propriétés des syllabes (line,
13
      lemma, pos).
14
      Les propriétés unclear et supplied prennent la valeur "yes" si la syllabe se
15
      trouve à l'intérieur de la balise correspondante.
16
    </xd:short>
17
    <xd:detail>
18
      This stylesheet is free software; you can redistribute it and/or
19
      modify it under the terms of the GNU Lesser General Public
20
      License as published by the Free Software Foundation; either
21
      version 3 of the License, or (at your option) any later version.
22
      
23
      This stylesheet is distributed in the hope that it will be useful,
24
      but WITHOUT ANY WARRANTY; without even the implied warranty of
25
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26
      Lesser General Public License for more details.
27
      
28
      You should have received a copy of GNU Lesser Public License with
29
      this stylesheet. If not, see http://www.gnu.org/licenses/lgpl.html
30
    </xd:detail>
31
    <xd:author>Alexei Lavrentiev, alexei.lavrentev@ens-lyon.fr</xd:author>
32
    <xd:copyright>2014-2015, CNRS / ICAR (équipe CACTUS)</xd:copyright>
33
  </xd:doc>
34
  
35
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/>
36
  
37
  <xsl:template match="*">
38
  	<xsl:copy>
39
  		<xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>	
40
  	</xsl:copy>
41
  </xsl:template>
42

  
43
  <xsl:template match="@*|comment()">
44
    <xsl:copy/>
45
  </xsl:template>
46
	
47
	<xsl:template match="processing-instruction()"/>
48
  
49
  <xsl:template match="*[local-name()='teiHeader']"/>
50
  
51
  <xsl:template match="*[local-name()='w']//text()">
52
    <xsl:variable name="line"><xsl:value-of select="ancestor::*[local-name()='w']/@line"/></xsl:variable>
53
    <xsl:variable name="lemma"><xsl:value-of select="ancestor::*[local-name()='w']/@lemma"/></xsl:variable>
54
    <xsl:variable name="pos"><xsl:value-of select="ancestor::*[local-name()='w']/@pos"/></xsl:variable>
55
    <xsl:variable name="word-form"><xsl:value-of select="ancestor::*[local-name()='w']"/></xsl:variable>
56
    <xsl:variable name="unclear">
57
      <xsl:choose>
58
        <xsl:when test="ancestor::*[local-name()='unclear']">yes</xsl:when>
59
        <xsl:otherwise>no</xsl:otherwise>
60
      </xsl:choose>
61
    </xsl:variable>
62
    <xsl:variable name="supplied">
63
      <xsl:choose>
64
        <xsl:when test="ancestor::*[local-name()='supplied']">yes</xsl:when>
65
        <xsl:otherwise>no</xsl:otherwise>
66
      </xsl:choose>
67
    </xsl:variable>
68
    
69
    <xsl:analyze-string select="." regex="[-.]|\([^\)]*\)">
70
      <xsl:matching-substring>
71
        <w line="{$line}" lemma="{$lemma}" pos="{$pos}" word-form="{$word-form}" supplied="{$supplied}" unclear="{$unclear}"><xsl:value-of select="."/></w>
72
      </xsl:matching-substring>
73
      <xsl:non-matching-substring>
74
        <w line="{$line}" lemma="{$lemma}" pos="{$pos}" word-form="{$word-form}" supplied="{$supplied}" unclear="{$unclear}"><xsl:value-of select="."/></w>
75
      </xsl:non-matching-substring>
76
    </xsl:analyze-string>    
77
  </xsl:template>
78

  
79
<xsl:template match="text()[not(ancestor::*[local-name()='w'])]">
80
  <xsl:analyze-string select="." regex="\[…\]">
81
    <xsl:matching-substring>
82
      <w line="¤" lemma="¤" pos="¤" word-form="¤" supplied="¤" unclear="¤"><xsl:value-of select="."/></w>
83
    </xsl:matching-substring>
84
    <xsl:non-matching-substring><xsl:comment><xsl:copy-of select="."/></xsl:comment></xsl:non-matching-substring>
85
  </xsl:analyze-string>
86
</xsl:template>
87

  
88
  <xsl:template match="*[local-name()='w']">
89
  <word>
90
    <xsl:apply-templates select="@*"/>
91
    <xsl:attribute name="no-supplied">
92
      <xsl:choose>
93
        <xsl:when test="ancestor::*[local-name()='supplied']">¤</xsl:when>
94
        <xsl:otherwise><xsl:apply-templates mode="nosupplied"/></xsl:otherwise>
95
      </xsl:choose>
96
    </xsl:attribute>
97
    <xsl:attribute name="no-unclear">
98
      <xsl:choose>
99
        <xsl:when test="ancestor::*[local-name()='supplied'] or ancestor::*[local-name()='unclear']">¤</xsl:when>
100
        <xsl:otherwise><xsl:apply-templates mode="nounclear"/></xsl:otherwise>
101
      </xsl:choose>
102
    </xsl:attribute>    
103
    <xsl:apply-templates/>
104
  </word>
105
</xsl:template>
106

  
107

  
108
</xsl:stylesheet>
tmp/trunk/org.txm.setups/shared/all/xsl/txm-filter-perseustreebank-xmlw.xsl (revision 729)
1
<?xml version="1.0"?>
2
<xsl:stylesheet
3
  xmlns:xd="http://www.pnp-software.com/XSLTdoc"
4
  xmlns:edate="http://exslt.org/dates-and-times"
5
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
7
  xmlns:treebank="http://nlp.perseus.tufts.edu/syntax/treebank/1.5"
8
  exclude-result-prefixes="edate xd xsi treebank" version="2.0">
9
  
10
  
11
  <xd:doc type="stylesheet">
12
    <xd:short>
13
      A stylesheet to prepare PERSEUS Treebank XML texts to TXM XML/w import.
14
    </xd:short>
15
    <xd:detail>
16
      This stylesheet is free software; you can redistribute it and/or
17
      modify it under the terms of the GNU Lesser General Public
18
      License as published by the Free Software Foundation; either
19
      version 3 of the License, or (at your option) any later version.
20
      
21
      This stylesheet is distributed in the hope that it will be useful,
22
      but WITHOUT ANY WARRANTY; without even the implied warranty of
23
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24
      Lesser General Public License for more details.
25
      
26
      You should have received a copy of GNU Lesser Public License with
27
      this stylesheet. If not, see http://www.gnu.org/licenses/lgpl.html
28
    </xd:detail>
29
    <xd:author>Alexei Lavrentiev alexei.lavrentev@ens-lyon.fr</xd:author>
30
    <xd:copyright>2012, CNRS / ICAR (ICAR3 LinCoBaTO)</xd:copyright>
31
  </xd:doc>
32
  
33

  
34
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/>
35
  
36
  <xsl:template match="*">
37
    <xsl:copy>
38
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>	
39
    </xsl:copy>
40
  </xsl:template>
41
  
42
  <xsl:template match="@*|comment()">
43
    <xsl:copy/>
44
  </xsl:template>
45
  
46
  <xsl:template match="processing-instruction()"/>
47
  
48
  <xsl:template match="text()"><xsl:value-of select="."/></xsl:template>
49
  
50
<xsl:template match="treebank">
51
  <text type="treebank" version="{@version}" date="{normalize-space(child::date[1])}" annotator-short="{normalize-space(child::annotator[1]/short)}" annotator-name="{normalize-space(child::annotator[1]/name)}" annotator-address="{normalize-space(child::annotator[1]/address)}">
52
    <xsl:apply-templates select="descendant::sentence"/>
53
  </text>
54
</xsl:template>
55

  
56
<xsl:template match="annotator"/>
57
  
58
<xsl:template match="sentence">
59
  <xsl:copy>
60
    <xsl:apply-templates select="@*"/>
61
    <xsl:attribute name="annotator"><xsl:value-of select="child::annotator"/></xsl:attribute>
62
    <xsl:apply-templates/>
63
  </xsl:copy>
64
</xsl:template>
65
  
66
  <xsl:template match="word">
67
    <w>
68
      <xsl:apply-templates select="@*[not(name()='form')]"/>
69
      <xsl:value-of select="@form"></xsl:value-of>
70
    </w>
71
  </xsl:template>
72

  
73
</xsl:stylesheet>
tmp/trunk/org.txm.setups/shared/all/xsl/txm-filter-teip5-teibfm.xsl (revision 729)
1
<?xml version="1.0"?>
2
<xsl:stylesheet
3
  xmlns:xd="http://www.pnp-software.com/XSLTdoc"
4
  xmlns:edate="http://exslt.org/dates-and-times"
5
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tei="http://www.tei-c.org/ns/1.0"
6
  exclude-result-prefixes="tei edate xd" version="2.0">
7
  
8
  <xd:doc type="stylesheet">
9
    <xd:short>
10
      Feuille de style de préparation de fichiers TEI P5 à l'importation 
11
      dans TXM. Permet de simplifier la structure du document afin
12
      d'optimiser les index CWB
13
    </xd:short>
14
    <xd:detail>
15
      This stylesheet is free software; you can redistribute it and/or
16
      modify it under the terms of the GNU Lesser General Public
17
      License as published by the Free Software Foundation; either
18
      version 3 of the License, or (at your option) any later version.
19
      
20
      This stylesheet is distributed in the hope that it will be useful,
21
      but WITHOUT ANY WARRANTY; without even the implied warranty of
22
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23
      Lesser General Public License for more details.
24
      
25
      You should have received a copy of GNU Lesser Public License with
26
      this stylesheet. If not, see http://www.gnu.org/licenses/lgpl.html
27
    </xd:detail>
28
    <xd:author>Alexei Lavrentiev alexei.lavrentev@ens-lyon.fr</xd:author>
29
    <xd:copyright>2012, CNRS / ICAR (ICAR3 LinCoBaTO)</xd:copyright>
30
  </xd:doc>
31
  
32

  
33
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/>
34
  
35
  <!--
36
    Modifications par AL le  2012-01-25
37
    g dépalacé de "deleteAll" vers "deleteTag"
38
    classe de balise "name" créée
39
    (geogName, placeName, persName et name)
40
  -->
41
  
42
  <!-- 
43
    Modifications par LBe le 2012-02-17
44
    Transformation automatique des esperluettes dans les métadonnées
45
    Suppression des balises label et heraldry
46
    Signed n'est plus transformé en ab
47
    opener est transformé en ab
48
    L'institution et le dépôt sont récupérés pour le lieu de conservation
49
  -->
50
  
51
  <!-- Modifications par AL le 2012-02-20
52
    rolename -> roleName
53
    suppression des balises surname et forename
54
  -->
55
  
56
  <!-- Modifications par LBe le 2012-03-09
57
    Automatisation du nommage des sorties
58
  -->
59
  
60
  <!-- Listes des balises par type de traitement (les templates sont plus bas) -->
61
  
62
  <!-- balises à supprimer avec leur contenu -->
63
  <xsl:template match="tei:figDesc|tei:figure|tei:fw|tei:g
64
    |tei:space|tei:titlePage ">
65
    <xsl:call-template name="deleteAll"/>
66
  </xsl:template>
67
  
68
  <!-- balises à supprimer, contenu à conserver -->  
69
  <xsl:template match="tei:add|tei:app
70
    |tei:caesura|tei:castItem|tei:castGroup[ancestor::tei:castList]
71
    |tei:castList[ancestor::tei:p]|tei:cell|tei:choice|tei:cit|tei:corr|tei:date|tei:ex
72
    |tei:forename|tei:g|tei:head[parent::tei:list]|tei:heraldry|tei:hi|tei:item|tei:label|tei:lem
73
    |tei:list[ancestor::tei:p|ancestor::tei:ab]|tei:lg[child::tei:lg|ancestor::tei:sp]
74
    |tei:p[ancestor::tei:sp]|tei:performance
75
    |tei:ref|tei:reg|tei:role|tei:roleDesc
76
    |tei:row|tei:salute|tei:signed[ancestor::tei:closer]|tei:speaker|tei:stage[ancestor::tei:p|ancestor::tei:ab]
77
    |tei:surname|tei:table[ancestor::tei:p]|tei:subst|tei:term|tei:unclear">
78
    <xsl:call-template name="deleteTag"/>
79
  </xsl:template>
80
  
81
  <!-- balises à transformer en notes-->
82
  <xsl:template match="tei:abbr[parent::tei:choice and not(ancestor::tei:note)]
83
    |tei:bibl[not(ancestor::tei:note)]
84
    |tei:del
85
    |tei:orig[parent::tei:choice and not(ancestor::tei:note)]    
86
    |tei:rdg[parent::tei:app and not(ancestor::tei:note)]
87
    |tei:sic[parent::tei:choice and not(ancestor::tei:note)]
88
    |tei:surplus[not(ancestor::tei:w)]">
89
    <xsl:call-template name="makeNote"/>
90
  </xsl:template>
91
  
92
  <!-- balises de noms à indexer -->
93
  
94
  <xsl:template match="tei:name
95
    |tei:geogName
96
    |tei:persName
97
    |tei:placeName
98
    |tei:roleName
99
    |tei:orgName">
100
    <xsl:call-template name="makeName"/>
101
  </xsl:template>
102
  
103
  <!-- à transformer en W -->
104
  
105
  <xsl:template match="tei:abbr[not(parent::tei:choice)]
106
    |tei:expan
107
    |tei:num[matches(.,'.')]">
108
    <xsl:call-template name="makeWord"/>
109
  </xsl:template>
110
  
111
  <!-- à transformer en AB typé -->
112
  
113
  <xsl:template match="tei:byline|tei:lg[not(child::tei:lg or ancestor::tei:sp)]|tei:list[not(ancestor::tei:p|ancestor::tei:ab)]
114
    |tei:closer|tei:opener|tei:sp|tei:castGroup[not(ancestor::tei:castList)]|tei:castList[not(ancestor::tei:p)]
115
    |tei:signed[not(ancestor::tei:closer)]
116
    |tei:stage[not(ancestor::tei:p|ancestor::tei:ab)]
117
    |tei:table[not(ancestor::tei:p)]
118
    |tei:trailer">
119
    <xsl:call-template name="makeAb"/>
120
  </xsl:template>
121
  
122
  <!-- à transformer en DIV typé -->
123
  
124
  <xsl:template match="tei:set">
125
    <xsl:call-template name="makeDiv"/>
126
  </xsl:template>
127

  
128
<!-- Partie générale : on copie les éléments, les attributs, le texte, les commentaires, on supprime mes prrocessing intstructions -->
129

  
130
<!--  <xsl:template match="/">
131
      <xsl:apply-templates/>  
132
  </xsl:template>
133
-->
134
  
135
  <xsl:template match="*">    
136
    <xsl:choose>
137
      <xsl:when test="namespace-uri()=''">
138
        <xsl:element namespace="http://www.tei-c.org/ns/1.0" name="{local-name(.)}">
139
          <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
140
        </xsl:element>
141
      </xsl:when>
142
      <xsl:otherwise>
143
        <xsl:copy>
144
          <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
145
        </xsl:copy>
146
      </xsl:otherwise>
147
    </xsl:choose>  
148
  </xsl:template>
149

  
150
  <xsl:template match="@*|comment()">
151
    <xsl:copy/>
152
  </xsl:template>
153

  
154
  <xsl:template match="text()">
155
    <xsl:analyze-string select="." regex="&amp;|&lt;|&gt;|--|\*(\w+)">
156
      <xsl:matching-substring>
157
        <xsl:choose>
158
          <xsl:when test="matches(.,'&amp;')">
159
            <expan xmlns="http://www.tei-c.org/ns/1.0">et</expan>
160
          </xsl:when>
161
          <xsl:when test="matches(.,'&lt;')">
162
            <xsl:text>[</xsl:text>
163
          </xsl:when>
164
          <xsl:when test="matches(.,'&gt;')">
165
            <xsl:text>]</xsl:text>
166
          </xsl:when>
167
          <!-- pose problème si se trouve dans les notes transformés en commentaires xml par le tokeniseur -->
168
          <xsl:when test="matches(.,'--')">
169
            <xsl:text> - </xsl:text>
170
          </xsl:when>
171
<!--          <!-\- Spécial FRANTEXT -\->
172
          <xsl:when test="matches(.,'\*(\w+)')">
173
            <name xmlns="http://www.tei-c.org/ns/1.0" type="maj"><xsl:value-of select="regex-group(1)"/></name>        		
174
          </xsl:when>          -->
175
          <xsl:otherwise>
176
            <xsl:value-of select="."/>
177
          </xsl:otherwise>
178
        </xsl:choose>
179
      </xsl:matching-substring>
180
      <xsl:non-matching-substring>         
181
        <xsl:value-of select="."/>
182
      </xsl:non-matching-substring>      
183
    </xsl:analyze-string>
184
  </xsl:template>
185
  
186

  
187
  <xsl:template match="processing-instruction()"/>
188

  
189
<!-- On ne touche pas au teiHeader -->
190
  
191
  <xsl:template match="tei:teiHeader">    
192
      <xsl:copy-of select="."/>    
193
  </xsl:template>
194

  
195
<!-- On supprime les balises et tout ce qu'elles contiennent pour les éléments hors texte à ignorer lors de l'import -->
196
  
197
  <xsl:template name="deleteAll"/>
198

  
199
<!-- On supprime les balises non essentielles pour l'exploitation textométrique et susceptibles de poser des problèmes au tokeniseur,
200
  mais on garde leur contenu qui fait partie du matériau textuel -->
201
  
202
  <xsl:template name="deleteTag">
203
    <xsl:apply-templates/>
204
  </xsl:template>
205

  
206
<!-- on met en note les éléments hors texte qu'on aimerait garder pour l'édition, etc. -->
207
  
208
  <xsl:template name="makeNote">
209
    <note type="{local-name()}" xmlns="http://www.tei-c.org/ns/1.0">
210
      <xsl:apply-templates select="text()"/>
211
    </note>
212
  </xsl:template>
213
  
214
<!-- On supprime toutes les balises à l'intérieur des notes-->
215
  <xsl:template match="tei:note">
216
    <xsl:copy>
217
      <xsl:apply-templates select="text()"/>
218
    </xsl:copy>
219
  </xsl:template>
220

  
221
<!-- On transforme en DIV typés les balises de niveau de division textuelle (pouvant contenir des p) -->
222

  
223
  <xsl:template name="makeDiv">
224
    <div type="{local-name()}" xmlns="http://www.tei-c.org/ns/1.0">
225
      <xsl:copy-of select="@*"/>
226
      <xsl:apply-templates/>
227
    </div>
228
  </xsl:template>  
229

  
230
<!-- On transforme en bloc anonyme les balises de niveau équivalent au paragraphe -->
231

  
232
  <xsl:template name="makeAb">
233
    <ab type="{local-name()}" xmlns="http://www.tei-c.org/ns/1.0">
234
      <xsl:copy-of select="@*"/>
235
      <xsl:apply-templates/>
236
    </ab>
237
  </xsl:template>
238

  
239
  <!-- on pré-tokenise les éléments équivalents à un mot -->
240
  
241
  <xsl:template name="makeWord">
242
    <xsl:variable name="wordType">
243
      <xsl:choose>
244
        <xsl:when test="@type">
245
          <xsl:value-of select="concat(local-name(),'-',@type)"/>
246
        </xsl:when>
247
        <xsl:otherwise>
248
          <xsl:value-of select="local-name()"></xsl:value-of>
249
        </xsl:otherwise>
250
      </xsl:choose>
251
    </xsl:variable>
252
    <xsl:choose>
253
      <xsl:when test="descendant::tei:w or ancestor::tei:w">
254
<!--            <xsl:element namespace="http://www.tei-c.org/ns/1.0" name="seg">
255
              <xsl:attribute name="type"><xsl:value-of select="local-name(.)"/></xsl:attribute>
256
              <xsl:apply-templates select="*|@*[not(name()='type')]|processing-instruction()|comment()|text()"/>
257
            </xsl:element>
258
-->
259
        <xsl:apply-templates/> <!-- on supprime ces balises pour éviter la réduplication des mots-->
260
      </xsl:when>
261
      <xsl:otherwise>
262
        <w type="{$wordType}" xmlns="http://www.tei-c.org/ns/1.0"><xsl:apply-templates/></w>
263
      </xsl:otherwise>
264
    </xsl:choose>    
265
  </xsl:template>  
266

  
267
<xsl:template name="makeName">
268
  <xsl:variable name="nameType">
269
    <xsl:choose>
270
      <xsl:when test="@type">
271
        <xsl:choose>
272
          <xsl:when test="local-name()='name'"><xsl:value-of select='@type'/></xsl:when>
273
          <xsl:otherwise><xsl:value-of select="concat(local-name(),'-',@type)"/></xsl:otherwise>
274
        </xsl:choose>
275
      </xsl:when>
276
      <xsl:otherwise>
277
        <xsl:value-of select="local-name()"></xsl:value-of>
278
      </xsl:otherwise>
279
    </xsl:choose>
280
  </xsl:variable>
281
  <name type="{$nameType}" xmlns="http://www.tei-c.org/ns/1.0">
282
    <xsl:apply-templates/>
283
  </name>
284
</xsl:template>
285

  
286
<!-- les l sont transformés en lb -->
287
  
288
  <xsl:template match="tei:l">
289
    <lb xmlns="http://www.tei-c.org/ns/1.0">
290
      <xsl:if test="@n">
291
        <xsl:attribute name="n"><xsl:value-of select="@n"/></xsl:attribute>
292
      </xsl:if>
293
    </lb>
294
    <xsl:apply-templates/>
295
  </xsl:template>
296
  
297

  
298
<!-- On met la ponctuation forte à l'extérieur de la balise foreign :
299
Cet élément sera toujours à l'intérieur d'une phrase. Attention au risque
300
de perdre les balises éventuelles à l'intérieur-->
301
  
302
  <xsl:template
303
    match="tei:foreign[not(contains(@rend,'multi_s'))][matches(.,'[.!?]')]">
304
    <xsl:variable name="lang">
305
      <xsl:choose>
306
        <xsl:when test="@lang"><xsl:value-of select="@lang"/></xsl:when>
307
        <xsl:when test="@xml:lang"><xsl:value-of select="@xml:lang"/></xsl:when>
308
        <xsl:otherwise>xx</xsl:otherwise>
309
      </xsl:choose>
310
    </xsl:variable>
311
    <xsl:for-each select="child::node()">
312
      <xsl:choose>
313
        <xsl:when test="self::text()">
314
          <xsl:analyze-string select="." regex="([^.!?]*)([.?!]+)">
315
            <xsl:matching-substring>
316
              <xsl:element name="foreign" namespace="http://www.tei-c.org/ns/1.0">
317
                <xsl:attribute name="lang"><xsl:value-of select="$lang"/></xsl:attribute>
318
                <xsl:analyze-string select="regex-group(1)" regex="&amp;">
319
                  <xsl:matching-substring><expan xmlns="http://www.tei-c.org/ns/1.0">et</expan></xsl:matching-substring>
320
                  <xsl:non-matching-substring>         
321
                    <xsl:value-of select="."/>
322
                  </xsl:non-matching-substring>      
323
                </xsl:analyze-string>
324
              </xsl:element>
325
              <xsl:value-of select="regex-group(2)"/>
326
              <xsl:text> </xsl:text>
327
            </xsl:matching-substring>
328
            <xsl:non-matching-substring>
329
              <xsl:analyze-string select="." regex="&amp;">
330
                <xsl:matching-substring><expan xmlns="http://www.tei-c.org/ns/1.0">et</expan></xsl:matching-substring>
331
                <xsl:non-matching-substring>         
332
                  <xsl:value-of select="."/>
333
                </xsl:non-matching-substring>      
334
              </xsl:analyze-string>              
335
            </xsl:non-matching-substring>
336
          </xsl:analyze-string>          
337
        </xsl:when>
338
        <xsl:when test="self::*[not(descendant::text())]">
339
          <xsl:apply-templates/>
340
        </xsl:when>
341
        <xsl:otherwise>
342
          <xsl:element name="foreign" namespace="http://www.tei-c.org/ns/1.0">
343
            <xsl:attribute name="lang"><xsl:value-of select="$lang"/></xsl:attribute>
344
            <xsl:apply-templates select="."/>          
345
          </xsl:element>
346
        </xsl:otherwise>
347
      </xsl:choose>
348
    </xsl:for-each>
349
  </xsl:template>
350
  
351
  
352
  <xsl:template name="persname">
353
      <xsl:choose>
354
         <xsl:when test="tei:surname"><xsl:value-of select="tei:forename"/>&#160;<xsl:value-of select="tei:surname"/></xsl:when>
355
         <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
356
      </xsl:choose>
357
   </xsl:template>
358
  
359
  
360
<!--  <!-\- traitement spécifique anciennes étiquettes bfm -\->
361
  <xsl:template match="tei:w/@type[contains(.,'_')]">
362
    <xsl:attribute name="type"><xsl:value-of select="substring-before(.,'_')"/></xsl:attribute>
363
  </xsl:template>
364
-->
365
</xsl:stylesheet>
tmp/trunk/org.txm.setups/shared/all/xsl/txm-edition-xtz-corpusakkadien-translit.xsl (revision 729)
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" xmlns:txm="http://textometrie.org/1.0"
4
	exclude-result-prefixes="#all" version="2.0">
5
	
6
	<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="no"  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
7
	
8
	<xsl:strip-space elements="*"/>
9
	
10
	<xsl:param name="editionpagetag">pb</xsl:param>
11
	
12
	<xsl:param name="textcontainer">text</xsl:param>
13
	
14
	<!--<xsl:param name="frontmatter"></xsl:param>
15
	
16
	<xsl:param name="backmatter">back</xsl:param>-->
17
	
18
	<xsl:variable name="inputtype">
19
		<xsl:choose>
20
			<xsl:when test="//tei:w//txm:form">xmltxm</xsl:when>
21
			<xsl:otherwise>xmlw</xsl:otherwise>
22
		</xsl:choose>
23
	</xsl:variable>
24
	
25
	<xsl:template match="/">
26
		<html>
27
			<head>
28
				<title><xsl:value-of select="//tei:text[1]/@id"/></title>
29
				<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
30
			</head>
31
			<body>
32
				<a class="txm-page" title="1"/>
33
				<div class="metadata-page">
34
					<h1><xsl:value-of select="//tei:text[1]/@id"></xsl:value-of></h1>
35
					<br/>
36
					<table>
37
						<xsl:for-each select="//tei:text[1]/@*">
38
							<tr>
39
								<td><xsl:value-of select="name()"/></td>
40
								<td><xsl:value-of select="."/></td>
41
							</tr>
42
						</xsl:for-each>
43
					</table>
44
					<br/>
45
					<br/>
46
				</div>
47
				<xsl:apply-templates select="descendant::*[local-name()=$textcontainer]"/>
48
				
49
				
50
			</body>
51
		</html>
52
	</xsl:template>
53
	
54
	<xsl:template match="//*[local-name()=$textcontainer]">
55
		<xsl:variable name="pbcount"></xsl:variable>
56
		
57
		<div class="text" style="margin-left:60px;">
58
			<xsl:apply-templates/>
59
		</div>
60
	</xsl:template>
61
	
62
		
63
	
64
	<xsl:template match="*">
65
		<xsl:choose>
66
			<xsl:when test="descendant::tei:p|descendant::tei:ab">
67
				<div>
68
					<xsl:call-template name="addClass"/>
69
					<xsl:apply-templates/></div>
70
				<xsl:text>&#xa;</xsl:text>
71
			</xsl:when>
72
			<xsl:otherwise><span>
73
				<xsl:call-template name="addClass"/>
74
				<xsl:if test="self::tei:add[@del]">
75
					<xsl:attribute name="title"><xsl:value-of select="@del"/></xsl:attribute>
76
				</xsl:if>
77
				<xsl:apply-templates/></span>
78
			</xsl:otherwise>
79
		</xsl:choose>
80
	</xsl:template>
81
	
82
	<xsl:template match="@*|processing-instruction()|comment()">
83

  
84
	</xsl:template>
85
	
86
	<xsl:template match="text()">
87
		<xsl:value-of select="normalize-space(.)"/>
88
	</xsl:template>
89
	
90
	<xsl:template name="addClass">
91
		<xsl:attribute name="class">
92
			<xsl:value-of select="local-name(.)"/>
93
			<xsl:if test="@type"><xsl:value-of select="concat('-',@type)"/></xsl:if>
94
			<xsl:if test="@subtype"><xsl:value-of select="concat('-',@subtype)"/></xsl:if>
95
			<xsl:if test="@rend"><xsl:value-of select="concat('-',@rend)"/></xsl:if>
96
		</xsl:attribute>                	
97
	</xsl:template>
98
	
99

  
100
	
101
	<xsl:template match="//word">
102
		<xsl:choose>
103
			<xsl:when test="@line = preceding::word[1]/@line"><xsl:text> </xsl:text></xsl:when>
104
			<xsl:otherwise><br/><xsl:text>&#xa;</xsl:text><span style="position:relative"><span class="linenumber" style="position:absolute;width:40px;left:-50px;padding-right:20px;text-align:right"><xsl:value-of select="@line"/>&#xa0;</span></span></xsl:otherwise>
105
		</xsl:choose>
106
		<span>
107
			<xsl:call-template name="addClass"/>
108
			<xsl:apply-templates/>
109
		</span>
110
	</xsl:template>
111
	
112
	
113
	
114
	<!-- Page breaks -->                
115
	<xsl:template match="//*[local-name()=$editionpagetag]">
116
		<xsl:variable name="editionpagetype">
117
			<xsl:choose>
118
				<xsl:when test="ancestor::tei:ab">editionpageverse</xsl:when>
119
				<xsl:otherwise>editionpage</xsl:otherwise>
120
			</xsl:choose>
121
		</xsl:variable>
122
		<xsl:variable name="pagenumber">
123
			<xsl:choose>
124
				<xsl:when test="@n"><xsl:value-of select="@n"/></xsl:when>
125
				<xsl:when test="@facs"><xsl:value-of select="substring-before(@facs,'.')"/></xsl:when>
126
				<xsl:otherwise>[NN]</xsl:otherwise>
127
			</xsl:choose>
128
		</xsl:variable>
129
		
130
		<xsl:variable name="page_id"><xsl:value-of select="count(preceding::*[local-name()=$editionpagetag])"/></xsl:variable>
131
		<xsl:if test="@break='no'"><span class="hyphen">-</span></xsl:if>
132
		<xsl:if test="//tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))][following::*[local-name()=$editionpagetag][1][count(preceding::*[local-name()=$editionpagetag]) = $page_id]]">
133
			<xsl:text>&#xa;</xsl:text>
134
			<br/>
135
			<br/>			
136
			<span class="footnotes">
137
				<xsl:for-each select="//tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))][following::*[local-name()=$editionpagetag][1][count(preceding::*[local-name()=$editionpagetag]) = $page_id]]">
138
					<xsl:variable name="note_count"><xsl:value-of select="count(preceding::tei:note[not(@place='inline')]) + 1"/></xsl:variable>
139
					<!--<p><xsl:value-of select="$note_count"/>. <a href="#noteref_{$note_count}" name="note_{$note_count}">[<xsl:value-of select="preceding::tei:cb[1]/@xml:id"/>, l. <xsl:value-of select="preceding::tei:lb[1]/@n"/>]</a><xsl:text> </xsl:text> <xsl:value-of select="."/></p>-->
140
					<span class="note">
141
						<span class="footnotenumber"><a href="#noteref_{$note_count}" name="note_{$note_count}"><xsl:value-of select="$note_count"/></a>. </span>
142
						<xsl:apply-templates mode="#current"/>
143
					</span>                                                                
144
				</xsl:for-each></span><xsl:text>&#xa;</xsl:text>                                                                
145
			
146
		</xsl:if>                                
147
		
148
		<xsl:text>&#xa;</xsl:text>
149
		<br/><xsl:text>&#xa;</xsl:text>
150
		<a class="txm-page" title="{count(preceding::*[local-name()=$editionpagetag]) + 2}"/>
151
		<span class="{$editionpagetype}"> - <xsl:value-of select="$pagenumber"/> - </span><br/><xsl:text>&#xa;</xsl:text>
152
	</xsl:template>
153
	
154
	<!-- Notes -->
155
<!--	<xsl:template match="tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))]">
156
		<!-\-<span style="color:violet"> [<b>Note :</b> <xsl:apply-templates/>] </span>-\->	
157
		<xsl:variable name="note_count"><xsl:value-of select="count(preceding::tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))]) + 1"/></xsl:variable>
158
		<a title="{.}" class="noteref" href="#note_{$note_count}" name="noteref_{$note_count}">[<xsl:value-of select="$note_count"/>]</a>
159
		<xsl:call-template name="spacing"/>                                
160
	</xsl:template>
161
-->	
162
	
163
	<xsl:template match="//w"><span class="w">
164
		<xsl:if test="@id">
165
			<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
166
		</xsl:if>
167
		<xsl:attribute name="title">
168
			<xsl:choose>
169
				<xsl:when test="descendant::txm:ana">
170
					<xsl:for-each select="descendant::txm:ana">
171
						<xsl:value-of select="concat(substring(@type,2),': ',.,' ; ')"/>				
172
					</xsl:for-each>
173
					<xsl:value-of select="concat('translit : ',descendant::txm:form)"/>
174
				</xsl:when>
175
				<xsl:otherwise>
176
					<xsl:for-each select="@*">
177
						<xsl:value-of select="concat(name(),': ',.,' ; ')"/>				
178
					</xsl:for-each>
179
					<xsl:value-of select="concat('translit : ',.)"/>
180
				</xsl:otherwise>
181
			</xsl:choose>
182

  
183
		</xsl:attribute>
184
		<xsl:choose>
185
			<xsl:when test="descendant::txm:form">
186
				<xsl:apply-templates select="txm:form"/>
187
			</xsl:when>
188
			<xsl:otherwise>
189
				<xsl:value-of select="."/>
190
			</xsl:otherwise>
191
		</xsl:choose>
192
		
193
	</span>
194
		<xsl:if test="following-sibling::w">-</xsl:if>
195
	</xsl:template>
196
	
197
	
198
	                <xsl:template match="//txm:form">
199
	                		<xsl:value-of select="."/>
200
                </xsl:template>
201
                
202
	
203
	
204
</xsl:stylesheet>
tmp/trunk/org.txm.setups/shared/all/xsl/txm-edition-xtz.xsl (revision 729)
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" xmlns:txm="http://textometrie.org/1.0"
4
                exclude-result-prefixes="#all" version="2.0">
5
                
6
	<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="no"  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
7
                
8
                <xsl:strip-space elements="*"/>
9
                
10
	<xsl:param name="editionpagetag">pb</xsl:param>
11
                
12
                <xsl:variable name="inputtype">
13
                	<xsl:choose>
14
                		<xsl:when test="//tei:w//txm:form">xmltxm</xsl:when>
15
                		<xsl:otherwise>xmlw</xsl:otherwise>
16
                	</xsl:choose>
17
                </xsl:variable>
18
	
19
	<xsl:variable name="filename">
20
		<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$">
21
			<xsl:matching-substring>
22
				<xsl:value-of select="regex-group(2)"/>
23
			</xsl:matching-substring>
24
		</xsl:analyze-string>
25
	</xsl:variable>
26
                
27
                <xsl:template match="/">
28
                	<html>
29
                		<head>
30
                			<title><xsl:choose>
31
                				<xsl:when test="//tei:text/@id"><xsl:value-of select="//tei:text[1]/@id"/></xsl:when>
32
                				<xsl:otherwise><xsl:value-of select="$filename"/></xsl:otherwise>
33
                			</xsl:choose></title>
34
                			<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
35
                			<link rel="stylesheet" media="all" type="text/css" href="css/bvhepistemon2014.css" />
36
<!--                			<title>
37
                				<xsl:if test="$author[not(contains(.,'anonym'))]">
38
                					<xsl:value-of select="$author"/><xsl:text> : </xsl:text>
39
                				</xsl:if>
40
                				<xsl:value-of select="$title-normal"/>
41
                			</title>                                                                -->
42
                		</head>
43
                			<xsl:apply-templates select="descendant::tei:text"/>
44
                	</html>
45
                </xsl:template>
46

  
47
<xsl:template match="tei:text">
48
	<body>
49
		<a class="txm-page" title="1"/>
50
		<div class="metadata-page">
51
			<h1><xsl:value-of select="@id"></xsl:value-of></h1>
52
			<br/>
53
			<table>
54
				<xsl:for-each select="@*">
55
					<tr>
56
						<td><xsl:value-of select="name()"/></td>
57
						<td><xsl:value-of select="."/></td>
58
					</tr>
59
				</xsl:for-each>
60
			</table>
61
		</div>
62
		<xsl:apply-templates/>		
63
	</body>
64
</xsl:template>
65

  
66
                <xsl:template match="*">
67
                                <xsl:choose>
68
                                	<xsl:when test="descendant::tei:p|descendant::tei:ab">
69
                                		<div>
70
                                			<xsl:call-template name="addClass"/>
71
                                			<xsl:apply-templates/></div>
72
                                		<xsl:text>&#xa;</xsl:text>
73
                                	</xsl:when>
74
                                	<xsl:otherwise><span>
75
                                		<xsl:call-template name="addClass"/>
76
                                		<xsl:if test="self::tei:add[@del]">
77
                                			<xsl:attribute name="title"><xsl:value-of select="@del"/></xsl:attribute>
78
                                		</xsl:if>
79
                                		<xsl:apply-templates/></span>
80
                                	<xsl:call-template name="spacing"/>
81
                                	</xsl:otherwise>
82
                                </xsl:choose>
83
                </xsl:template>
84
                
85
                <xsl:template match="@*|processing-instruction()|comment()">
86
                                <!--<xsl:copy/>-->
87
                </xsl:template>
88
                
89
<!--                <xsl:template match="comment()">
90
                                <xsl:copy/>
91
                </xsl:template>
92
-->                
93
                <xsl:template match="text()">
94
                                <xsl:value-of select="normalize-space(.)"/>
95
                </xsl:template>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff