Revision 2398 tmp/org.txm.oriflamms.rcp/res/oriflamms-convert-charrettenew-oriflammsxml.xsl

oriflamms-convert-charrettenew-oriflammsxml.xsl (revision 2398)
1 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">
2
<xsl:stylesheet
3
	xmlns:edate="http://exslt.org/dates-and-times"
4
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
	xmlns:tei="http://www.tei-c.org/ns/1.0"
6
	xmlns:xd="http://www.pnp-software.com/XSLTdoc"
7
	xmlns:txm="http://textometrie.org/1.0"
8
	exclude-result-prefixes="tei edate xd txm" version="2.0">
7 9

  
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 permet de convertir la transcription compacte de la 
13
      Queste del saint Graal au format XML-TEI du projet Oriflamms.
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="@*"/>
41
          <xsl:apply-templates select="*|processing-instruction()|comment()|text()"/>
42
        </xsl:copy>
43
  </xsl:template>
10
	<xsl:output method="xml" encoding="utf-8"
11
		omit-xml-declaration="no" indent="no" />
44 12

  
45
  <xsl:template match="comment()|text()">
46
    <xsl:copy/>
47
  </xsl:template>
48
  
49
  <xsl:template match="processing-instruction()"></xsl:template>
13
	<xd:doc type="stylesheet">
14
		<xd:short>
15
			Cette feuille permet de convertir la transcription compacte de la
16
			Queste del saint Graal au format XML-TEI du projet Oriflamms.
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.
50 23

  
51
  <!-- On supprime les attributs par défaut de la DTD TEI -->
52
  
53
  <xsl:template match="@*">
54
    <xsl:choose>
55
      <xsl:when test="matches(name(.),'^(part|instant|anchored|full)$')"/>
56
      <xsl:when test="matches(name(.),'rend')">
57
        <xsl:choose>
58
          <xsl:when test="matches(.,'^aggl$')"><xsl:attribute name="rend">space-after(none)</xsl:attribute></xsl:when>
59
          <xsl:otherwise><xsl:copy/></xsl:otherwise>
60
        </xsl:choose>
61
      </xsl:when>
62
      <xsl:otherwise><xsl:copy/></xsl:otherwise>
63
    </xsl:choose>
64
  </xsl:template>
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.
65 28

  
66
  <xsl:template match="tei:teiHeader">    
67
      <xsl:copy>
68
        <xsl:apply-templates select="@*"/>
69
        <xsl:apply-templates/>
70
      </xsl:copy>    
71
  </xsl:template>
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>2014, CNRS / ICAR (Équipe CACTUS)</xd:copyright>
34
	</xd:doc>
72 35

  
73
<xsl:template match="tei:revisionDesc">
74
  <xsl:copy>
75
  <xsl:apply-templates select="@*"/>
76
  <change xmlns="http://www.tei-c.org/ns/1.0" when="{format-date(current-date(),'[Y]-[M01]-[D01]')}" who="#auto">Conversion automatique au format XML-TEI-Oriflamms</change>
77
  <xsl:apply-templates/>
78
  </xsl:copy>
79
</xsl:template>
80
  
81
  <xsl:template match="tei:encodingDesc">
82
    <xsl:copy>
83
      <xsl:apply-templates select="@*"/>
84
      <xsl:apply-templates/>
85
      <xsl:if test="not(//tei:prefixDef[@ident='ori'])">
86
        <listPrefixDef xmlns="http://www.tei-c.org/ns/1.0">
87
          <prefixDef xmlns="http://www.tei-c.org/ns/1.0" ident="ori" 
88
            matchPattern="([a-z]+)" 
89
            replacementPattern="oriflamms-annotation-scheme.xml#$1">
90
            <p>In the context of this project, private URIs with the prefix
91
              "ori" point to <gi>interp</gi> elements in the project's
92
              oriflamms-annotation-scheme.xml file.
93
            </p>
94
          </prefixDef>
95
        </listPrefixDef>
96
      </xsl:if>
97
    </xsl:copy>
98
  </xsl:template>
