[xquery-talk] items as nodes or atomic values

Ronald Bourret rpbourret at rpbourret.com
Mon May 7 23:36:29 PDT 2007


I think this touches on something that took me years to understand, and 
that is that when you parse an XML document (or construct XML nodes with 
direct or indirect constructors), the result is *always* nodes and not 
atomic values, even if there is schema information present.

For example, the result of parsing or constructing:

    <price>10</price>

is always the node tree:

     Element node (name=price)
         |
     Text node (value=10)

It is not:

     Element node (name=price)
          |
     Atomic value (type=string, value=10)

and it is not (in the presence of schema information):

     Element node (name=price)
          |
     Atomic value (type=float, value=10.0)

You can, of course, convert the various nodes into atomic values, such 
as through the string() or data() functions or through casting, but they 
start out as nodes.

(Hopefully I've got this right. Please correct me if I don't...)

-- Ron

Smith, Donald T. wrote:
> I do see from the example how nodes and (atomic) values interact, but it
> seems to confirm my prior understanding of node trees since, in the
> example given, the result of the @x expression is (first) a node whose
> value is (then) atomized. So I'm still thinking initially of the node
> tree and then about how a given node value is or is not atomized. What
> I'm not tracking with is thinking of atomic values without, or apart
> from, nodes.  




More information about the talk mailing list