[xquery-talk] incomplete results

Michael Kay mhk at mhk.me.uk
Wed Dec 1 16:16:58 PST 2004

> I was expecting an error if I tried to
> return an attribute that wasn't there.

A path expression such as @a returns the empty sequence if the context node
has no @a attribute.

This obviously makes sense with elements: ./author returns a sequence of 2
nodes if there are two authors, one node if there is one author, zero nodes
if there are no authors. Attributes are just handled the same way. If this
weren't the case you wouldn't be able to do if(@a) to test if the attribute
exists - this is simply a test for whether the sequence returned by @a is
empty or not.

Michael Kay

More information about the talk mailing list