1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<!-- Parametres d entrees -->
<xsl:param name="champTri"/>
<xsl:param name="sensTri"/>
<!-- Template aplati -->
<xsl:template name="aplati">
<!-- Pour tous les fils sans fils -->
<xsl:for-each select="*[count(*)=0]">
<xsl:if test="name()!='ID'">
<td>
<xsl:value-of select="."/>
</td>
</xsl:if>
</xsl:for-each>
<xsl:choose>
<!-- Pour les Petits enfants -->
<xsl:when test="count(*[count(*)!=0])!=0">
<td>
<table border="1">
<xsl:for-each select="*">
<tr>
<xsl:call-template name="aplati"/>
</tr>
</xsl:for-each>
</table>
</td>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Fin Template aplati -->
<xsl:template match="root">
<table border="1">
<!-- Faire un tri différent selon que le champ à trier soit une date -->
<!--!!! TEMPORAIRE !!!-->
<xsl:choose>
<xsl:when test="contains(*/*[name()=$champTri],'/')">
<!-- Pour chaque ligne -->
<xsl:for-each select="*">
<xsl:sort select="concat(substring(*[name()=$champTri],7,4), substring(*[name()=$champTri],4,2), substring(*[name()=$champTri],1,2))" order="{$sensTri}"/>
<tr>
<!-- Pour chaque colone -->
<xsl:for-each select="*">
<!-- Pas de fils -->
<xsl:if test="count(*)=0">
<xsl:if test="name()!='ID'">
<td>
<xsl:value-of select="."/>
</td>
</xsl:if>
</xsl:if>
<xsl:if test="count(*)!=0">
<xsl:call-template name="aplati"/>
</xsl:if>
</xsl:for-each>
</tr>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<!-- Pour chaque ligne -->
<xsl:for-each select="*">
<xsl:sort select="*[name()=$champTri]" order="{$sensTri}"/>
<tr>
<!-- Pour chaque colone -->
<xsl:for-each select="*">
<!-- Pas de fils -->
<xsl:if test="count(*)=0">
<xsl:if test="name()!='ID'">
<td>
<xsl:value-of select="."/>
</td>
</xsl:if>
</xsl:if>
<xsl:if test="count(*)!=0">
<xsl:call-template name="aplati"/>
</xsl:if>
</xsl:for-each>
</tr>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</table>
</xsl:template>
</xsl:stylesheet> |
Partager