root / tmp / org.txm.oriflamms.rcp / bin / txm-front-teioriflamms-xtz.xsl @ 476
History | View | Annotate | Download (9.1 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 |
xmlns:me="http://www.menota.org/ns/1.0" |
5 |
xmlns:bfm="http://bfm.ens-lsh.fr/ns/1.0" |
6 |
xmlns:xd="http://www.pnp-software.com/XSLTdoc" |
7 |
exclude-result-prefixes="tei edate bfm me" version="2.0"> |
8 |
|
9 |
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/> |
10 |
|
11 |
|
12 |
<xd:doc type="stylesheet"> |
13 |
<xd:short> |
14 |
Cette feuille XSLT prépare les fichiers au format TEI Oriflamms |
15 |
(tokénisés par mot) à l'imppportation dans TXM avec le module XTZ |
16 |
(étape 2 "front"). |
17 |
</xd:short> |
18 |
<xd:detail> |
19 |
This stylesheet is free software; you can redistribute it and/or |
20 |
modify it under the terms of the GNU Lesser General Public |
21 |
License as published by the Free Software Foundation; either |
22 |
version 3 of the License, or (at your option) any later version. |
23 |
|
24 |
This stylesheet is distributed in the hope that it will be useful, |
25 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
26 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
27 |
Lesser General Public License for more details. |
28 |
|
29 |
You should have received a copy of GNU Lesser Public License with |
30 |
this stylesheet. If not, see http://www.gnu.org/licenses/lgpl.html |
31 |
</xd:detail> |
32 |
<xd:author>Alexei Lavrentiev alexei.lavrentev@ens-lyon.fr</xd:author> |
33 |
<xd:copyright>2016, CNRS / ICAR (Équipe CACTUS)</xd:copyright> |
34 |
</xd:doc> |
35 |
|
36 |
|
37 |
<xsl:template match="*" mode="#all"> |
38 |
<xsl:copy> |
39 |
<xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()" mode="#current"/> |
40 |
</xsl:copy> |
41 |
</xsl:template> |
42 |
|
43 |
<xsl:template match="comment()|processing-instruction()|text()|@*"> |
44 |
<xsl:copy> |
45 |
<xsl:apply-templates/> |
46 |
</xsl:copy> |
47 |
</xsl:template> |
48 |
|
49 |
<xsl:template match="comment()|processing-instruction()|@*" mode="expan letters-all |
50 |
letters-alignable characters-alignable"> |
51 |
<xsl:copy> |
52 |
<xsl:apply-templates/> |
53 |
</xsl:copy> |
54 |
</xsl:template> |
55 |
|
56 |
<xsl:variable name="filename"> |
57 |
<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)-w\.xml$"> |
58 |
<xsl:matching-substring> |
59 |
<xsl:value-of select="regex-group(2)"/> |
60 |
</xsl:matching-substring> |
61 |
</xsl:analyze-string> |
62 |
</xsl:variable> |
63 |
|
64 |
<xsl:template match="tei:teiCorpus"> |
65 |
<TEI xmlns="http://www.tei-c.org/ns/1.0"> |
66 |
<text> |
67 |
<!-- on ajoute des attributs utiles pour la création de partitions et de sous-corpus --> |
68 |
<xsl:apply-templates/> |
69 |
</text> |
70 |
</TEI> |
71 |
</xsl:template> |
72 |
|
73 |
|
74 |
<xsl:template match="tei:TEI[ancestor::tei:teiCorpus]"> |
75 |
<xsl:apply-templates/> |
76 |
</xsl:template> |
77 |
|
78 |
<xsl:template match="tei:teiHeader"> |
79 |
<!--<xsl:copy-of select="."/>--> |
80 |
</xsl:template> |
81 |
|
82 |
<xsl:template match="tei:text[not(ancestor::tei:teiCorpus)]"> |
83 |
<xsl:element name="text" namespace="http://www.tei-c.org/ns/1.0"> |
84 |
<!-- on ajoute des attributs utiles pour la création de partitions et de sous-corpus --> |
85 |
<xsl:apply-templates select="@*"/> |
86 |
<xsl:apply-templates/> |
87 |
</xsl:element> |
88 |
</xsl:template> |
89 |
|
90 |
<xsl:template match="tei:text[ancestor::tei:teiCorpus]"> |
91 |
<div type="text" id="{$filename}-{count(preceding::tei:text) + 1}" xmlns="http://www.tei-c.org/ns/1.0"> |
92 |
<xsl:apply-templates select="@*|node()"/> |
93 |
</div> |
94 |
</xsl:template> |
95 |
|
96 |
<xsl:template match="tei:w[not(tei:seg[@type='wp'])]"> |
97 |
<xsl:element name="w" namespace="http://www.tei-c.org/ns/1.0"> |
98 |
<xsl:apply-templates select="@*"/> |
99 |
<xsl:attribute name="expan"><xsl:apply-templates mode="expan"/></xsl:attribute> |
100 |
<xsl:attribute name="letters-all"><xsl:apply-templates mode="letters-all"/></xsl:attribute> |
101 |
<xsl:attribute name="letters-alignable"><xsl:apply-templates mode="letters-alignable"/></xsl:attribute> |
102 |
<xsl:attribute name="characters"><xsl:apply-templates mode="characters-alignable"/></xsl:attribute> |
103 |
<xsl:attribute name="abbr-n"> |
104 |
<xsl:value-of select="count(descendant::tei:abbr)"/> |
105 |
</xsl:attribute> |
106 |
<xsl:attribute name="ref"><xsl:value-of select="concat($filename,', p. ',preceding::tei:pb[1]/@n,', col. ',preceding::tei:cb[1]/@n,', l. ',preceding::tei:lb[1]/@n)"/></xsl:attribute> |
107 |
<xsl:apply-templates/> |
108 |
</xsl:element> |
109 |
</xsl:template> |
110 |
|
111 |
<xsl:template match="tei:w[tei:seg[@type='wp']]"> |
112 |
<xsl:element name="w-lb" namespace="http://www.tei-c.org/ns/1.0"> |
113 |
<xsl:apply-templates select="@*"/> |
114 |
<xsl:attribute name="expan"><xsl:apply-templates mode="expan"/></xsl:attribute> |
115 |
<xsl:attribute name="letters-all"><xsl:apply-templates mode="letters-all"/></xsl:attribute> |
116 |
<xsl:attribute name="letters-alignable"><xsl:apply-templates mode="letters-alignable"/></xsl:attribute> |
117 |
<xsl:attribute name="characters"><xsl:apply-templates mode="characters-alignable"/></xsl:attribute> |
118 |
<xsl:attribute name="abbr-n"> |
119 |
<xsl:value-of select="count(descendant::tei:abbr)"/> |
120 |
</xsl:attribute> |
121 |
<xsl:attribute name="ref"><xsl:value-of select="concat($filename,', p. ',preceding::tei:pb[1]/@n,', col. ',preceding::tei:cb[1]/@n,', l. ',preceding::tei:lb[1]/@n)"/></xsl:attribute> |
122 |
<xsl:apply-templates/> |
123 |
</xsl:element> |
124 |
</xsl:template> |
125 |
|
126 |
<xsl:template match="tei:seg[@type='wp']"> |
127 |
<xsl:element name="w" namespace="http://www.tei-c.org/ns/1.0"> |
128 |
<xsl:apply-templates select="@*"/> |
129 |
<xsl:attribute name="expan"><xsl:apply-templates mode="expan"/></xsl:attribute> |
130 |
<xsl:attribute name="letters-all"><xsl:apply-templates mode="letters-all"/></xsl:attribute> |
131 |
<xsl:attribute name="letters-alignable"><xsl:apply-templates mode="letters-alignable"/></xsl:attribute> |
132 |
<xsl:attribute name="characters"><xsl:apply-templates mode="characters-alignable"/></xsl:attribute> |
133 |
<xsl:attribute name="abbr-n"> |
134 |
<xsl:value-of select="count(descendant::tei:abbr)"/> |
135 |
</xsl:attribute> |
136 |
<xsl:attribute name="ref"><xsl:value-of select="concat($filename,', p. ',preceding::tei:pb[1]/@n,', col. ',preceding::tei:cb[1]/@n,', l. ',preceding::tei:lb[1]/@n)"/></xsl:attribute> |
137 |
<xsl:apply-templates/> |
138 |
</xsl:element> |
139 |
</xsl:template> |
140 |
|
141 |
<xsl:template match="tei:pc[not(child::tei:reg or @ana='ori:align-no')]"> |
142 |
<xsl:element name="w" namespace="http://www.tei-c.org/ns/1.0"> |
143 |
<xsl:apply-templates select="@*"/> |
144 |
<xsl:attribute name="type">pc</xsl:attribute> |
145 |
<xsl:attribute name="expan"><xsl:apply-templates/></xsl:attribute> |
146 |
<xsl:attribute name="letters-all"/> |
147 |
<xsl:attribute name="letters-alignable"/> |
148 |
<xsl:attribute name="characters"><xsl:apply-templates mode="characters-alignable"/></xsl:attribute> |
149 |
<xsl:attribute name="abbr-n"> |
150 |
<xsl:value-of select="0"/> |
151 |
</xsl:attribute> |
152 |
<xsl:attribute name="ref"><xsl:value-of select="concat($filename,', p. ',preceding::tei:pb[1]/@n,', col. ',preceding::tei:cb[1]/@n,', l. ',preceding::tei:lb[1]/@n)"/></xsl:attribute> |
153 |
<xsl:apply-templates/> |
154 |
</xsl:element> |
155 |
</xsl:template> |
156 |
|
157 |
<xsl:template match="tei:pc[child::tei:reg or @ana='ori:align-no']"> |
158 |
<xsl:comment><xsl:copy-of select="."/></xsl:comment> |
159 |
</xsl:template> |
160 |
|
161 |
<xsl:template match="tei:choice[tei:abbr]"> |
162 |
<xsl:apply-templates select="tei:abbr"/> |
163 |
</xsl:template> |
164 |
|
165 |
<xsl:template match="tei:choice[tei:abbr]" mode="expan"> |
166 |
<xsl:apply-templates select="tei:expan" mode="#current"/> |
167 |
</xsl:template> |
168 |
|
169 |
<xsl:template match="tei:choice[tei:abbr]" mode="letters-all"> |
170 |
<xsl:apply-templates select="tei:expan" mode="#current"/> |
171 |
</xsl:template> |
172 |
|
173 |
<xsl:template match="tei:choice[tei:abbr]" mode="letters-alignable"> |
174 |
<xsl:apply-templates select="tei:expan" mode="#current"/> |
175 |
</xsl:template> |
176 |
|
177 |
<xsl:template match="tei:choice[tei:abbr]" mode="characters-alignable"> |
178 |
<xsl:apply-templates select="tei:abbr" mode="#current"/> |
179 |
</xsl:template> |
180 |
|
181 |
<xsl:template match="tei:choice[tei:orig]" mode="#all"> |
182 |
<xsl:apply-templates select="tei:orig" mode="#current"/> |
183 |
</xsl:template> |
184 |
|
185 |
<xsl:template match="tei:reg" mode="#all"></xsl:template> |
186 |
|
187 |
<xsl:template match="tei:orig" mode="#all"> |
188 |
<xsl:apply-templates mode="#current"/> |
189 |
</xsl:template> |
190 |
|
191 |
<xsl:template match="tei:ex" mode="expan"> |
192 |
<xsl:text>(</xsl:text> |
193 |
<xsl:value-of select="."/> |
194 |
<xsl:text>)</xsl:text> |
195 |
</xsl:template> |
196 |
|
197 |
<xsl:template match="tei:ex" mode="letters-all"> |
198 |
<xsl:value-of select="."/> |
199 |
</xsl:template> |
200 |
|
201 |
<xsl:template match="tei:ex" mode="letters-alignable"/> |
202 |
|
203 |
<xsl:template match="tei:ex" mode="characters-alignable"> |
204 |
<xsl:choose> |
205 |
<xsl:when test="matches(.,'^(cum|com|con)$','i')">ꝯ</xsl:when> |
206 |
<xsl:when test="matches(.,'^et$','i')">⁊</xsl:when> |
207 |
<xsl:when test="matches(.,'^est$','i')">∻</xsl:when> |
208 |
<xsl:when test="matches(.,'^us$','i')">ꝰ</xsl:when> |
209 |
<xsl:otherwise/> |
210 |
</xsl:choose> |
211 |
</xsl:template> |
212 |
|
213 |
<xsl:template match="tei:supplied"></xsl:template> |
214 |
|
215 |
|
216 |
|
217 |
|
218 |
<xsl:template match="tei:w//text()" mode="letters-alignable characters-alignable"> |
219 |
<xsl:analyze-string select="." regex="\p{{M}}"> |
220 |
<xsl:matching-substring/> |
221 |
<xsl:non-matching-substring><xsl:value-of select="."/></xsl:non-matching-substring> |
222 |
</xsl:analyze-string> |
223 |
</xsl:template> |
224 |
|
225 |
</xsl:stylesheet> |