36
	<xsl:template match="/">
37
		<xsl:apply-templates />
38
	</xsl:template>
99 39

  
100 40

  
101
<xsl:template match="tei:div3[@facs]">
102
  <xsl:variable name="facs">
103
    <xsl:value-of select="@facs"/>
104
  </xsl:variable>
105
  <xsl:if test="not(preceding::tei:div3/@facs=$facs)">
106
    <milestone unit="surface" xmlns="http://www.tei-c.org/ns/1.0" facs="{@facs}"/>
107
  </xsl:if>
108
    
109
  <pb xmlns="http://www.tei-c.org/ns/1.0" facs="{@facs}" n="{parent::div2/@n}{@n}"/>
110
  <xsl:copy>
111
    <xsl:apply-templates select="@*|node()"/>
112
  </xsl:copy>
113
</xsl:template>
114
  
115
  <xsl:template match="tei:div3[not(@facs)]">
116
    <xsl:copy>
117
      <xsl:apply-templates select="@*"/>
118
      <xsl:attribute name="ana"><xsl:text>ori:align-no</xsl:text></xsl:attribute>
119
      <xsl:apply-templates/>
120
    </xsl:copy>
121
  </xsl:template>
122
  
123
  <xsl:template match="tei:div4">
124
    <cb xmlns="http://www.tei-c.org/ns/1.0" n="{@n}"/>
125
    <xsl:copy>
126
      <xsl:apply-templates select="@*|node()"/>
127
    </xsl:copy>
128
  </xsl:template>
41
	<xsl:template match="*">
42
		<xsl:copy>
43
			<xsl:apply-templates select="@*" />
44
			<xsl:apply-templates
45
				select="*|processing-instruction()|comment()|text()" />
46
		</xsl:copy>
47
	</xsl:template>
129 48

  
130
  <xsl:template match="tei:l">
131
    <xsl:copy>
132
      <xsl:apply-templates select="@*"/>
133
      <lb xmlns="http://www.tei-c.org/ns/1.0" n="{@n}"/>
134
      <xsl:apply-templates/>
135
    </xsl:copy>
136
  </xsl:template>  
49
	<xsl:template match="comment()|text()">
50
		<xsl:copy />
51
	</xsl:template>
137 52

  
138
<xsl:template match="tei:note|tei:supplied|tei:head">
139
  <xsl:copy>
140
    <xsl:apply-templates select="@*"/>
141
    <xsl:attribute name="ana">
142
      <xsl:if test="@ana"><xsl:value-of select="concat(@ana,' ')"/></xsl:if>
53
	<xsl:template match="processing-instruction()"></xsl:template>
54

  
55
	<!-- On supprime les attributs par défaut de la DTD TEI -->
56

  
57
	<xsl:template match="@*">
58
		<xsl:choose>
59
			<xsl:when
60
				test="matches(name(.),'^(part|instant|anchored|full)$')" />
61
			<xsl:when test="matches(name(.),'rend')">
62
				<xsl:choose>
63
					<xsl:when test="matches(.,'^aggl$')">
64
						<xsl:attribute name="rend">space-after(none)</xsl:attribute>
65
					</xsl:when>
66
					<xsl:otherwise>
67
						<xsl:copy />
68
					</xsl:otherwise>
69
				</xsl:choose>
70
			</xsl:when>
71
			<xsl:otherwise>
72
				<xsl:copy />
73
			</xsl:otherwise>
74
		</xsl:choose>
75
	</xsl:template>
76

  
77
	<xsl:template match="tei:teiHeader">
78
		<xsl:copy>
79
			<xsl:apply-templates select="@*" />
80
			<xsl:apply-templates />
81
		</xsl:copy>
82
	</xsl:template>
83

  
84
	<xsl:template match="tei:revisionDesc">
85
		<xsl:copy>
86
			<xsl:apply-templates select="@*" />
87
			<change xmlns="http://www.tei-c.org/ns/1.0"
88
				when="{format-date(current-date(),'[Y]-[M01]-[D01]')}" who="#auto">Conversion
