Revision 2398 tmp/org.txm.oriflamms.rcp/res/oriflamms-convert-transcriptions-orizones.xsl

oriflamms-convert-transcriptions-orizones.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">
7
  
8
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="yes"/>
9
  
10
  <xd:doc type="stylesheet">
11
    <xd:short>
12
      Cette feuille permet de convertir les données de zonage d'image produites 
13
      par le logiciel Oriflamms (0.3.2) vers le format XML-TEI-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>2015, CNRS / ICAR (Équipe CACTUS)</xd:copyright>
31
  </xd:doc>
32
  
33
  <xsl:variable name="filename">
34
    <xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$">
35
      <xsl:matching-substring>
36
        <xsl:value-of select="regex-group(2)"/>
37
      </xsl:matching-substring>
38
    </xsl:analyze-string>
39
  </xsl:variable>
40
  
41
  <xsl:variable name="filedir">
42
    <xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$">
43
      <xsl:matching-substring>
44
        <xsl:value-of select="regex-group(1)"/>
45
      </xsl:matching-substring>
46
    </xsl:analyze-string>
47
  </xsl:variable>
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">
48 9

  
49
<xsl:variable name="corpusid">
50
  <xsl:value-of select="replace($filename,'-w$','')"/>
51
</xsl:variable>
10
	<xsl:output method="xml" encoding="utf-8"
11
		omit-xml-declaration="no" indent="yes" />
52 12

  
53
  <!--  <xsl:variable name="filenameresult">
54
    <xsl:value-of select="replace($filename,'(-ori)?-w$','')"/>
55
  </xsl:variable>-->
56
  
57
  <!--<xsl:param name="textFileName"><xsl:value-of select="$filename"/></xsl:param>-->
58
  
59
  <xsl:param name="imageZoneFileName"><xsl:value-of select="concat($filename,'-zones.xml')"/></xsl:param>
60
  
61
  <xsl:template match="*">
62
    <xsl:copy>
63
      <xsl:apply-templates select="@*"/>
64
      <xsl:apply-templates select="*|processing-instruction()|comment()|text()"/>
65
    </xsl:copy>
66
  </xsl:template>
67
  
68
  <xsl:template match="@*|comment()|processing-instruction()|text()">
69
    <xsl:copy/>
70
  </xsl:template>
71
  
72
<xsl:template match="/">
73
<dummy>Les résultats sont enregistrés dans les dossiers zones et img-links</dummy>
74
  <xsl:apply-templates select="//tei:milestone[@unit='surface']"/>
75
</xsl:template>
13
	<xd:doc type="stylesheet">
14
		<xd:short>
15
			Cette feuille permet de convertir les données de zonage d'image produites
16
			par le logiciel Oriflamms (0.3.2) vers le format XML-TEI-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.
76 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.
77 28

  
78
  <xsl:template match="tei:milestone[@unit='surface' and not(ancestor::tei:supplied)]">
79
    
80
    <!--<xsl:variable name="fileid">
81
      <xsl:value-of select="replace(@xml:id,'^surf_','')"/>
82
    </xsl:variable>-->
83
    
84
    <xsl:result-document href="{$filedir}/../zones/{$corpusid}_{@xml:id}-zones.xml">
85
      <TEI xmlns="http://www.tei-c.org/ns/1.0">
86
        <teiHeader xmlns="http://www.tei-c.org/ns/1.0">
87
          <fileDesc xmlns="http://www.tei-c.org/ns/1.0">
88
            <titleStmt xmlns="http://www.tei-c.org/ns/1.0">
89
              <title xmlns="http://www.tei-c.org/ns/1.0">Zones d'image pour <xsl:value-of select="@xml:id"/></title>
90
              <respStmt xmlns="http://www.tei-c.org/ns/1.0">
91
                <resp xmlns="http://www.tei-c.org/ns/1.0">Création automatique du fichier</resp>
