transformation.xsl 2.48 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 13 14 15 16 17 18
    </xsl:template>

    <xsl:template match="h:head" mode="title">
        <titre>
            <xsl:value-of select="./h:title"/>
        </titre>
            <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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    <xsl:template match="h:section">
        <section>
            <titresection>
                <xsl:value-of select="./h:header/h:h1"/>
            </titresection>
            <contenu>
                
                <paragraphes>
                    <xsl:apply-templates select="h:div"/>
                </paragraphes>
                <xsl:apply-templates select="h:section" mode="soussect"/>
            </contenu>
        </section>
    </xsl:template>
 
    <xsl:template match="h:section" mode="soussect">
        <soussection></soussection>
simei.yin's avatar
simei.yin committed
62 63
    </xsl:template>
    
Baptiste Montange's avatar
Baptiste Montange committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    <xsl:template match="h:div" >
        
            <xsl:if test="h:p">
                <paragraphe>
                <xsl:value-of select="."/>
                </paragraphe>
            </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">
            <paragraphe>
                <xsl:value-of select="h:p"/>
            </paragraphe>
        </xsl:for-each>
        
    </xsl:template>
84
    
Baptiste Montange's avatar
Baptiste Montange committed
85 86 87


</xsl:stylesheet>