last_transformer.xsl 3.02 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8"?>
2
3

<xsl:stylesheet
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
  xpath-default-namespace="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml">

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>

  <!-- Traitement du titre et des auteurs du document -->
  <xsl:template match="body">
    <body>
      <h1><xsl:value-of select="/html/head/title"/></h1>
      <p class="authors"><xsl:value-of select="/html/head/meta[@name='author']/@content"/></p>
bperraud's avatar
bperraud committed
21

22
      <xsl:apply-templates select="node()|@*"/>
bperraud's avatar
bperraud committed
23

bperraud's avatar
bperraud committed
24
      <xsl:call-template name="toc"/>
25
26
    </body>
  </xsl:template>
bperraud's avatar
bperraud committed
27

28
29
30

  <!-- Cleaning des footers vides -->
  <xsl:template match="footer[not(node())]"/>
bperraud's avatar
bperraud committed
31
32


bperraud's avatar
bperraud committed
33
34
  <!-- Gestion de la table des matières -->
  <xsl:template name="toc">
bperraud's avatar
bperraud committed
35

bperraud's avatar
bperraud committed
36
    <xsl:if test="count(//h2) &gt; 0">
bperraud's avatar
bperraud committed
37

bperraud's avatar
bperraud committed
38
    <h2 class="nocount toc-title">Table des matières</h2>
bperraud's avatar
bperraud committed
39

bperraud's avatar
bperraud committed
40
41
    <ul class="toc level2">
      <xsl:for-each select="//h2">
bperraud's avatar
bperraud committed
42

bperraud's avatar
bperraud committed
43
44
        <li>
          <xsl:call-template name="toc-a"/>
bperraud's avatar
bperraud committed
45

bperraud's avatar
bperraud committed
46
47
48
49
          <xsl:if test="count(..//h3) &gt; 0">

            <ul class="toc level3">
              <xsl:for-each select="..//h3">
bperraud's avatar
bperraud committed
50

bperraud's avatar
bperraud committed
51
52
                <li>
                  <xsl:call-template name="toc-a"/>
bperraud's avatar
bperraud committed
53

bperraud's avatar
bperraud committed
54
55
56
57
                  <xsl:if test="count(..//h4) &gt; 0">

                    <ul class="toc level4">
                      <xsl:for-each select="..//h4">
bperraud's avatar
bperraud committed
58

bperraud's avatar
bperraud committed
59
60
                        <li>
                          <xsl:call-template name="toc-a"/>
bperraud's avatar
bperraud committed
61

bperraud's avatar
bperraud committed
62
63
64
65
                          <xsl:if test="count(..//h5) &gt; 0">

                            <ul class="toc level5">
                              <xsl:for-each select="..//h5">
bperraud's avatar
bperraud committed
66

bperraud's avatar
bperraud committed
67
68
                                <li>
                                  <xsl:call-template name="toc-a"/>
bperraud's avatar
bperraud committed
69

bperraud's avatar
bperraud committed
70
                                  <xsl:if test="count(..//h6) &gt; 0">
Baptiste Perraud's avatar
Baptiste Perraud committed
71

bperraud's avatar
bperraud committed
72
73
                                    <ul class="toc level6">
                                      <xsl:for-each select="..//h6">
bperraud's avatar
bperraud committed
74

bperraud's avatar
bperraud committed
75
76
                                        <li>
                                          <xsl:call-template name="toc-a"/>
bperraud's avatar
bperraud committed
77

bperraud's avatar
bperraud committed
78
79
80
                                        </li>
                                      </xsl:for-each>
                                    </ul>
bperraud's avatar
bperraud committed
81

bperraud's avatar
bperraud committed
82
                                  </xsl:if>
bperraud's avatar
bperraud committed
83

bperraud's avatar
bperraud committed
84
85
86
                                </li>
                              </xsl:for-each>
                            </ul>
bperraud's avatar
bperraud committed
87

bperraud's avatar
bperraud committed
88
                          </xsl:if>
bperraud's avatar
bperraud committed
89

bperraud's avatar
bperraud committed
90
91
92
                        </li>
                      </xsl:for-each>
                    </ul>
bperraud's avatar
bperraud committed
93

bperraud's avatar
bperraud committed
94
                  </xsl:if>
bperraud's avatar
bperraud committed
95

bperraud's avatar
bperraud committed
96
97
98
99
100
                </li>
              </xsl:for-each>
            </ul>

          </xsl:if>
bperraud's avatar
bperraud committed
101

bperraud's avatar
bperraud committed
102
103
104
        </li>
      </xsl:for-each>
    </ul>
bperraud's avatar
bperraud committed
105

bperraud's avatar
bperraud committed
106
    </xsl:if>
bperraud's avatar
bperraud committed
107

bperraud's avatar
bperraud committed
108
109
110
111
112
113
114
115
116
117
118
  </xsl:template>
  
  <xsl:template name="toc-a">
    <a>
      <xsl:attribute name="href">
        <xsl:text>#</xsl:text>
        <xsl:value-of select="./@id"/>
      </xsl:attribute>
      <xsl:value-of select="."/>
    </a>
  </xsl:template>
bperraud's avatar
bperraud committed
119
120
121



122
</xsl:stylesheet>