Statistics
| Revision:

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

History | View | Annotate | Download (4.6 kB)

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">
10

    
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>
57

    
58
<xsl:template match="processing-instruction()"></xsl:template>
59

    
60
  <xsl:template match="comment()|text()">
61
    <xsl:copy/>
62
  </xsl:template>
63

    
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>
118

    
119
</xsl:stylesheet>