[antlr-interest] XQuery Grammar?

Arnar Birgisson ArnarB at oddi.is
Wed May 4 01:33:22 PDT 2005


Hullo..

Michel wrote: 
> What do you want to do with your grammar ? Why not use standard XML
> methods/tools like DOM, SAX, XML Schema, XPath,... to use your XQuery
> document ?

XQuery is not XML based itself, it's a procedural language. Thus, a specific parser is needed if one wants to build an XQuery processor.

Here's a sample XQuery:

<results>
  {
    let $a := doc("http://bstore1.example.com/bib/bib.xml")//author
    for $last in distinct-values($a/last),
        $first in distinct-values($a[last=$last]/first)
    order by $last, $first
    return
        <result>
            <author>
               <last>{ $last }</last>
               <first>{ $first }</first>
            </author>
            {
                for $b in doc("http://bstore1.example.com/bib.xml")/bib/book
                where some $ba in $b/author 
                      satisfies ($ba/last = $last and $ba/first=$first)
                return $b/title
            }
        </result>
  }
</results> 


- Arnar




More information about the antlr-interest mailing list