W3C home > Mailing lists > Public > public-qt-comments@w3.org > March 2003

RE: Valid use of the Where clause

From: McMillan, Shane <Shane.McMillan@softwareagusa.com>
Date: Fri, 21 Mar 2003 14:44:08 -0700
Message-ID: <82962908B5CD7B4082925E2175E61F2201F38530@usmsg06.sagus.com>
To: "'Jonathan Robie'" <jonathan.robie@datadirect-technologies.com>, "McMillan, Shane" <Shane.McMillan@softwareagusa.com>, "'public-qt-comments@w3.org'" <public-qt-comments@w3.org>

Many thanks Mr Robie.  The results you highlighted below are exactly what we
were getting but not expecting.  We changed the let to a for and all works
Thanks for your reply

-----Original Message-----
From: Jonathan Robie [mailto:jonathan.robie@datadirect-technologies.com]
Sent: Friday, March 21, 2003 3:20 PM
To: McMillan, Shane; 'public-qt-comments@w3.org'
Subject: Re: Valid use of the Where clause

At 01:55 PM 3/21/2003 -0700, McMillan, Shane wrote:
>I have been reading the specs on 1.0 working draft for XQuery regarding 
>the where clause.  It does not seem to support the following syntax:
>Let $a := input()/person/lastname
>Where $a = "miller"<?xml:namespace prefix = o ns = 
>"urn:schemas-microsoft-com:office:office" />
>Return $a

If you delete "<?xml:namespace prefix = o ns = 
"urn:schemas-microsoft-com:office:office" />" and change the case of your 
keywords to lowercase, this parses fine according to our grammar:

         let $a := input()/person/lastname
         where $a = "miller"
         return $a

It's often helpful to try out queries on our test grammar page if you're 
not sure whether a given query parses:


>Notice in the where clause there is no further navigation down the tree 
>because this query wants all documents with lastname = to miller.  All 
>spec examples do not show this usage of the where clause.  Is the above 
>query syntactically correct based on the 1.0 standards?

Our BNF accepts this query just fine. You might be a little surprised by 
what it means! To explain why, let me add in a little data:

let $in := <people>
let $a := $in/person/lastname
where $a = "miller"
return $a

What do you expect this to return? It returns the following:


To explain why, let me step through this one clause at a time:

let $a := $in/person/lastname

    $a is bound to:

where $a = "miller"

     this is approximately equivalent to:

         where some $dot in $a satisfies $dot eq miller

return $a

      since the where clause evaluates to true,
      this returns $a

That's why for/where is more common than let/where, but let/where is very 
helpful with aggregate functions like sum(), count(), avg(), min(), and

Is that helpful?

Received on Friday, 21 March 2003 16:44:12 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:11 UTC