[XSLT]Sort sur un attribut dont la valeur est en param
Bonjour,
je voudrais faire un tri sur un attribut dont le nom est passé en paramètre.
Je m'explique, tout d'abord voici mon fichier xml :
Code:
1 2 3 4 5 6
|
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="TableauxSynthetiques.xsl"?>
<racine>
<row numero="F3" libelle="Truc" t1="13" t2="50" t3="47" t4="190" total="300" cible="600" atteinte="50%"/>
</racine> |
Voici maintenant mon fichier xsl :
Code:
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
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="order">ascending</xsl:param>
<xsl:param name="field">cible</xsl:param>
<xsl:template match="/">
<table width="100%" border="1">
<tr class="header">
<th><a href="d2restitutionTableauSynthetique.asp"><u>N°</u></a></th>
<th>Libellé</th>
<th>T1</th>
<th>T2</th>
<th>T3</th>
<th>T4</th>
<th>Total</th>
<th>Cible</th>
<th width="80"><a href="d2restitutionTableauSynthetiqueTri.asp"><u>Atteinte de la cible</u></a></th>
</tr>
<xsl:for-each select="racine/row">
<xsl:sort select="*[name()=$field]" order="{$order}"/>
<tr>
<td width="30" class="11px" align="center"><xsl:value-of select="@numero"/></td>
<td class="11px" align="center"><xsl:value-of select="@libelle"/></td>
<td class="11px" align="right"><xsl:value-of select="@t1"/></td>
<td class="11px" align="right"><xsl:value-of select="@t2"/></td>
<td class="11px" align="right"><xsl:value-of select="@t3"/></td>
<td class="11px" align="right"><xsl:value-of select="@t4"/></td>
<td class="11px" align="right"><xsl:value-of select="@total"/></td>
<td class="11px" align="right"><xsl:value-of select="@cible"/></td>
<td class="11px" align="right"><xsl:value-of select="@atteinte"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet> |
Je voudrais donc effectuer un tri sur le champ passé en param (field). Cependant ce code ne marche pas car je veux faire un tri sur un attribut et non sur un élément. Où ajouter le '@' dans la balise sort ?
Merci pour votre aide !