How to express an Inner Join in XSLT?
Posted: Thu Apr 21, 2011 2:23 pm
My source XML is as follows:
I want to calculate 'The total distance covered by all Porsche cars'.
My query should look something like:
sum(/Data/Journey[SOMECONDITION]/@distance)
(where SOMECONDITION joins the journeys to the associated car and checks that @type = 'Porsche')
---
I'm just not quite sure of how to express this in XSLT. Any help would be appreciated.
Code: Select all
<Data>
<Car registration="1" type="Ford" />
<Car registration="2" type="Volkswagen" />
<Car registration="3" type="Volkswagen" />
<Car registration="4" type="Porsche" />
<Car registration="5" type="Porsche" />
<Journey car="1" distance="10" />
<Journey car="1" distance="15" />
<Journey car="3" distance="5" />
<Journey car="2" distance="6" />
</Data>
My query should look something like:
sum(/Data/Journey[SOMECONDITION]/@distance)
(where SOMECONDITION joins the journeys to the associated car and checks that @type = 'Porsche')
---
I'm just not quite sure of how to express this in XSLT. Any help would be appreciated.