[xquery-talk] Tales of the unexpected version III - Atomization

David Carlisle davidc at nag.co.uk
Wed Jan 8 04:07:44 PST 2014


On 08/01/2014 11:55, Ihe Onwuka wrote:
>
> for $t in things/thing group by $sex:=$t/@sex return
> <something>{$t/@sex}</something>
>
> the effect of the group by turns {$t/@sex} into a sequence of
> attribute nodes and the processor (at least eXist) will barf about
> duplicate attributes instead of atomizing them. Why barf - duplicate
> atttributes are not allowed and demand an explicit atomization?


because atomising would just be weird.

If $t/sex is a single sex="M" attribute node then it is not atomized it
is simply copied to <something> producing

<something sex="M"/>

If (as in your example) it is a sequence of two attribute nodes
sex="M" sex="M"
then as you can not have two attributes on the <something> element it is
an XQuery error. (XSLT takes a different route and just uses the last)

If the sequence were atomised then you would get

<something>MM</something>


as for

<something>{$t/string(@sex)}</something>

which would be pretty strange to happen by default.

David


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________


More information about the talk mailing list