Hi everyone,
A newbie to this site and to XML in general, I am having a small issue with my stylesheet.
I have so far managed to use xsl:value-of to output a sum of some selected elements, and while the output is fine it tends to repeat itself far too many times.
Here is an example of my XSL:
Here is a snippet of my XML:
The output appears to add the sum of the points correctly but if the sum of Cyan is 8, Yellow is 12 and Magenta is 6 the output is
8
12
6
8
12
6
8
12
6
8
12
6
8
12
6
[...]
-------------------------------
I am hoping that someone will be able to help me identify why the output is being repeated so many times when it is only required to be displayed once.
I appreciate any help, suggestions or advice anyone can provide. Thanks to anyone who can help!
PS. As mentioned before, new to XML & this website - both of which I seem to like a lot. Hopefully it won't be too long before I can offer some assistance to others
A newbie to this site and to XML in general, I am having a small issue with my stylesheet.
I have so far managed to use xsl:value-of to output a sum of some selected elements, and while the output is fine it tends to repeat itself far too many times.
Here is an example of my XSL:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match="runner">
<xsl:value-of select="sum(//points[preceding-sibling::house='Cyan'])" /><br />
<xsl:value-of select="sum(//points[preceding-sibling::house='Magenta'])" /><br />
<xsl:value-of select="sum(//points[preceding-sibling::house='Yellow'])" /><br />
<xsl:value-of select="sum(//points[preceding-sibling::house='Black'])" /><br />
</xsl:template>
</xsl:stylesheet>
Here is a snippet of my XML:
Code:
<carnivals>
<carnival>
<events>
<maleunder13>
<runner>
<lane>1</lane>
<position>3</position>
<time>11:44:47</time>
<house>Cyan</house>
<points>2</points>
</runner>
<runner>
<lane>2</lane>
<position>2</position>
<time>11:44:46</time>
<house>Magenta</house>
<points>3</points>
</runner>
<runner>
<lane>3</lane>
<position>1</position>
<time>11:44:41</time>
<house>Magenta</house>
<points>4</points>
</runner>
</maleunder13>
</events>
</carnival>
</carnivals>
The output appears to add the sum of the points correctly but if the sum of Cyan is 8, Yellow is 12 and Magenta is 6 the output is
8
12
6
8
12
6
8
12
6
8
12
6
8
12
6
[...]
-------------------------------
I am hoping that someone will be able to help me identify why the output is being repeated so many times when it is only required to be displayed once.
I appreciate any help, suggestions or advice anyone can provide. Thanks to anyone who can help!
PS. As mentioned before, new to XML & this website - both of which I seem to like a lot. Hopefully it won't be too long before I can offer some assistance to others