Subject: Re: Problems with following-sibling
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 04 Jul 2007 17:17:32 +0200
|
Barret Boombastic wrote:
<xsl:for-each select="car[name = 'Ferrari Enzo']">
<xsl:variable name="nextVolume" select="following-sibling::car/volume"/>
<line x1="{position()*15}" y1="-{volume} " x2="{(position()+1)*15}" y2="-{$nextVolume}" style="stroke: red;"/>
</xsl:for-each>
</g>
Here is the problem: When I try to get the "nextVolume" with "following-sibling::car/volume" it works fine if the next car is a Ferrari, but as you can see the cars can be at any order in the xml-file.
I've selected specifically the Ferraris with the "for-each", but how do I select the following sibling so that it also matches the car name?
Can't you simply use the same predicate as before? That is [name =
'Ferrari Enzo'] so
<xsl:for-each select="car[name = 'Ferrari Enzo']">
<xsl:variable name="nextVolume" select="following-sibling::car[name =
'Ferrari Enzo'][1]/volume"/>
should do.
--
Martin Honnen
http://JavaScript.FAQTs.com/
|