Revision 2398 tmp/org.txm.oriflamms.rcp/res/oriflamms-patch-milestones.xsl

oriflamms-patch-milestones.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
  xmlns:xi="http://www.w3.org/2001/XInclude" 
7
  xmlns:svg="http://www.w3.org/2000/svg" 
8
  xmlns:math="http://www.w3.org/1998/Math/MathML"
9
  exclude-result-prefixes="tei edate xd txm xi svg math" 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
	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">
10 12

  
11
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="no"/>
12
  
13
  <xd:doc type="stylesheet">
14
    <xd:short>
15
      Cette feuille permet de rajouter les éléments milestone et cb, et les identifiants 
16
      manquant sur lb
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.
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.
28
      
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:strip-space elements="*"/>-->
37
  
38
  <xsl:variable name="textID">
39
    <xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$">
40
      <xsl:matching-substring>
41
        <xsl:value-of select="regex-group(2)"/>
42
      </xsl:matching-substring>
43
    </xsl:analyze-string>
44
  </xsl:variable>
45
  
46
  <xsl:template match="/">
47
    <xsl:apply-templates/>
48
  </xsl:template>
49
  
50
  
51
  <xsl:template match="*">
52
        <xsl:copy>
53
          <xsl:apply-templates select="@*"/>
54
          <xsl:apply-templates select="*|processing-instruction()|comment()|text()"/>
55
        </xsl:copy>
56
  </xsl:template>
13
	<xsl:output method="xml" encoding="utf-8"
14
		omit-xml-declaration="no" indent="no" />
57 15

  
58
<xsl:template match="processing-instruction()"></xsl:template>
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.
59 27

  
60
  <xsl:template match="comment()|text()">
61
    <xsl:copy/>
62
  </xsl:template>
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.
63 32

  
64
  <!-- On supprime les attributs par défaut de la DTD TEI -->
65
  
66
  <xsl:template match="@*">
67
    <xsl:choose>
68
      <xsl:when test="matches(name(.),'^(part|instant|anchored|full)$')"/>
69
      <!--      <xsl:when test="matches(name(.),'rend')">
70
        <xsl:choose>
71
          <xsl:when test="matches(.,'^aggl$')"><xsl:attribute name="rend">space-after(none)</xsl:attribute></xsl:when>
72
          <xsl:otherwise><xsl:copy/></xsl:otherwise>
73
        </xsl:choose>
74
      </xsl:when>-->
75
      <xsl:otherwise><xsl:copy/></xsl:otherwise>
76
    </xsl:choose>
77
  </xsl:template>
78
  
79
  <xsl:template match="tei:pb[not(ancestor::tei:supplied)]">
80
    <xsl:variable name="facs"><xsl:value-of select="@facs"/></xsl:variable>
81
    <xsl:if 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])">
82
      <milestone xmlns="http://www.tei-c.org/ns/1.0" unit="surface" facs="{@facs}"/>
83
    </xsl:if>
84
    <xsl:copy>
85
      <xsl:apply-templates select="@*"/>
86
    </xsl:copy>
87
    <xsl:if test="not(following::*[position() lt 5][self::tei:cb])">
88
      <xsl:comment>cb added automatically</xsl:comment>
89
      <cb xmlns="http://www.tei-c.org/ns/1.0"/>
90
    </xsl:if>
91
    <xsl:if test="not(following::*[position() lt 5][self::tei:lb or self::tei:cb])">
92
      <lb xmlns="http://www.tei-c.org/ns/1.0"/>
93
      <xsl:comment>lb added automatically</xsl:comment>
94
    </xsl:if>
95
  </xsl:template>
96
  
97
  <xsl:template match="tei:cb[not(ancestor::tei:supplied)]">
98
    <xsl:copy>
99
      <xsl:apply-templates select="@*"/>
100
    </xsl:copy>
101
    <xsl:if test="not(following::*[position() lt 5][self::tei:lb])">
102
      <lb xmlns="http://www.tei-c.org/ns/1.0"/>
103
    </xsl:if>
104
  </xsl:template>
105
  
106
  <xsl:template match="tei:lb">
107
    <xsl:copy>
108
      <xsl:apply-templates select="@*"/>
109
      <xsl:if test="matches(@rend,'^(right|center|centre)#')">
110
        <xsl:attribute name="type">rejet</xsl:attribute>
111
      </xsl:if>
112
    </xsl:copy>
113
  </xsl:template>
114
  
115
  <xsl:template match="tei:milestone[@unit='surface' and @facs=preceding::tei:milestone[@unit='surface']/@facs]">
116
    <xsl:comment>Doublon éliminé <xsl:value-of select="@xml:id"/></xsl:comment>
117
  </xsl:template>
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>
118 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

  
119 138
</xsl:stylesheet>

Also available in: Unified diff