[xquery-talk] incomplete results

Michael Rys mrys at microsoft.com
Wed Dec 1 09:13:43 PST 2004


There is one situation where you can get a static error:

1. If you have a static typing implementation and
2. The data you query is typed with a schema that has a closed content
model and
3. The path expression's type inference infers empty().

Then a statically typed implementation raises a type error since the
path does not exist...

Best regards
Michael

> -----Original Message-----
> From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On
Behalf
> Of Michael Kay
> Sent: Wednesday, December 01, 2004 8:17 AM
> To: 'Cindy Girard'; talk at xquery.com
> Subject: RE: Re[2]: [xquery-talk] incomplete results
> 
> > 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
> http://www.saxonica.com/
> 
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk



More information about the talk mailing list