Statistics
| Revision:

root / tmp / org.txm.core / src / groovy / org / txm / importer / graal / xsl / breakByMilestone.xsl @ 187

History | View | Annotate | Download (3.2 kB)

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:me="http://www.menota.org/ns/1.0" xmlns:bfm="http://bfm.ens-lsh.fr/ns/1.0">
3

    
4
    <!-- Based on a stylesheet for creating separate XML-TEI files for
5
        each page by Paul Caton (posted on TEI-L 2008-12-11)-->
6

    
7
    <xsl:output method="xml" encoding="UTF-8"/>
8

    
9
    <xsl:param name="pbval1">7</xsl:param>
10
    <xsl:param name="pbval2">8</xsl:param>
11

    
12
    <xsl:function name="tei:page-content" as="node()*">
13
        <xsl:param name="pb1" as="node()"/>
14
        <xsl:param name="pb2" as="node()"/>
15
        <xsl:param name="node" as="node()"/>
16
        <xsl:choose>
17
            <xsl:when test="$node[self::*]">
18
                <!-- $node is an element() -->
19
                <xsl:choose>
20
                    <!--                    <xsl:when test="$node is $pb1">
21
                        <xsl:copy-of select="$node"/>
22
                    </xsl:when>
23
-->
24
                    <xsl:when
25
                        test="some $n in $node/descendant::* satisfies ($n is $pb1 or $n is $pb2)">
26
                        <xsl:element name="{name($node)}" namespace="http://www.tei-c.org/ns/1.0">
27
                            <!--<xsl:attribute name="testttt">http://www.menota.org/ns/1.0</xsl:attribute>-->
28
                            <xsl:sequence select="for $i in ( $node/node() | $node/@* ) return tei:page-content($pb1, $pb2, $i)"/>
29
                        </xsl:element>
30
                    </xsl:when>
31
                    <xsl:when test="($node >> $pb1) and ($node &lt;&lt; $pb2)">
32
                        <xsl:copy-of select="$node"/>
33
                    </xsl:when>
34
                    <xsl:otherwise>
35
                        <!-- do nothing -->
36
                    </xsl:otherwise>
37
                </xsl:choose>
38
            </xsl:when>
39
            <xsl:when test="$node[count(. | ../@*) = count(../@*)]">
40
                <!-- $node is an attribute -->
41
                <xsl:attribute name="{name($node)}">
42
                    <xsl:sequence select="data($node)"/>
43
                </xsl:attribute>
44
            </xsl:when>
45
            <xsl:otherwise>
46
                <xsl:choose>
47
                    <xsl:when test="($node >> $pb1) and ($node &lt;&lt; $pb2)">
48
                        <xsl:copy-of select="$node"/>
49
                    </xsl:when>
50
                    <xsl:otherwise>
51
                        <!-- do nothing -->
52
                    </xsl:otherwise>
53
                </xsl:choose>
54
            </xsl:otherwise>
55
        </xsl:choose>
56
    </xsl:function>
57

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

    
65
    <xsl:template match="processing-instruction()">
66
        <xsl:copy>
67
            <xsl:value-of select="."/>
68
        </xsl:copy>
69
    </xsl:template>
70

    
71
    <xsl:template match="tei:body">
72
        <!-- <xsl:variable name="containingNode" select="//tei:text"/> -->
73
        <xsl:sequence select="tei:page-content(//tei:milestone[@unit='column'][@n=$pbval1], //tei:milestone[@unit='column'][@n=$pbval2], //tei:body)"/>
74
    </xsl:template>
75
</xsl:stylesheet>