Salut,
Cela n'est pas possible directement sauf si tu peux calculer directement ta
valeur de tri sur des arguments ou des éléments du noeud site.
Dans le cas contraire, il faut faire 2 transformations 1 qui fait les calculs, 1 qui
fait le tri. Mais pour les calculs y a mieux que XSLT, faut mieux revoir la
génération du XML
Exemple vis à vis de la première 'option':
Fichier XML
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="sort_calc.xsl" ?>
<sites>
<site nom="1" vu="30" vote="3"/>
<site nom="2" vu="30" vote="20"/>
<site nom="3" vu="20" vote="3"/>
<site nom="4" vu="40" vote="20"/>
</sites>
Fichier XSL:
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output encoding="iso-8859-1" method="html"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:template match="/">
<html>
<head><title>XML: tri avec calcul</title></head>
<body>
<table style="width:80%;">
<tr>
<th style="width:25%;">site</th>
<th style="width:25%;">vote</th>
<th style="width:25%;">vu</th>
<th style="width:25%;">ratio</th>
</tr>
<xsl:for-each select="sites/site">
<xsl:sort select="@vote div @vu" data-type="number" order="descending"/>
<tr>
<td style="text-align:center;"><xsl:value-of select="@nom"/></td>
<td style="text-align:center;"><xsl:value-of select="@vote"/></td>
<td style="text-align:center;"><xsl:value-of select="@vu"/></td>
<td><xsl:value-of select="@vote div @vu"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
..., I think Slackware sounds better than 'Microsoft,'
-- Patrick Volkerding - founder and maintainer of Slackware