|
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" xmlns:txm="http://textometrie.org/1.0"
|
|
4 |
exclude-result-prefixes="tei edate" version="2.0">
|
|
5 |
|
|
6 |
<!--
|
|
7 |
Copyright © 2019 ENS de Lyon, CNRS, University of Franche-Comté
|
|
8 |
Licensed under the terms of the GNU General Public License (http://www.gnu.org/licenses)
|
|
9 |
@author Alexei Lavrentiev
|
|
10 |
-->
|
|
11 |
|
|
12 |
<!-- This stylesheet converts TEI-TXM files to the format compatible with
|
|
13 |
XML TEI Zero (XTZ) and XML/w import modules.
|
|
14 |
All annotations encoded as txm:ana elements are converted to attributes of
|
|
15 |
w elements. Customize the annotationsToKeep parameter to select the annotations
|
|
16 |
to keep.
|
|
17 |
-->
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="yes"/>
|
|
22 |
|
|
23 |
<xsl:strip-space elements="*"/>
|
|
24 |
|
|
25 |
|
|
26 |
<!-- provide the names of annotations to keep in the form of a regular expression, e.g. pos|lemma -->
|
|
27 |
<xsl:param name="annotationsToKeep">.*</xsl:param>
|
|
28 |
|
|
29 |
<xsl:variable name="filename">
|
|
30 |
<xsl:analyze-string select="document-uri(.)" regex="/([^/.]+)\.[^/.]*$">
|
|
31 |
<xsl:matching-substring>
|
|
32 |
<xsl:value-of select="regex-group(1)"/>
|
|
33 |
</xsl:matching-substring>
|
|
34 |
</xsl:analyze-string>
|
|
35 |
</xsl:variable>
|
|
36 |
|
|
37 |
<!-- <xsl:variable name="filedir">
|
|
38 |
<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)$">
|
|
39 |
<xsl:matching-substring>
|
|
40 |
<xsl:value-of select="regex-group(1)"/>
|
|
41 |
</xsl:matching-substring>
|
|
42 |
</xsl:analyze-string>
|
|
43 |
</xsl:variable>-->
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
<xsl:template match="*">
|
|
49 |
<xsl:choose>
|
|
50 |
<xsl:when test="namespace-uri()=''">
|
|
51 |
<xsl:element namespace="http://www.tei-c.org/ns/1.0" name="{local-name(.)}">
|
|
52 |
<xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
|
|
53 |
</xsl:element>
|
|
54 |
</xsl:when>
|
|
55 |
<xsl:otherwise>
|
|
56 |
<xsl:copy>
|
|
57 |
<xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
|
|
58 |
</xsl:copy>
|
|
59 |
</xsl:otherwise>
|
|
60 |
</xsl:choose>
|
|
61 |
</xsl:template>
|
|
62 |
|
|
63 |
<xsl:template match="@*|processing-instruction()|comment()">
|
|
64 |
<xsl:copy/>
|
|
65 |
</xsl:template>
|
|
66 |
|
|
67 |
<xsl:template match="text()">
|
|
68 |
<xsl:value-of select="normalize-space(.)"/>
|
|
69 |
</xsl:template>
|
|
70 |
|
|
71 |
<xsl:template match="tei:w">
|
|
72 |
<xsl:element name="w" namespace="http://www.tei-c.org/ns/1.0">
|
|
73 |
<xsl:for-each select="descendant::txm:ana[matches(@type,concat('^#(',$annotationsToKeep,')$'))]">
|
|
74 |
<xsl:attribute name="{substring(@type,2)}"><xsl:value-of select="normalize-space(.)"/></xsl:attribute>
|
|
75 |
</xsl:for-each>
|
|
76 |
<xsl:attribute name="xml:id"><xsl:value-of select="@*[local-name()='id'][1]"/></xsl:attribute>
|
|
77 |
<!-- decomment the line below to keep the attributes of words from XML-TEI TXM file -->
|
|
78 |
<!--<xsl:copy-of select="@*"/>-->
|
|
79 |
<xsl:apply-templates select="txm:form"/>
|
|
80 |
</xsl:element>
|
|
81 |
</xsl:template>
|
|
82 |
|
|
83 |
<xsl:template match="txm:form">
|
|
84 |
<xsl:apply-templates/>
|
|
85 |
</xsl:template>
|
|
86 |
|
|
87 |
</xsl:stylesheet>
|
0 |
88 |
|