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: http://www.w3.org/2002/08/applets/xqueryApplet.html >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> <person><lastname>robie</lastname></person> <person><lastname>miller</lastname></person> </people> let $a := $in/person/lastname where $a = "miller" return $a What do you expect this to return? It returns the following: <lastname>robie</lastname> <lastname>miller</lastname> To explain why, let me step through this one clause at a time: let $a := $in/person/lastname $a is bound to: <lastname>robie</lastname>, <lastname>miller</lastname> 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 max(). Is that helpful? JonathanReceived on Friday, 21 March 2003 16:19:44 GMT
This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:13:58 GMT