[xquery-talk] Tales of the unexpected version III - Atomization
David Carlisle
davidc at nag.co.uk
Wed Jan 8 03:20:52 PST 2014
On 08/01/2014 11:11, Ihe Onwuka wrote:
>
>
>
> On Wed, Jan 8, 2014 at 11:03 AM, David Carlisle <davidc at nag.co.uk
> <mailto:davidc at nag.co.uk>> wrote:
>
> On 08/01/2014 09:35, Ihe Onwuka wrote:
>
> >
> > <person>{$thing/@name}</__person>
>
>
> I can't begin to fathom the rationale for the exception or the
> value of
> such an exception over the simple rule of atomizing sequences if
> they
> appear in contexts where a value is expected.
>
>
> why do you think an atomised value is expected here?
>
>
> because the value you put in an attribute must be atomic.......
If you add such a sequence in an attribute constructor then it is
atomized, but here you are copying a sequence of nodes into an element
constructor. In particular you are adding attribute nodes.
>
> would you expect element nodes
>
>
> <person>{$thing/name}</person>
>
> to be atomised as well? (They aren't: this would add a sequence of
> <name> children to <person>)
>
>
> ......and the value of an element doesn't have to be.
You are copying a sequence of nodes so that <person> becodes their
parent, attribute and element nodes are treated similarly.
>
>
>
> > It seems to me that it is
>
> just demanding the explicit call of the data function (which is
> exactly
> what I put in) for something it could just have easily handled
> implicitly.
>
>
> But this construct is designed to add attribute nodes, so implicit
> atomization would be undesirable.
>
>
> Why? It cannot be a placeholder for anything but an atomic value.
No, as shown here it is copying attribute nodes. If $thing is
<foo name="me"/>
then
<person>{$thing/@name}</person>
is
<person name="me"></person>
but
<person>{$thing/@name/string()}</person>
is
<person>me</person>
You are (I think) saying that atomization should be automatic and you
should get the second result, but then you would not be able to copy
attribute (or element) nodes.
David
>
>
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star.
> ________________________________________________________________________
--
google plus: https:/profiles.google.com/d.p.carlisle
________________________________________________________________________
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