Bonjour,
j'arrive à trier un xml l'aide de xsl, mais je souhaite garder les n premiers noeuds apres tri seulement (et la j'y arrive pas). d'ou mon cri : A L'AIDE ;-)
exemple de xml
j'utilise "position () ", mais ça me ramène les 5 premiers AVANT tri alors que je voudrais les 5 premiers APRES tri... Je sèche completement....<tiltviewergallery>
<photos>
<photo imageurl="/phpgraphy-0.9.13a/pictures/2009-01-05 Lola/IMG_7646_resize.JPG"/>
<photo imageurl="/phpgraphy-0.9.13a/pictures/2009-01-05 Lola/IMG_7639_resize.JPG"/>
<photo imageurl="/phpgraphy-0.9.13a/pictures/2009-01-05 Lola/IMG_7637_resize.JPG"/>
<photo imageurl="/phpgraphy-0.9.13a/pictures/2009-01-05 Lola/IMG_7636_resize.JPG"/>
</photos>
</tiltviewergallery>
<xsl:stylesheet version="1.0" xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="utf-8" omit-xml-declaration="yes"/>
<xsl:template match="/">
<tiltviewergallery>
<photos>
<xsl:apply-templates />
</photos>
</tiltviewergallery>
</xsl:template>
<xsl:template match="tiltviewergallery">
<xsl:apply-templates select="/tiltviewergallery/photos/photo">
<xsl:sort select="@imageurl" order="descending" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="/tiltviewergallery/photos/photo[position() < 5]">
<photo imageurl="{@imageurl}">
</photo>
</xsl:template>
<xsl:template match="/">
<tiltviewergallery>
<photos>
<xsl:apply-templates />
</photos>
</tiltviewergallery>
</xsl:template>
</xsl:stylesheet>
Partager