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

how to generate an inventory of elements in alistfor whole collection?

Michael Kay mike at saxonica.com
Thu Aug 6 23:42:53 PDT 2009


  how to generate an inventory of elements in
	alistfor whole collection?
> 
> I had to replace the "{.}" with "{$x}" to avoid an error from eXist.  

Sorry about that. It's an error I make all the time - the result of too many
years spent writing XSLT for-each instructions.

Incidentally the XSLT solution to this is:

<xsl:for-each-group select="//highlight/@subject/tokenize(.,';')">
  <token value="{current-grouping-key()}" count="{count(current-group())}"/>
</xsl:for-each-group>

-- which is rather easier for the system to optimize.

Regards,

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


> But, it worked beautifully and gives me an example of a way 
> to approach some other tasks. I had no idea how powerful a 
> "let" could be
> -- you just grabbed EVERYTHING needed for the calculation in one step!
> 
> thank you!
> -david
> 
> 
> ---
> 
> I think, from reverse engineering your description, that what 
> you want is along these lines:
> 
> let $tokens := //highlight/@subject/tokenize(.,';')
> for $x in distinct-values($tokens)
> return
>    <token value="{.}" count="{count($tokens[. eq $x])}"/>



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.