root / tmp / org.txm.oriflamms.rcp / bin / oriflamms-tokenize-words-1-tag.xsl @ 476
History | View | Annotate | Download (5.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:xd="http://www.pnp-software.com/XSLTdoc" |
5 |
xmlns:txm="http://textometrie.org/1.0" |
6 |
exclude-result-prefixes="tei edate xd txm" version="2.0"> |
7 |
|
8 |
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="no"/> |
9 |
|
10 |
<xd:doc type="stylesheet"> |
11 |
<xd:short> |
12 |
Cette feuille XSLT permet de pré-tokeniser par mot des fichiers au format |
13 |
XML-TEI Oriflamms brut |
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>2014, CNRS / ICAR (Équipe CACTUS)</xd:copyright> |
31 |
</xd:doc> |
32 |
|
33 |
<!-- <xsl:template match="/"> |
34 |
<xsl:apply-templates/> |
35 |
</xsl:template> |
36 |
--> |
37 |
|
38 |
<xsl:template match="*"> |
39 |
<xsl:copy> |
40 |
<xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/> |
41 |
</xsl:copy> |
42 |
</xsl:template> |
43 |
|
44 |
<xsl:template match="comment()|processing-instruction()|text()"> |
45 |
<xsl:copy/> |
46 |
</xsl:template> |
47 |
|
48 |
<!-- On supprime les attributs par défaut de la DTD TEI --> |
49 |
|
50 |
<xsl:template match="@*"> |
51 |
<xsl:choose> |
52 |
<xsl:when test="matches(name(.),'^(part|instant|anchored|full)$')"/> |
53 |
<xsl:otherwise><xsl:copy/></xsl:otherwise> |
54 |
</xsl:choose> |
55 |
</xsl:template> |
56 |
|
57 |
<!-- <xsl:template match="tei:teiHeader"> |
58 |
<xsl:copy-of select="."/> |
59 |
</xsl:template> |
60 |
--> |
61 |
<xsl:template match="tei:text/tei:body/tei:div1[@type='original']//tei:p//text()"> |
62 |
<xsl:choose> |
63 |
<!--<xsl:when test="not(ancestor::tei:text/tei:body/tei:div1/tei:p)"><xsl:copy/></xsl:when>--> |
64 |
<xsl:when test="matches(.,'^\s*$')"><xsl:copy/></xsl:when> |
65 |
<xsl:when test="matches(local-name(parent::*),'^(abbr|expan|sic|corr)$')"><xsl:copy/></xsl:when> |
66 |
<xsl:when test="matches(ancestor::*/@*,'ori:align-no')"><xsl:copy/></xsl:when> |
67 |
<xsl:when test="ancestor::tei:note"><xsl:copy/></xsl:when> |
68 |
<xsl:when test="parent::tei:hi and matches(.,'\w+') and not(matches(.,'\s'))"><xsl:copy/></xsl:when> |
69 |
<xsl:when test="parent::tei:am"><xsl:copy/></xsl:when> |
70 |
<xsl:when test="parent::tei:rdg[not(matches(@wit,'^#?A'))]"><xsl:copy/></xsl:when> |
71 |
<xsl:when test="ancestor::tei:pc"><xsl:copy/></xsl:when> |
72 |
<xsl:otherwise> |
73 |
<xsl:analyze-string select="." regex="\w+|\p{{P}}+|\s+"> |
74 |
<xsl:matching-substring> |
75 |
<xsl:choose> |
76 |
<xsl:when test="matches(.,'^\w+$')"><w xmlns="http://www.tei-c.org/ns/1.0"><xsl:value-of select="."/></w></xsl:when> |
77 |
<!-- <xsl:when test="matches(.,'^\p{P}+$')"><orig xmlns="http://www.tei-c.org/ns/1.0"><pc xmlns="http://www.tei-c.org/ns/1.0"><xsl:value-of select="."/></pc></orig></xsl:when>--> |
78 |
<xsl:when test="matches(.,'^\p{P}+$')"><pc xmlns="http://www.tei-c.org/ns/1.0"><xsl:value-of select="."/></pc></xsl:when> |
79 |
<xsl:otherwise><xsl:copy/></xsl:otherwise> |
80 |
</xsl:choose> |
81 |
</xsl:matching-substring> |
82 |
<xsl:non-matching-substring> |
83 |
<xsl:comment>Type de caractère non reconnu</xsl:comment><xsl:copy/> |
84 |
</xsl:non-matching-substring> |
85 |
</xsl:analyze-string> |
86 |
</xsl:otherwise> |
87 |
</xsl:choose> |
88 |
</xsl:template> |
89 |
|
90 |
<xsl:template match="tei:choice"> |
91 |
<xsl:choose> |
92 |
<xsl:when test="descendant::tei:pc"> |
93 |
<pc xmlns="http://www.tei-c.org/ns/1.0"> |
94 |
<xsl:apply-templates select="descendant::tei:pc[1]/@*"/> |
95 |
<xsl:copy> |
96 |
<xsl:apply-templates/> |
97 |
</xsl:copy> |
98 |
</pc> |
99 |
</xsl:when> |
100 |
<xsl:otherwise><w xmlns="http://www.tei-c.org/ns/1.0"><xsl:copy-of select="."/></w></xsl:otherwise> |
101 |
</xsl:choose> |
102 |
</xsl:template> |
103 |
|
104 |
<!-- <xsl:template match="tei:pc[ancestor::tei:choice]"> |
105 |
<xsl:apply-templates/> |
106 |
</xsl:template> |
107 |
--> |
108 |
|
109 |
<xsl:template match="tei:choice/tei:orig[child::tei:pc]|tei:choice/tei:reg[child::tei:pc]"> |
110 |
<xsl:copy> |
111 |
<xsl:apply-templates select="@*"/> |
112 |
<xsl:value-of select="normalize-space(.)"/> |
113 |
</xsl:copy> |
114 |
</xsl:template> |
115 |
|
116 |
<xsl:template match="tei:hi[matches(.,'\w+') and not(matches(.,'\s'))]|tei:am"> |
117 |
<w xmlns="http://www.tei-c.org/ns/1.0"><xsl:copy-of select="."/></w> |
118 |
</xsl:template> |
119 |
|
120 |
|
121 |
|
122 |
<xsl:template match="tei:sic[not(parent::tei:choice)]|tei:corr[not(parent::tei:choice)]"> |
123 |
<w xmlns="http://www.tei-c.org/ns/1.0"><xsl:copy-of select="."/></w> |
124 |
</xsl:template> |
125 |
|
126 |
</xsl:stylesheet> |