[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Adding content for with distinct-values

Michael Kay mhk at mhk.me.uk
Thu Dec 9 22:32:53 PST 2004


distinct values
I suspect that grouping with XQuery is going to turn into as arcane an art
as grouping in XSLT 1.0, with the difference that there's no key() function
to assist. (And that some implementations of XQuery might not support the
preceding-sibling axis).

The simplest solution is probably

for $d in distinct-values(dy:iu-count/@ID)
return <dy:iu-count ID="{$d}"> {
   sum( http://xquery.com/mailman/listinfo/talk[@ID=$d] )
} </dy:iu-count>

Note that distinct-values returns the results in undefined order.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: http://xquery.com/mailman/listinfo/talk 
> [mailto:http://xquery.com/mailman/listinfo/talk] On Behalf Of Bruno Chatel
> Sent: 09 December 2004 21:36
> To: http://xquery.com/mailman/listinfo/talk
> Subject:  Adding content for with distinct-values
> 
> Hi,
> 
> I am looking for a way to do the following (and do not find)..
> 
> I have a node set containing something like
>  
> <dy:iu-count ID ="n0001000300040011|000100010002" > 1 </ 
> dy:iu-count > 
> <dy:iu-count ID ="n0001000300040011|000100010002" > 1 </ 
> dy:iu-count > 
> <dy:iu-count ID ="n00010002001100030002|000100020003" > 1 </ 
> dy:iu-count > 
> <dy:iu-count ID ="n0001000500040004|000100080004" > 1 </ 
> dy:iu-count > 
> <dy:iu-count ID ="n0001000500040004|000100080004" > 1 </ 
> dy:iu-count > 
> <dy:iu-count ID ="n0001000500040004|000100080004" > 1 </ 
> dy:iu-count > 
> <dy:iu-count ID ="n0001000500040004|000100080004" > 1 </ 
> dy:iu-count > 
> 
> and i like to return this :
> 
> <dy:iu-count ID ="n0001000300040011|000100010002" > 2 </ 
> dy:iu-count > 
> <dy:iu-count ID ="n00010002001100030002|000100020003" > 1 </ 
> dy:iu-count > 
> <dy:iu-count ID ="n0001000500040004|000100080004" > 4 </ 
> dy:iu-count > 
> 
> I suspect using distinct-values and sum but do not succeed.
> 
> Thanks in advance for your help
> 
> Regards
> 
> -- bruno -- 
> Bruno Chatel
> Tel : (+33) (0)4 96 11 14 57
> http://xquery.com/mailman/listinfo/talk
> --------------------------------------
> 
> 
> _______________________________________________
> http://xquery.com/mailman/listinfo/talk
> http://xquery.com/mailman/listinfo/talk
> 



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.