Parsing Xquery queries
Added by Anonymous about 17 years ago
Legacy ID: #4548591 Legacy Poster: ielghand (ielghand)
Hello, I would like to parse XQuery queries. I went through the documentation but could not figure out whether or not saxon can help me with what I want to do. I mainly need to identify the let , for , where , return clauses. And for each clause I need to identify the bound variable if there is one, and the XPath expression. I was thinking for this example: let $i = for $j in doc("docName")/a/b return $j/c return max($i) Then the parser identifies, that there is a "let clause" with variable "$i" bound to the query " for $j in doc("docName")/a/b return $j/c" , and the return value is "max($i)" . Next I can parse the query bounded to $i , and so on. I was also hoping to identify structured queries. For example separate the following queries: for $i in doc("docName")/a/b return <retVal> for $j in $i/c return $j/d </retVal> Can I do something like that with saxon? Or may be something simpler and I add code to achieve what I want to do. Thanks, Iman
Replies (2)
RE: Parsing Xquery queries - Added by Anonymous about 17 years ago
Legacy ID: #4548648 Legacy Poster: Michael Kay (mhkay)
You might be able to adapt Saxon's internal parser to do what you need, but a better bet is probably to use David Carlisle's tools at http://monet.nag.co.uk/xq2xml/index.html or any other tool which converts XQuery to XQueryX. Once it's in XQueryX form you can manipulate it directly using XSLT or XQuery itself.
RE: Parsing Xquery queries - Added by Anonymous about 17 years ago
Legacy ID: #4548666 Legacy Poster: ielghand (ielghand)
Thank you very much Michael for your help Cheers, Iman
Please register to reply