Statistics
| Revision:

root / tmp / org.txm.oriflamms.rcp / groovy / org / txm / macro / oriflamms / prepare / oriflamms-patch-milestones.xsl @ 2398

History | View | Annotate | Download (4.5 kB)

1
<?xml version="1.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
	xmlns:xi="http://www.w3.org/2001/XInclude"
9
	xmlns:svg="http://www.w3.org/2000/svg"
10
	xmlns:math="http://www.w3.org/1998/Math/MathML"
11
	exclude-result-prefixes="tei edate xd txm xi svg math" version="2.0">
12

    
13
	<xsl:output method="xml" encoding="utf-8"
14
		omit-xml-declaration="no" indent="no" />
15

    
16
	<xd:doc type="stylesheet">
17
		<xd:short>
18
			Cette feuille permet de rajouter les éléments milestone et cb, et les
19
			identifiants
20
			manquant sur lb
21
		</xd:short>
22
		<xd:detail>
23
			This stylesheet is free software; you can redistribute it and/or
24
			modify it under the terms of the GNU Lesser General Public
25
			License as published by the Free Software Foundation; either
26
			version 3 of the License, or (at your option) any later version.
27

    
28
			This stylesheet is distributed in the hope that it will be useful,
29
			but WITHOUT ANY WARRANTY; without even the implied warranty of
30
			MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31
			Lesser General Public License for more details.
32

    
33
			You should have received a copy of GNU Lesser Public License with
34
			this stylesheet. If not, see http://www.gnu.org/licenses/lgpl.html
35
		</xd:detail>
36
		<xd:author>Alexei Lavrentiev alexei.lavrentev@ens-lyon.fr</xd:author>
37
		<xd:copyright>2015, CNRS / ICAR (Équipe CACTUS)</xd:copyright>
38
	</xd:doc>
39

    
40
	<!--<xsl:strip-space elements="*"/> -->
41

    
42
	<xsl:variable name="textID">
43
		<xsl:analyze-string select="document-uri(.)"
44
			regex="^(.*)/([^/]+)\.[^/]+$">
45
			<xsl:matching-substring>
46
				<xsl:value-of select="regex-group(2)" />
47
			</xsl:matching-substring>
48
		</xsl:analyze-string>
49
	</xsl:variable>
50

    
51
	<xsl:template match="/">
52
		<xsl:apply-templates />
53
	</xsl:template>
54

    
55

    
56
	<xsl:template match="*">
57
		<xsl:copy>
58
			<xsl:apply-templates select="@*" />
59
			<xsl:apply-templates
60
				select="*|processing-instruction()|comment()|text()" />
61
		</xsl:copy>
62
	</xsl:template>
63

    
64
	<xsl:template match="processing-instruction()"></xsl:template>
65

    
66
	<xsl:template match="comment()|text()">
67
		<xsl:copy />
68
	</xsl:template>
69

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

    
72
	<xsl:template match="@*">
73
		<xsl:choose>
74
			<xsl:when
75
				test="matches(name(.),'^(part|instant|anchored|full)$')" />
76
			<!-- <xsl:when test="matches(name(.),'rend')"> <xsl:choose> <xsl:when 
77
				test="matches(.,'^aggl$')"><xsl:attribute name="rend">space-after(none)</xsl:attribute></xsl:when> 
78
				<xsl:otherwise><xsl:copy/></xsl:otherwise> </xsl:choose> </xsl:when> -->
79
			<xsl:otherwise>
80
				<xsl:copy />
81
			</xsl:otherwise>
82
		</xsl:choose>
83
	</xsl:template>
84

    
85
	<xsl:template match="tei:pb[not(ancestor::tei:supplied)]">
86
		<xsl:variable name="facs">
87
			<xsl:value-of select="@facs" />
88
		</xsl:variable>
89
		<xsl:if
90
			test="matches(@facs,'\.(tiff?|png|jpg)$','i') and not(preceding-sibling::*[position() lt 3][self::tei:milestone[@unit='surface']]) and not(preceding::tei:pb[@facs=$facs])">
91
			<milestone xmlns="http://www.tei-c.org/ns/1.0"
92
				unit="surface" facs="{@facs}" />
93
		</xsl:if>
94
		<xsl:copy>
95
			<xsl:apply-templates select="@*" />
96
		</xsl:copy>
97
		<xsl:if test="not(following::*[position() lt 5][self::tei:cb])">
98
			<xsl:comment>
99
				cb added automatically
100
			</xsl:comment>
101
			<cb xmlns="http://www.tei-c.org/ns/1.0" />
102
		</xsl:if>
103
		<xsl:if
104
			test="not(following::*[position() lt 5][self::tei:lb or self::tei:cb])">
105
			<lb xmlns="http://www.tei-c.org/ns/1.0" />
106
			<xsl:comment>
107
				lb added automatically
108
			</xsl:comment>
109
		</xsl:if>
110
	</xsl:template>
111

    
112
	<xsl:template match="tei:cb[not(ancestor::tei:supplied)]">
113
		<xsl:copy>
114
			<xsl:apply-templates select="@*" />
115
		</xsl:copy>
116
		<xsl:if test="not(following::*[position() lt 5][self::tei:lb])">
117
			<lb xmlns="http://www.tei-c.org/ns/1.0" />
118
		</xsl:if>
119
	</xsl:template>
120

    
121
	<xsl:template match="tei:lb">
122
		<xsl:copy>
123
			<xsl:apply-templates select="@*" />
124
			<xsl:if test="matches(@rend,'^(right|center|centre)#')">
125
				<xsl:attribute name="type">rejet</xsl:attribute>
126
			</xsl:if>
127
		</xsl:copy>
128
	</xsl:template>
129

    
130
	<xsl:template
131
		match="tei:milestone[@unit='surface' and @facs=preceding::tei:milestone[@unit='surface']/@facs]">
132
		<xsl:comment>
133
			Doublon éliminé
134
			<xsl:value-of select="@xml:id" />
135
		</xsl:comment>
136
	</xsl:template>
137

    
138
</xsl:stylesheet>