transformation.xsl 2.56 KB
Newer Older
simei.yin's avatar
simei.yin committed
1
2
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
Baptiste Montange's avatar
Baptiste Montange committed
3
4
5
6
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:h="http://www.utc.fr/ics/hdoc/xhtml"
    exclude-result-prefixes="xs" version="2.0">

    <xsl:template match="h:html">
7
        <document>
Baptiste Montange's avatar
Baptiste Montange committed
8
        <xsl:apply-templates mode="title"/>
9
    </document>
Baptiste Montange's avatar
Baptiste Montange committed
10
11
12
    </xsl:template>

    <xsl:template match="h:head" mode="title">
Baptiste Montange's avatar
Baptiste Montange committed
13
        <title>
Baptiste Montange's avatar
Baptiste Montange committed
14
            <xsl:value-of select="./h:title"/>
Baptiste Montange's avatar
Baptiste Montange committed
15
        </title>
Baptiste Montange's avatar
Baptiste Montange committed
16
17
18
            <xsl:apply-templates select="./h:meta"/>
            
    </xsl:template>
simei.yin's avatar
simei.yin committed
19
    
Baptiste Montange's avatar
Baptiste Montange committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
    <xsl:template match="h:meta[@name='author']">
        <authors> 
           
                <xsl:for-each select="tokenize(@content,', \d')">
                    <xsl:if test="position() = 1">
                        <xsl:for-each select="tokenize(.,', ')">
                        <author>
                            <xsl:value-of select="."/>
                            
                        </author>
                        </xsl:for-each>
                    </xsl:if>
                </xsl:for-each>
            
        </authors>
    </xsl:template>

    <xsl:template match="h:body" mode="title">
        <sections>
           
                <xsl:apply-templates select="./h:section"/>
            
        </sections>
    </xsl:template>
simei.yin's avatar
simei.yin committed
44
    
Baptiste Montange's avatar
Baptiste Montange committed
45
46
    <xsl:template match="h:section">
        <section>
Baptiste Montange's avatar
Baptiste Montange committed
47
48
49
50
            <typesection>
                <xsl:value-of select="@data-hdoc-type"/>
            </typesection>
            <titlesection>
Baptiste Montange's avatar
Baptiste Montange committed
51
                <xsl:value-of select="./h:header/h:h1"/>
Baptiste Montange's avatar
Baptiste Montange committed
52
53
54
            </titlesection>
            <content>
                <paragraphs>
Baptiste Montange's avatar
Baptiste Montange committed
55
                    <xsl:apply-templates select="h:div"/>
Baptiste Montange's avatar
Baptiste Montange committed
56
                </paragraphs>
Baptiste Montange's avatar
Baptiste Montange committed
57
                <xsl:apply-templates select="h:section" mode="soussect"/>
Baptiste Montange's avatar
Baptiste Montange committed
58
            </content>
Baptiste Montange's avatar
Baptiste Montange committed
59
60
61
        </section>
    </xsl:template>
 
Baptiste Montange's avatar
Baptiste Montange committed
62

Baptiste Montange's avatar
Baptiste Montange committed
63
64
    <xsl:template match="h:section" mode="soussect">
        <soussection></soussection>
simei.yin's avatar
simei.yin committed
65
66
    </xsl:template>
    
Baptiste Montange's avatar
Baptiste Montange committed
67

Baptiste Montange's avatar
Baptiste Montange committed
68
69
    <xsl:template match="h:div" >
            <xsl:if test="h:p">
Baptiste Montange's avatar
Baptiste Montange committed
70
                <paragraph>
Baptiste Montange's avatar
Baptiste Montange committed
71
                <xsl:value-of select="."/>
Baptiste Montange's avatar
Baptiste Montange committed
72
                </paragraph>
Baptiste Montange's avatar
Baptiste Montange committed
73
74
75
76
77
78
79
80
            </xsl:if>
            <xsl:if test="h:ul">
                <xsl:apply-templates select="h:ul"></xsl:apply-templates>
            </xsl:if>
        
    </xsl:template>
    <xsl:template match="h:ul">
        <xsl:for-each select="h:li">
Baptiste Montange's avatar
Baptiste Montange committed
81
            <paragraph>
Baptiste Montange's avatar
Baptiste Montange committed
82
                <xsl:value-of select="h:p"/>
Baptiste Montange's avatar
Baptiste Montange committed
83
            </paragraph>
Baptiste Montange's avatar
Baptiste Montange committed
84
85
86
        </xsl:for-each>
        
    </xsl:template>
87
    
Baptiste Montange's avatar
Baptiste Montange committed
88
89
90


</xsl:stylesheet>