root / tmp / org.txm.oriflamms.rcp / res / txm-front-teioriflammsw-xtz.xsl @ 476
History | View | Annotate | Download (12.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 |
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:facsimile"/> |
65 |
|
66 |
<xsl:template match="tei:teiCorpus"> |
67 |
<TEI xmlns="http://www.tei-c.org/ns/1.0"> |
68 |
<text> |
69 |
<!-- on ajoute des attributs utiles pour la création de partitions et de sous-corpus --> |
70 |
<xsl:apply-templates/> |
71 |
</text> |
72 |
</TEI> |
73 |
</xsl:template> |
74 |
|
75 |
|
76 |
<xsl:template match="tei:TEI[ancestor::tei:teiCorpus]"> |
77 |
<xsl:apply-templates/> |
78 |
</xsl:template> |
79 |
|
80 |
<xsl:template match="tei:teiHeader"> |
81 |
<!--<xsl:copy-of select="."/>--> |
82 |
</xsl:template> |
83 |
|
84 |
<xsl:template match="tei:text[not(ancestor::tei:teiCorpus)]"> |
85 |
<xsl:element name="text" namespace="http://www.tei-c.org/ns/1.0"> |
86 |
<!-- on ajoute des attributs utiles pour la création de partitions et de sous-corpus --> |
87 |
<xsl:apply-templates select="@*"/> |
88 |
<xsl:apply-templates/> |
89 |
</xsl:element> |
90 |
</xsl:template> |
91 |
|
92 |
<xsl:template match="tei:text[ancestor::tei:teiCorpus]"> |
93 |
<div type="text" id="{$filename}-{count(preceding::tei:text) + 1}" xmlns="http://www.tei-c.org/ns/1.0"> |
94 |
<xsl:apply-templates select="@*|node()"/> |
95 |
</div> |
96 |
</xsl:template> |
97 |
|
98 |
<xsl:template match="tei:milestone[@unit='surface']"> |
99 |
<pb xmlns="http://www.tei-c.org/ns/1.0" n="{following::tei:pb[1]/@n}" facs="{@facs}" xml:id="{@xml:id}"/> |
100 |
</xsl:template> |
101 |
|
102 |
<xsl:template match="tei:pb"> |
103 |
<milestone unit="ms-page"> |
104 |
<xsl:apply-templates select="@*"/> |
105 |
</milestone> |
106 |
</xsl:template> |
107 |
|
108 |
<xsl:template match="tei:w[not(tei:seg[@type='wp'])]"> |
109 |
<xsl:element name="w" namespace="http://www.tei-c.org/ns/1.0"> |
110 |
<xsl:apply-templates select="@*"/> |
111 |
<xsl:attribute name="expan"><xsl:apply-templates mode="expan"/></xsl:attribute> |
112 |
<xsl:attribute name="letters-all"><xsl:apply-templates mode="letters-all"/></xsl:attribute> |
113 |
<xsl:attribute name="letters-alignable"><xsl:apply-templates mode="letters-alignable"/></xsl:attribute> |
114 |
<xsl:attribute name="characters"><xsl:apply-templates mode="characters-alignable"/></xsl:attribute> |
115 |
<xsl:attribute name="abbr-n"> |
116 |
<xsl:choose> |
117 |
<xsl:when test="descendant::tei:abbr"> |
118 |
<xsl:value-of select="count(descendant::tei:abbr)"/> |
119 |
</xsl:when> |
120 |
<xsl:when test="descendant::tei:expan"> |
121 |
<xsl:value-of select="count(descendant::tei:expan)"/> |
122 |
</xsl:when> |
123 |
<xsl:when test="descendant::tei:ex"> |
124 |
<xsl:value-of select="count(descendant::tei:ex)"/> |
125 |
</xsl:when> |
126 |
<xsl:otherwise>0</xsl:otherwise> |
127 |
</xsl:choose> |
128 |
</xsl:attribute> |
129 |
<xsl:attribute name="ref"><xsl:value-of select="concat($filename,', f. ',preceding::tei:pb[1]/@n,', col. ',preceding::tei:cb[1]/@n,', l. ',preceding::tei:lb[1]/@n)"/></xsl:attribute> |
130 |
<xsl:apply-templates/> |
131 |
</xsl:element> |
132 |
</xsl:template> |
133 |
|
134 |
<xsl:template match="tei:w[tei:seg[@type='wp']]"> |
135 |
<xsl:element name="w-lb" namespace="http://www.tei-c.org/ns/1.0"> |
136 |
<xsl:apply-templates select="@*"/> |
137 |
<xsl:attribute name="expan"><xsl:apply-templates mode="expan"/></xsl:attribute> |
138 |
<xsl:attribute name="letters-all"><xsl:apply-templates mode="letters-all"/></xsl:attribute> |
139 |
<xsl:attribute name="letters-alignable"><xsl:apply-templates mode="letters-alignable"/></xsl:attribute> |
140 |
<xsl:attribute name="characters"><xsl:apply-templates mode="characters-alignable"/></xsl:attribute> |
141 |
<xsl:attribute name="abbr-n"> |
142 |
<xsl:choose> |
143 |
<xsl:when test="descendant::tei:abbr"> |
144 |
<xsl:value-of select="count(descendant::tei:abbr)"/> |
145 |
</xsl:when> |
146 |
<xsl:when test="descendant::tei:expan"> |
147 |
<xsl:value-of select="count(descendant::tei:expan)"/> |
148 |
</xsl:when> |
149 |
<xsl:when test="descendant::tei:ex"> |
150 |
<xsl:value-of select="count(descendant::tei:ex)"/> |
151 |
</xsl:when> |
152 |
<xsl:otherwise>0</xsl:otherwise> |
153 |
</xsl:choose> |
154 |
</xsl:attribute> |
155 |
<xsl:attribute name="ref"><xsl:value-of select="concat($filename,', f. ',preceding::tei:pb[1]/@n,', col. ',preceding::tei:cb[1]/@n,', l. ',preceding::tei:lb[1]/@n)"/></xsl:attribute> |
156 |
<xsl:apply-templates/> |
157 |
</xsl:element> |
158 |
</xsl:template> |
159 |
|
160 |
<xsl:template match="tei:seg[@type='wp']"> |
161 |
<xsl:element name="w" namespace="http://www.tei-c.org/ns/1.0"> |
162 |
<xsl:apply-templates select="@*"/> |
163 |
<xsl:attribute name="expan"><xsl:apply-templates mode="expan"/></xsl:attribute> |
164 |
<xsl:attribute name="letters-all"><xsl:apply-templates mode="letters-all"/></xsl:attribute> |
165 |
<xsl:attribute name="letters-alignable"><xsl:apply-templates mode="letters-alignable"/></xsl:attribute> |
166 |
<xsl:attribute name="characters"><xsl:apply-templates mode="characters-alignable"/></xsl:attribute> |
167 |
<xsl:attribute name="abbr-n"> |
168 |
<xsl:value-of select="count(descendant::tei:abbr)"/> |
169 |
</xsl:attribute> |
170 |
<xsl:attribute name="ref"><xsl:value-of select="concat($filename,', f. ',preceding::tei:pb[1]/@n,', col. ',preceding::tei:cb[1]/@n,', l. ',preceding::tei:lb[1]/@n)"/></xsl:attribute> |
171 |
<xsl:apply-templates/> |
172 |
</xsl:element> |
173 |
</xsl:template> |
174 |
|
175 |
<xsl:template match="tei:pc[not(child::tei:reg or @ana='ori:align-no')]"> |
176 |
<xsl:element name="w" namespace="http://www.tei-c.org/ns/1.0"> |
177 |
<xsl:apply-templates select="@*"/> |
178 |
<xsl:attribute name="type">pc</xsl:attribute> |
179 |
<xsl:attribute name="expan"><xsl:apply-templates/></xsl:attribute> |
180 |
<xsl:attribute name="letters-all"><xsl:apply-templates mode="letters-all"/></xsl:attribute> |
181 |
<xsl:attribute name="letters-alignable"><xsl:apply-templates mode="letters-alignable"/></xsl:attribute> |
182 |
<xsl:attribute name="characters"><xsl:apply-templates mode="characters-alignable"/></xsl:attribute> |
183 |
<xsl:attribute name="abbr-n"> |
184 |
<xsl:value-of select="0"/> |
185 |
</xsl:attribute> |
186 |
<xsl:attribute name="ref"><xsl:value-of select="concat($filename,', f. ',preceding::tei:pb[1]/@n,', col. ',preceding::tei:cb[1]/@n,', l. ',preceding::tei:lb[1]/@n)"/></xsl:attribute> |
187 |
<xsl:apply-templates/> |
188 |
</xsl:element> |
189 |
</xsl:template> |
190 |
|
191 |
<xsl:template match="tei:pc[child::tei:reg or @ana='ori:align-no']"> |
192 |
<xsl:comment><xsl:copy-of select="."/></xsl:comment> |
193 |
</xsl:template> |
194 |
|
195 |
<xsl:template match="tei:choice[tei:abbr]"> |
196 |
<xsl:apply-templates select="tei:abbr"/> |
197 |
</xsl:template> |
198 |
|
199 |
<xsl:template match="tei:choice[tei:abbr]" mode="expan"> |
200 |
<xsl:apply-templates select="tei:expan" mode="#current"/> |
201 |
</xsl:template> |
202 |
|
203 |
<xsl:template match="tei:choice[tei:abbr]" mode="letters-all"> |
204 |
<xsl:apply-templates select="tei:expan" mode="#current"/> |
205 |
</xsl:template> |
206 |
|
207 |
<xsl:template match="tei:choice[tei:abbr]" mode="letters-alignable"> |
208 |
<xsl:choose> |
209 |
<xsl:when test="tei:expan[tei:ex]"> |
210 |
<xsl:apply-templates select="tei:expan" mode="#current"/> |
211 |
</xsl:when> |
212 |
<xsl:otherwise> |
213 |
<xsl:apply-templates select="tei:abbr" mode="#current"/> |
214 |
</xsl:otherwise> |
215 |
</xsl:choose> |
216 |
</xsl:template> |
217 |
|
218 |
<xsl:template match="tei:choice[tei:abbr]" mode="characters-alignable"> |
219 |
<xsl:apply-templates select="tei:abbr" mode="#current"/> |
220 |
</xsl:template> |
221 |
|
222 |
<xsl:template match="tei:choice[tei:orig]" mode="#all"> |
223 |
<xsl:apply-templates select="tei:orig" mode="#current"/> |
224 |
</xsl:template> |
225 |
|
226 |
<xsl:template match="tei:abbr" mode="letters-alignable"> |
227 |
<xsl:apply-templates select="descendant::text()" mode="letters-alignable"/> |
228 |
</xsl:template> |
229 |
|
230 |
<xsl:template match="tei:reg" mode="#all"></xsl:template> |
231 |
|
232 |
<xsl:template match="tei:orig" mode="#all"> |
233 |
<xsl:apply-templates mode="#current"/> |
234 |
</xsl:template> |
235 |
|
236 |
<xsl:template match="tei:ex" mode="expan"> |
237 |
<xsl:text>(</xsl:text> |
238 |
<xsl:value-of select="normalize-space(.)"/> |
239 |
<xsl:text>)</xsl:text> |
240 |
</xsl:template> |
241 |
|
242 |
<xsl:template match="tei:ex" mode="letters-all"> |
243 |
<xsl:value-of select="normalize-space(.)"/> |
244 |
</xsl:template> |
245 |
|
246 |
<xsl:template match="tei:ex" mode="letters-alignable"/> |
247 |
|
248 |
<xsl:template match="tei:ex" mode="characters-alignable"> |
249 |
<xsl:choose> |
250 |
<xsl:when test="matches(.,'^(cum|com|con)$','i')">ꝯ</xsl:when> |
251 |
<xsl:when test="matches(.,'^et$','i')">⁊</xsl:when> |
252 |
<xsl:when test="matches(.,'^est$','i')">∻</xsl:when> |
253 |
<xsl:when test="matches(.,'^us$','i')">ꝰ</xsl:when> |
254 |
<xsl:otherwise/> |
255 |
</xsl:choose> |
256 |
</xsl:template> |
257 |
|
258 |
<xsl:template match="tei:supplied"></xsl:template> |
259 |
|
260 |
|
261 |
<xsl:template match="text()" mode="expan letters-all"> |
262 |
<xsl:value-of select="normalize-space(.)"/> |
263 |
</xsl:template> |
264 |
|
265 |
|
266 |
<xsl:template match="tei:w//text()" mode="characters-alignable"> |
267 |
<xsl:analyze-string select="." regex="\p{{M}}|\s"> |
268 |
<xsl:matching-substring/> |
269 |
<xsl:non-matching-substring><xsl:value-of select="."/></xsl:non-matching-substring> |
270 |
</xsl:analyze-string> |
271 |
</xsl:template> |
272 |
|
273 |
<xsl:template match="tei:w//text()" mode="letters-alignable"> |
274 |
<xsl:analyze-string select="." regex="."> |
275 |
<xsl:matching-substring> |
276 |
<xsl:choose> |
277 |
<xsl:when test="matches(.,'\p{M}|\s')"></xsl:when> |
278 |
<xsl:when test="matches(.,$alignable-abbreviation-marks)"/> |
279 |
<xsl:when test="matches(.,$modified-letters)"> |
280 |
<xsl:call-template name="modified-letters"/> |
281 |
</xsl:when> |
282 |
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> |
283 |
</xsl:choose> |
284 |
</xsl:matching-substring> |
285 |
</xsl:analyze-string> |
286 |
</xsl:template> |
287 |
|
288 |
<xsl:variable name="modified-letters">^(Ł|ł|[Ꝉ-ꝙ])$</xsl:variable> |
289 |
<xsl:variable name="alignable-abbreviation-marks">^(&|⁊|⁹|∻|ꝯ|ꝰ|||)$</xsl:variable> |
290 |
|
291 |
<xsl:template name="modified-letters"> |
292 |
<xsl:choose> |
293 |
<xsl:when test="matches(.,'Ł|Ꝉ')">L</xsl:when> |
294 |
<xsl:when test="matches(.,'ł|ꝉ')">l</xsl:when> |
295 |
<xsl:when test="matches(.,'Ꝑ|Ꝓ|Ꝕ')">P</xsl:when> |
296 |
<xsl:when test="matches(.,'ꝑ|ꝓ|ꝕ')">p</xsl:when> |
297 |
<xsl:when test="matches(.,'Ꝗ|Ꝙ')">Q</xsl:when> |
298 |
<xsl:when test="matches(.,'ꝗ|ꝙ')">q</xsl:when> |
299 |
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> |
300 |
</xsl:choose> |
301 |
</xsl:template> |
302 |
|
303 |
</xsl:stylesheet> |