[xsl] adding numbers

Subject: [xsl] adding numbers
From: 04083259@xxxxxxxxxxxxx
Date: Wed, 30 Mar 2005 13:36:43 +0100 (BST)
hi
i have the following xml database

<car>
<sub0><x>5</x><y>32</y><x>5</x><y>315</y></<x>54</x><y>31</y></sub0>
<sub1> <x>5</x><y>312</y></sub1>
<sub2><x>40</x><y> 48</y><x>120</x><y>-32</y><x>160</x><y>-6</y></sub2>
<sub3><x>0</x><y>8</y></sub3>
<sub4><x>10</x><y>-103</y><x>50</x><y>-83</y><x>90</x><y>-42</y></sub4>
<sub5><x>0</x><y>0</y><x>20</x><y>12</y><x>30</x><y>7</y></sub5>
 </car>

the following template will add the value of x and y  in last position
within the element sub2 to   x and y  in sub3

the problem i need to add  to x and y  within the element sub3 all the
priviouse x(s) and y(s) in last position  of the elements  sub2 and sub1
sub0 but could be more then these 3 elements

 <xsl:template match="path">
 <xsl:copy>
   <xsl:for-each select="*" >
 <xsl:choose>

<xsl:when test="contains(name(.), 'sub3') " >
<x><xsl:value-of
select="x[1]+current()/preceding-sibling::*[1]/child::x[position()=last()]"/></x><y><xsl:value-of
select="y[1]+current()/preceding-sibling::*[1]/child::y[position()=last()]"/></y>

    </xsl:when>

  </xsl:choose>
  </xsl:for-each>
  </xsl:copy>
 </xsl:template>

Current Thread