89
				automatique au format XML-TEI-Oriflamms</change>
90
			<xsl:apply-templates />
91
		</xsl:copy>
92
	</xsl:template>
93

  
94
	<xsl:template match="tei:encodingDesc">
95
		<xsl:copy>
96
			<xsl:apply-templates select="@*" />
97
			<xsl:apply-templates />
98
			<xsl:if test="not(//tei:prefixDef[@ident='ori'])">
99
				<listPrefixDef xmlns="http://www.tei-c.org/ns/1.0">
100
					<prefixDef xmlns="http://www.tei-c.org/ns/1.0"
101
						ident="ori" matchPattern="([a-z]+)"
102
						replacementPattern="oriflamms-annotation-scheme.xml#$1">
103
						<p>
104
							In the context of this project, private URIs with the prefix
105
							"ori" point to
106
							<gi>interp</gi>
107
							elements in the project's
108
							oriflamms-annotation-scheme.xml file.
109
						</p>
110
					</prefixDef>
111
				</listPrefixDef>
112
			</xsl:if>
113
		</xsl:copy>
114
	</xsl:template>
115

  
116

  
117
	<xsl:template match="tei:div3[@facs]">
118
		<xsl:variable name="facs">
119
			<xsl:value-of select="@facs" />
120
		</xsl:variable>
121
		<xsl:if test="not(preceding::tei:div3/@facs=$facs)">
122
			<milestone unit="surface"
123
				xmlns="http://www.tei-c.org/ns/1.0" facs="{@facs}" />
124
		</xsl:if>
125

  
126
		<pb xmlns="http://www.tei-c.org/ns/1.0" facs="{@facs}"
127
			n="{parent::div2/@n}{@n}" />
128
		<xsl:copy>
129
			<xsl:apply-templates select="@*|node()" />
130
		</xsl:copy>
131
	</xsl:template>
132

  
133
	<xsl:template match="tei:div3[not(@facs)]">
134
		<xsl:copy>
135
			<xsl:apply-templates select="@*" />
136
			<xsl:attribute name="ana"><xsl:text>ori:align-no</xsl:text></xsl:attribute>
137
			<xsl:apply-templates />
138
		</xsl:copy>
139
	</xsl:template>
140

  
141
	<xsl:template match="tei:div4">
142
		<cb xmlns="http://www.tei-c.org/ns/1.0" n="{@n}" />
143
		<xsl:copy>
144
			<xsl:apply-templates select="@*|node()" />
145
		</xsl:copy>
146
	</xsl:template>
147

  
148
	<xsl:template match="tei:l">
149
		<xsl:copy>
150
			<xsl:apply-templates select="@*" />
151
			<lb xmlns="http://www.tei-c.org/ns/1.0" n="{@n}" />
152
			<xsl:apply-templates />
153
		</xsl:copy>
154
	</xsl:template>
155

  
156
	<xsl:template match="tei:note|tei:supplied|tei:head">
157
		<xsl:copy>
158
			<xsl:apply-templates select="@*" />
159
			<xsl:attribute name="ana">
160
      <xsl:if test="@ana"><xsl:value-of
161
				select="concat(@ana,' ')" /></xsl:if>
143 162
      <xsl:text>ori:align-no</xsl:text>
144 163
    </xsl:attribute>
145
    <xsl:apply-templates/>
146
  </xsl:copy>
147
</xsl:template>
148
  
149
<xsl:template match="tei:c[@type='lettrine']">
150
  <g xmlns="http://www.tei-c.org/ns/1.0" n="{@n}">
151
    <xsl:apply-templates select="@*|node()"/>
152
  </g>
153
</xsl:template>
164
			<xsl:apply-templates />
165
		</xsl:copy>
166
	</xsl:template>
154 167

  
168
	<xsl:template match="tei:c[@type='lettrine']">
169
		<g xmlns="http://www.tei-c.org/ns/1.0" n="{@n}">
170
			<xsl:apply-templates select="@*|node()" />
171
		</g>
172
	</xsl:template>
173

  
155 174
</xsl:stylesheet>

Also available in: Unified diff