Subject: Re: [xsl] XSL Query From: Joerg Heinicke <joerg.heinicke@xxxxxx> Date: Sun, 27 Oct 2002 08:31:57 +0000 |
Date: Sat, 26 Oct 2002 19:51:51 -0400 From: Navin Kumar <navin1@xxxxxxxx> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: Need help on XSL query
Hello,
I need to display the sum of sales for each country only once! Current code is not properly working and I understand it is because the loop itself is to select all possible "@country" occurences but I also tried to use set:distinct but am getting error like "set function not found in namespace...". Could someone help me out in resolving this problem? Here is the template I have written:
=============================================== <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="locations" match="location" use="@country" /> <xsl:template match="/"> <html> <body> <table> <xsl:for-each select="//@country"> <xsl:variable name="country"> <xsl:value-of select="." /> </xsl:variable> <xsl:variable name="Total"> <xsl:value-of select="sum(key('locations',$country)/sales)" /> </xsl:variable> <xsl:value-of select="$country" /> <xsl:value-of select="$Total" /> <br/> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
XML FILE IS =========== <SalesDB> <time year="1996" quarter="1"> <product category="Ford" brand="Escort"> <location country="USA" state="NY"> <sales>70</sales> </location> <location country="USA" state="CA"> <sales>80</sales> </location> <location country="Canada" state="Ontario"> <sales>90</sales> </location> <location country="Canada" state="British Columbia"> <sales>100</sales> </location> </product> .........continue........ ===============================================
Thanks and regards, Navin
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL Query, Mitch Amiano | Thread | [xsl] ANN: mtxslt, a multi-XSLT-eng, Anthony B. Coates |
Re: [xsl] Sorting on a transformed , Mitch Amiano | Date | RE: [xsl] Sorting on a transformed , Michael Kay |
Month |