[xquery-talk] XQuery Feature: Grouping

Martin Probst martin at x-hive.com
Mon Feb 27 17:15:15 PST 2006


> Can you be more specific about what you think this grouping operator 
> should do? I've been in a lot of discussions on grouping, and people 
> have quite different expectations of what a grouping expression should 
> do in an XML query language - obviously, SQL grouping does not fit this 
> data model very well.

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 ...

Martin





More information about the talk mailing list