Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / txm-filter-corpusakkadien-xmlw_syllabes.xsl @ 187

History | View | Annotate | Download (4.6 kB)

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>