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

XQuery count()

G. Ken Holman gkholman at CraneSoftwrights.com
Mon Nov 9 14:07:10 PST 2009


  XQuery count()
At 2009-11-09 18:55 +0000, Ricardo Queirós wrote:
>I need to count the total number of distinct 
>collections in my db (eXist XML Database).

How are you defining "distinct" in your 
situation?  There are many possible ways:  string 
value, tree structure, tree structure of string values, etc.

>How can i do this in a compact way using XQuery?

Consider using deep-equal() ... if you have two 
root nodes, say in $a and $b, you can get 
true/false with deep-equal( $a, $b ) and it will 
check the tree structure and the node values in 
the tree structure and things like attributes 
will be checked regardless of their order 
(because attributes in XML documents are unordered).

But be aware this is an "expensive" function, and 
could take up a lot of processing resources to accomplish the comparison.

I hope this helps.

. . . . . . . . . . . Ken


--
Upcoming:  hands-on XSLT, XQuery and XSL-FO Washington DC Nov 2009
Interested in other classes?  http://www.CraneSoftwrights.com/q/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:http://x-query.com/mailman/listinfo/talk
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal




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-2011 All Rights Reserved.