[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Grouping is not working that great over here

Subject: RE: Grouping is not working that great over here
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 11 Apr 2003 12:32:24 +0100
RE:  Grouping is not working that great over here
I haven't looked through this in detail, but if X has no date child,
then X[date=$date] will always select nothing (any "=" comparison with
an empty node-set returns false). If you want two non-existent dates to
compare equal, force the value to a string: X[string(date)=$date] - do
this wherever you use the date as a grouping key.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Matts Isuls
> Sent: 11 April 2003 06:32
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  Grouping is not working that great over here
> 
> 
> Hi
> 
> Having problems grouping (first timer). Someone please help 
> me out of this darkness.
> 
> thanks,
> Matts Isuls
> 
> 
> 
> I get this:
> 
> ------
> 20030404::1
> 20030405::2
> ------
> ::0
> 20030101::2
> ::0
> ------
> 20030202::2
> 20030303::1
> ------
> ::0
> ::0
> ------
> ::0
> ::0
> 
> but would like to get this:
> ------
> 20030404::1
> 20030405::2
> ------
> 20030101::2
> 20030404::1
> 20030405::2
> ------
> 20030202::2
> 20030303::1
> 20030404::1
> ------
> 20030404::1
> 20030405::2
> ------
> 20030404::1
> 
> ----------
> ---XSL----
> ----------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <!-- leave payment nodes without date out -->
> <xsl:key name="mkey" match="payments/payment[date]" use="date"/>
> 
> <xsl:template match="/">
>         <xsl:apply-templates select="parcels" /> 
> </xsl:template> <xsl:template match="parcels">
>         <xsl:apply-templates select="parcel" />
> </xsl:template>
> 
> <xsl:template match="parcel">
>    <br/>        ------
>     <xsl:for-each 
> select="payments/payment[count(.|key('mkey',date)[1])=1]">
>       <xsl:sort select="date" />
>       <xsl:variable name="date" select="date" />
>       <xsl:variable name="tot"
>          select="sum(../../payments/payment[date=$date]/amount)" />
>                         <br/><xsl:value-of select="$date" />
>                         ::<xsl:value-of select="$tot" />
>     </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
> 
> ----------
> --XML-----
> ----------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- <date> in <payment> may be missing -->
> <!-- normaly there is more data here but cut that out --> <parcels>
>         <parcel>
>                 <payments>
>                         <payment>
>                                 <date>20030404</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030405</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030405</date>
>                                 <amount>1</amount>
>                         </payment>
>                 </payments>
>         </parcel>
>         <parcel>
>                 <payments>
>                         <payment>
>                                 <amount>449</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030101</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030404</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030405</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030101</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030405</date>
>                                 <amount>1</amount>
>                         </payment>
>                 </payments>
>         </parcel>
>         <parcel>
>                 <payments>
>                         <payment>
>                                 <date>20030202</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030303</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030404</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030202</date>
>                                 <amount>1</amount>
>                         </payment>
>                 </payments>
>         </parcel>
>         <parcel>
>                 <payments>
>                         <payment>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030404</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030405</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030405</date>
>                                 <amount>1</amount>
>                         </payment>
>                 </payments>
>         </parcel>
>         <parcel>
>                 <payments>
>                         <payment>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <date>20030404</date>
>                                 <amount>1</amount>
>                         </payment>
>                         <payment>
>                                 <amount>1</amount>
>                         </payment>
>                 </payments>
>         </parcel>
> </parcels> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.