xhtml2hdoc.xsl 2.25 KB
Newer Older
Jean Vintache's avatar
Jean Vintache committed
1
2
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
qaomia's avatar
fixes  
qaomia committed
3
4
5
6
    xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
    xmlns="http://www.utc.fr/ics/hdoc/xhtml" version="2.0">
    <xsl:output method="xml" indent="yes"/>

qaomia's avatar
qaomia committed
7
8
9
    <xsl:template match="html">
        <html>
            <head>
qaomia's avatar
fixes  
qaomia committed
10
11
12
                <title>
                    <xsl:value-of select="/html/head/title"/>
                </title>
qaomia's avatar
qaomia committed
13
14
15
16
17
18
19
                <meta charset="utf-8"/>
            </head>
            <body>
                <section>
                    <header>
                        <h1>Contenu</h1>
                    </header>
20
                    <xsl:apply-templates select="/html/body/div"/>
qaomia's avatar
qaomia committed
21
22
23
24
                </section>
            </body>
        </html>
    </xsl:template>
qaomia's avatar
fixes  
qaomia committed
25
26
27
28
29
30
31
32
33
    <xsl:template match="/html/body/div" priority="1">
        <xsl:choose>
            <xsl:when test="p/ul">
                <xsl:element name="{local-name()}">
                        <xsl:apply-templates select="*"/>
                </xsl:element>
            </xsl:when>
            <xsl:when test="p/ol">
                <xsl:element name="{local-name()}">
34
                    <xsl:apply-templates select="*"/>
qaomia's avatar
fixes  
qaomia committed
35
36
37
38
39
40
41
42
43
44
                </xsl:element>
            </xsl:when>
            <xsl:otherwise>
                <p>
                    <xsl:element name="{local-name()}">
                        <xsl:apply-templates select="node() | @*"/>
                    </xsl:element>
                </p>
            </xsl:otherwise>
        </xsl:choose>
45
    </xsl:template>
qaomia's avatar
fixes  
qaomia committed
46

47
    <!--
qaomia's avatar
fixes  
qaomia committed
48
49
50
51
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
52
    </xsl:template>
53
54
55
56
    -->

    <xsl:template match="/">
        <xsl:apply-templates select="*"></xsl:apply-templates>
57
    </xsl:template>
Jean Vintache's avatar
Jean Vintache committed
58
<<<<<<< HEAD
59
60
61
    <xsl:template match="*">
        <xsl:comment>Error</xsl:comment>
    </xsl:template>
62
    
Jean Vintache's avatar
Jean Vintache committed
63
=======
64

qaomia's avatar
fixes  
qaomia committed
65
66
67
68
69
70
71
    <!-- Namespace substitution for hdoc elements -->                        
    <xsl:template match="*">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="node()|@*"/>
        </xsl:element>
    </xsl:template> 

Jean Vintache's avatar
Jean Vintache committed
72
>>>>>>> 112cef1ed5bea6c90a2ef0bdff0e2d981478d5da
qaomia's avatar
qaomia committed
73
</xsl:stylesheet>