|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XSL Query
>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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