92
                <name xmlns="http://www.tei-c.org/ns/1.0" xml:id="TXM">Logiciel TXM (http://textometrie.ens-lyon.fr)</name>
93
              </respStmt>
94
            </titleStmt>
95
            <publicationStmt xmlns="http://www.tei-c.org/ns/1.0"><p xmlns="http://www.tei-c.org/ns/1.0">Projet Oriflamms (http://oriflamms.hypotheses.org)</p></publicationStmt>
96
            <sourceDesc xmlns="http://www.tei-c.org/ns/1.0"><p>Généré à partir du fichier de transcription au format TEI-Oriflamms</p></sourceDesc>
97
          </fileDesc>
98
          <revisionDesc xmlns="http://www.tei-c.org/ns/1.0">
99
            <change when="{format-date(current-date(),'[Y]-[M01]-[D01]')}" who="#TXM" xmlns="http://www.tei-c.org/ns/1.0">Création du fichier</change>
100
          </revisionDesc>
101
        </teiHeader>
102
        <facsimile xml:base="../img/" xmlns="http://www.tei-c.org/ns/1.0">
103
          <surface xmlns="http://www.tei-c.org/ns/1.0" xml:id="{replace(@xml:id,'^surf_','surf_img')}">
104
            <!--<graphic url="{replace(following::tei:pb[1]/@facs,'\.tif$','.jpg')}"/>-->
105
            <graphic url="{following::tei:pb[1]/@facs}"/>
106
          </surface>
107
        </facsimile>
108
      </TEI>
109
    </xsl:result-document>
110
    <xsl:result-document href="{$filedir}/../img_links/{$corpusid}_{@xml:id}-links.xml">
111
      <TEI xmlns="http://www.tei-c.org/ns/1.0">
112
        <teiHeader xmlns="http://www.tei-c.org/ns/1.0">
113
          <fileDesc xmlns="http://www.tei-c.org/ns/1.0">
114
            <titleStmt xmlns="http://www.tei-c.org/ns/1.0">
115
              <title xmlns="http://www.tei-c.org/ns/1.0">Données d'alignement pour les transcriptions et les zones d'image (<xsl:value-of select="$filename"/>)</title>
116
              <respStmt xmlns="http://www.tei-c.org/ns/1.0">
117
                <resp xmlns="http://www.tei-c.org/ns/1.0">Création automatique du fichier</resp>
118
                <name xmlns="http://www.tei-c.org/ns/1.0" xml:id="TXM">Logiciel TXM (http://textometrie.ens-lyon.fr)</name>
119
              </respStmt>
120
            </titleStmt>
121
            <publicationStmt xmlns="http://www.tei-c.org/ns/1.0"><p xmlns="http://www.tei-c.org/ns/1.0">Projet Oriflamms (http://oriflamms.hypotheses.org)</p></publicationStmt>
122
            <sourceDesc xmlns="http://www.tei-c.org/ns/1.0"><p>Généré à partir du fichier de transcription au format TEI-Oriflamms</p></sourceDesc>
123
          </fileDesc>
124
          <encodingDesc xmlns="http://www.tei-c.org/ns/1.0">
125
            <listPrefixDef xmlns="http://www.tei-c.org/ns/1.0">
126
              <prefixDef xmlns="http://www.tei-c.org/ns/1.0" ident="txt" matchPattern="([a-z]+)" replacementPattern="../texts/{$corpusid}-c.xml#$1"/>
127
              <prefixDef xmlns="http://www.tei-c.org/ns/1.0" ident="img" matchPattern="([a-z]+)" replacementPattern="../zones/{$corpusid}_{@xml:id}-zones.xml#$1"/>
128
            </listPrefixDef>
129
          </encodingDesc>
130
          <revisionDesc xmlns="http://www.tei-c.org/ns/1.0">
131
            <change when="{format-date(current-date(),'[Y]-[M01]-[D01]')}" who="#TXM" xmlns="http://www.tei-c.org/ns/1.0">Création du fichier</change>
132
          </revisionDesc>
133
        </teiHeader>
134
        <text xmlns="http://www.tei-c.org/ns/1.0">
135
          <body xmlns="http://www.tei-c.org/ns/1.0">
136
            <ab type="linking" xmlns="http://www.tei-c.org/ns/1.0">
137
              <linkGrp type="surfaces" xmlns="http://www.tei-c.org/ns/1.0"/>
138
              <linkGrp type="pages" xmlns="http://www.tei-c.org/ns/1.0"/>
139
              <linkGrp type="columns" xmlns="http://www.tei-c.org/ns/1.0"/>
140
              <linkGrp type="lines" xmlns="http://www.tei-c.org/ns/1.0"/>
141
              <linkGrp type="words" xmlns="http://www.tei-c.org/ns/1.0"/>
142
              <linkGrp type="characters" xmlns="http://www.tei-c.org/ns/1.0"/>
143
            </ab>
144
          </body>
145
        </text>
146
      </TEI>
147
    </xsl:result-document>
148
  </xsl:template>
149
  
150
  
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>2015, CNRS / ICAR (Équipe CACTUS)</xd:copyright>
34
	</xd:doc>
35

  
36
	<xsl:variable name="filename">
37
		<xsl:analyze-string select="document-uri(.)"
38
			regex="^(.*)/([^/]+)\.[^/]+$">
39
			<xsl:matching-substring>
40
				<xsl:value-of select="regex-group(2)" />
41
			</xsl:matching-substring>
42
		</xsl:analyze-string>
43
	</xsl:variable>
44

  
45
	<xsl:variable name="filedir">
46
		<xsl:analyze-string select="document-uri(.)"
47
			regex="^(.*)/([^/]+)\.[^/]+$">
48
			<xsl:matching-substring>
49
				<xsl:value-of select="regex-group(1)" />
50
			</xsl:matching-substring>
51
		</xsl:analyze-string>
52
	</xsl:variable>
53

  
54
	<xsl:variable name="corpusid">
55
		<xsl:value-of select="replace($filename,'-w$','')" />
56
	</xsl:variable>
57

  
58
	<!-- <xsl:variable name="filenameresult"> <xsl:value-of select="replace($filename,'(-ori)?-w$','')"/> 
59
		</xsl:variable> -->
60

  
61
	<!--<xsl:param name="textFileName"><xsl:value-of select="$filename"/></xsl:param> -->
62

  
63
	<xsl:param name="imageZoneFileName">
64
		<xsl:value-of select="concat($filename,'-zones.xml')" />
65
	</xsl:param>
66

  
67
	<xsl:template match="*">
68
		<xsl:copy>
69
			<xsl:apply-templates select="@*" />
70
			<xsl:apply-templates
71
				select="*|processing-instruction()|comment()|text()" />
72
		</xsl:copy>
73
	</xsl:template>
74

  
75
	<xsl:template
76
		match="@*|comment()|processing-instruction()|text()">
77
		<xsl:copy />
78
	</xsl:template>
79

  
80
	<xsl:template match="/">
81
		<dummy>Les résultats sont enregistrés dans les dossiers zones et
82
			img-links</dummy>
83
		<xsl:apply-templates
84
			select="//tei:milestone[@unit='surface']" />
85
	</xsl:template>
86

  
87

  
88
	<xsl:template
89
		match="tei:milestone[@unit='surface' and not(ancestor::tei:supplied)]">
90

  
91
		<!--<xsl:variable name="fileid"> <xsl:value-of select="replace(@xml:id,'^surf_','')"/> 
92
			</xsl:variable> -->
93

  
94
		<xsl:result-document
95
			href="{$filedir}/../zones/{$corpusid}_{@xml:id}-zones.xml">
96
			<TEI xmlns="http://www.tei-c.org/ns/1.0">
97
				<teiHeader xmlns="http://www.tei-c.org/ns/1.0">
98
					<fileDesc xmlns="http://www.tei-c.org/ns/1.0">
99
						<titleStmt xmlns="http://www.tei-c.org/ns/1.0">
100
							<title xmlns="http://www.tei-c.org/ns/1.0">
101
								Zones d'image pour
102
								<xsl:value-of select="@xml:id" />
103
							</title>
104
							<respStmt xmlns="http://www.tei-c.org/ns/1.0">
105
								<resp xmlns="http://www.tei-c.org/ns/1.0">Création automatique du fichier</resp>
106
								<name xmlns="http://www.tei-c.org/ns/1.0" xml:id="TXM">Logiciel
107
									TXM (http://textometrie.ens-lyon.fr)</name>
108
							</respStmt>
109
						</titleStmt>
110
						<publicationStmt
111
							xmlns="http://www.tei-c.org/ns/1.0">
112
							<p xmlns="http://www.tei-c.org/ns/1.0">Projet Oriflamms (http://oriflamms.hypotheses.org)</p>
113
						</publicationStmt>
114
						<sourceDesc xmlns="http://www.tei-c.org/ns/1.0">
115
							<p>Généré à partir du fichier de transcription au format
116
								TEI-Oriflamms</p>
117
						</sourceDesc>
118
					</fileDesc>
119
					<revisionDesc xmlns="http://www.tei-c.org/ns/1.0">
120
						<change
121
							when="{format-date(current-date(),'[Y]-[M01]-[D01]')}" who="#TXM"
122
							xmlns="http://www.tei-c.org/ns/1.0">Création du fichier</change>
123
					</revisionDesc>
124
				</teiHeader>
125
				<facsimile xml:base="../img/"
126
					xmlns="http://www.tei-c.org/ns/1.0">
127
					<surface xmlns="http://www.tei-c.org/ns/1.0"
128
						xml:id="{replace(@xml:id,'^surf_','surf_img')}">
129
						<!--<graphic url="{replace(following::tei:pb[1]/@facs,'\.tif$','.jpg')}"/> -->
130
						<graphic url="{following::tei:pb[1]/@facs}" />
131
					</surface>
132
				</facsimile>
133
			</TEI>
134
		</xsl:result-document>
135
		<xsl:result-document
136
			href="{$filedir}/../img_links/{$corpusid}_{@xml:id}-links.xml">
137
			<TEI xmlns="http://www.tei-c.org/ns/1.0">
138
				<teiHeader xmlns="http://www.tei-c.org/ns/1.0">
139
					<fileDesc xmlns="http://www.tei-c.org/ns/1.0">
140
						<titleStmt xmlns="http://www.tei-c.org/ns/1.0">
141
							<title xmlns="http://www.tei-c.org/ns/1.0">
142
								Données d'alignement pour les transcriptions et les zones
143
								d'image (
144
								<xsl:value-of select="$filename" />
145
								)
146
							</title>
147
							<respStmt xmlns="http://www.tei-c.org/ns/1.0">
148
								<resp xmlns="http://www.tei-c.org/ns/1.0">Création automatique du fichier</resp>
149
								<name xmlns="http://www.tei-c.org/ns/1.0" xml:id="TXM">Logiciel
150
									TXM (http://textometrie.ens-lyon.fr)</name>
151
							</respStmt>
152
						</titleStmt>
153
						<publicationStmt
154
							xmlns="http://www.tei-c.org/ns/1.0">
155
							<p xmlns="http://www.tei-c.org/ns/1.0">Projet Oriflamms (http://oriflamms.hypotheses.org)</p>
156
						</publicationStmt>
157
						<sourceDesc xmlns="http://www.tei-c.org/ns/1.0">
158
							<p>Généré à partir du fichier de transcription au format
159
								TEI-Oriflamms</p>
160
						</sourceDesc>
161
					</fileDesc>
162
					<encodingDesc xmlns="http://www.tei-c.org/ns/1.0">
163
						<listPrefixDef xmlns="http://www.tei-c.org/ns/1.0">
164
							<prefixDef xmlns="http://www.tei-c.org/ns/1.0"
165
								ident="txt" matchPattern="([a-z]+)"
166
								replacementPattern="../texts/{$corpusid}-c.xml#$1" />
167
							<prefixDef xmlns="http://www.tei-c.org/ns/1.0"
168
								ident="img" matchPattern="([a-z]+)"
169
								replacementPattern="../zones/{$corpusid}_{@xml:id}-zones.xml#$1" />
170
						</listPrefixDef>
171
					</encodingDesc>
172
					<revisionDesc xmlns="http://www.tei-c.org/ns/1.0">
173
						<change
174
							when="{format-date(current-date(),'[Y]-[M01]-[D01]')}" who="#TXM"
175
							xmlns="http://www.tei-c.org/ns/1.0">Création du fichier</change>
176
					</revisionDesc>
177
				</teiHeader>
178
				<text xmlns="http://www.tei-c.org/ns/1.0">
179
					<body xmlns="http://www.tei-c.org/ns/1.0">
180
						<ab type="linking" xmlns="http://www.tei-c.org/ns/1.0">
181
							<linkGrp type="surfaces"
182
								xmlns="http://www.tei-c.org/ns/1.0" />
183
							<linkGrp type="pages" xmlns="http://www.tei-c.org/ns/1.0" />
184
							<linkGrp type="columns"
185
								xmlns="http://www.tei-c.org/ns/1.0" />
186
							<linkGrp type="lines" xmlns="http://www.tei-c.org/ns/1.0" />
187
							<linkGrp type="words" xmlns="http://www.tei-c.org/ns/1.0" />
188
							<linkGrp type="characters"
189
								xmlns="http://www.tei-c.org/ns/1.0" />
190
						</ab>
191
					</body>
192
				</text>
193
			</TEI>
194
		</xsl:result-document>
195
	</xsl:template>
196

  
197

  
151 198
</xsl:stylesheet>

Also available in: Unified diff