[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Problems with following-sibling

Subject: Problems with following-sibling
From: Barret Boombastic <barret@xxxxxxxxxx>
Date: Wed, 4 Jul 2007 18:10:01 +0300 (EEST)
 Problems with following-sibling
Hi.

I'm working on a project where I have to generate a line graph (using SVG)
from an XML-file generated by a program.
For example the XML-file can look like this (generated by the program):

<cars>
     <cartype>Sports cars</cartype>
     <active>true</active>
      <car>
        <name>Ferrari Enzo</name>
        <price>750000</price>
        <date>2007-05-21</date>
        <volume>15</volume>
      </car>
      <car>
        <name>Ferrari Enzo</name>
        <price>750000</price>
        <date>2007-06-13</date>
        <volume>19</volume>
      </car>
      <car>
        <name>Porsche Carrera GT</name>
        <price>600000</price>
        <date>2007-06-13</date>
        <volume>11</volume>
      </car>
      <car>
        <name>Ferrari Enzo</name>
        <price>750000</price>
        <date>2007-06-22</date>
        <volume>13</volume>
      </car>
      <car>
        <name>Bugatti Veyron</name>
        <price>15000000</price>
        <date>2007-06-22</date>
        <volume>4</volume>
      </car>
</cars>

The graph's y-axis holds the volume amount and the x-axis holds the date.
The idea is that the graph generates different color line graphs based on the
name of the car, so to address this I've written an XSLT-file.

Here is a snippet from the XSL-file:

<g transform="translate(60,400)">
 <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?
The <xsl:variable name="nextVolume" select="following-sibling::car/volume"/>
itself doesn't work since it doesn't seem to skip the Porsche's value, which
is between the Ferraris. Any help is greatly appreciated.

...................................................................
Luukku Plus paketilla pddset eroon tila- ja turvallisuusongelmista.
Hanki Luukku Plus ja helpotat eldmddsi. http://www.mtv3.fi/luukku

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.