|
[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.comThu Aug 6 23:42:53 PDT 2009
>
> 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! 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
|






