Statistics
| Revision:

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

History | View | Annotate | Download (7.2 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()='g']">
89
    <xsl:variable name="line"><xsl:value-of select="ancestor::*[local-name()='w']/@line"/></xsl:variable>
90
    <xsl:variable name="lemma"><xsl:value-of select="ancestor::*[local-name()='w']/@lemma"/></xsl:variable>
91
    <xsl:variable name="pos"><xsl:value-of select="ancestor::*[local-name()='w']/@pos"/></xsl:variable>
92
    <xsl:variable name="word-form">
93
      <xsl:for-each select="ancestor::*[local-name()='w']/descendant::*[local-name()='g']">
94
        <xsl:value-of select="."/>
95
        <xsl:if test="following-sibling::*[local-name()='g']">-</xsl:if>
96
      </xsl:for-each>
97
    </xsl:variable>
98
    <xsl:variable name="unclear">
99
      <xsl:choose>
100
        <xsl:when test="ancestor::*[local-name()='unclear']">yes</xsl:when>
101
        <xsl:otherwise>no</xsl:otherwise>
102
      </xsl:choose>
103
    </xsl:variable>
104
    <xsl:variable name="supplied">
105
      <xsl:choose>
106
        <xsl:when test="ancestor::*[local-name()='supplied']">yes</xsl:when>
107
        <xsl:otherwise>no</xsl:otherwise>
108
      </xsl:choose>
109
    </xsl:variable>
110
    <xsl:variable name="decimal">
111
      <xsl:call-template name="hex2num"><xsl:with-param name="hex"><xsl:value-of select="substring(@refUnicode,4)"/></xsl:with-param></xsl:call-template>
112
    </xsl:variable>
113
    
114
    <w line="{$line}" lemma="{$lemma}" pos="{$pos}" word-form="{$word-form}" supplied="{$supplied}" unclear="{$unclear}" ref-syllabaire="{@refSyllabaire}" ref-unicode="{@refUnicode}"><xsl:value-of select="."/></w>
115
    
116
  </xsl:template>
117

    
118
  <xsl:template match="*[local-name()='w']">
119
  <word>
120
    <xsl:apply-templates select="@*"/>
121
    <xsl:attribute name="no-supplied">
122
      <xsl:choose>
123
        <xsl:when test="ancestor::*[local-name()='supplied']">¤</xsl:when>
124
        <xsl:otherwise>      
125
          <xsl:for-each select="descendant::*[local-name()='g']">
126
          <xsl:value-of select="."/>
127
          <xsl:if test="following-sibling::*[local-name()='g']">-</xsl:if>
128
        </xsl:for-each>
129
        </xsl:otherwise>
130
      </xsl:choose>
131
    </xsl:attribute>
132
    <xsl:attribute name="no-unclear">
133
      <xsl:choose>
134
        <xsl:when test="ancestor::*[local-name()='supplied'] or ancestor::*[local-name()='unclear']">¤</xsl:when>
135
        <xsl:otherwise>
136
          <xsl:for-each select="descendant::*[local-name()='g']">
137
            <xsl:value-of select="."/>
138
            <xsl:if test="following-sibling::*[local-name()='g']">-</xsl:if>
139
          </xsl:for-each>
140
        </xsl:otherwise>
141
      </xsl:choose>
142
    </xsl:attribute>    
143
    <xsl:apply-templates/>
144
  </word>
145
</xsl:template>
146

    
147

    
148
  <xsl:template name="hex2num">
149
    <xsl:param name="hex"/>
150
    <xsl:param name="num" select="0"/>
151
    <xsl:param name="MSB" select="translate(substring($hex, 1, 1), 'abcdef', 'ABCDEF')"/>
152
    <xsl:param name="value" select="string-length(substring-before('0123456789ABCDEF', $MSB))"/>
153
    <xsl:param name="result" select="16 * $num + $value"/>
154
    <xsl:choose>
155
      <xsl:when test="string-length($hex) > 1">
156
        <xsl:call-template name="hex2num">
157
          <xsl:with-param name="hex" select="substring($hex, 2)"/>
158
          <xsl:with-param name="num" select="$result"/>
159
        </xsl:call-template>
160
      </xsl:when>
161
      <xsl:otherwise>
162
        <xsl:value-of select="$result"/>
163
      </xsl:otherwise>
164
    </xsl:choose>
165
  </xsl:template>
166

    
167

    
168
</xsl:stylesheet>