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
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- commande : xsltproc change.xsl base.xml > result.xml -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" encoding="ISO-8859-1" />
<xsl:template match="//*/*">
<xsl:variable name="prix" select="@prix" />
<xsl:variable name="type" select="name()" />
<xsl:variable name="nomlivre" select="@nom" />
<xsl:variable name="minprix">
<xsl:for-each select="//*[(name()= $type) and (@nom = $nomlivre)]">
<xsl:choose>
<xsl:when test="$prix <= @prix"> <!-- <= signifie inférieur ou egal -->
<xsl:value-of select="@prix"/>
</xsl:when>
<xsl:otherwise>
0
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:if test="$prix <= $minprix">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:if>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>
</xsl:stylesheet> |