[xquery-talk] XQuery Feature: Grouping

Jonathan Robie jonathan.robie at datadirect.com
Mon Feb 27 11:24:01 PST 2006


Martin Probst wrote:
> Grouping of nodes based on equality of some property of them, e.g.
>
> <book>
>   <title>Foo</title>
>   <author>X</author>
> </book>
> <book>
>   <title>Baz</title>
>   <author>Y</author>
> </book>
> <book>
>   <title>Bar</title>
>   <author>X</author>
> </book>
>
> Group so that I have a link from <author/>s to <book/>s.
>
> I know this is currently achievable using the distinct-values function
> (for $author in d-v(book/author) return book[author = $author]), but
> this is not very obvious for users, hard to detect for databases, plus
> it atomises the <author/> node. I remember XQuery was once advertised as
> making it a lot easier to do such "turning XML inside-out" stuff - I
> don't really consider this to be that easy ...
>   

So for your needs, it would be adequate if grouping were based on leaf 
nodes, using the typed value as the basis for comparison?

Jonathan

-- 
Read my Blog: http://blogs.datadirect.com/jonathan_robie/
Learn XQuery: http://media.datadirect.com/download/docs/ddxquery/tutorial_query.html
Learn XQJ (the JDBC for XQuery): http://www.datadirect.com/developer/xquery/topics/xqj_tutorial/
Get DataDirect XQuery: http://www.datadirect.com/products/xquery/



More information about the talk mailing list