Project

Profile

Help

Calling XQuery from Java

Added by Anonymous almost 19 years ago

Legacy ID: #3220533 Legacy Poster: anusr (anusr)

Hi, I am a newbie to XQuery processor. I was able to run the following Xquery from the command line by running java net.sf.saxon.Query line. query version "1.0"; declare copy-namespaces preserve,inherit; for $b in doc("d:/saxon/Emp.xml")//Company/Employee for $d in doc("d://saxon/Dept.xml")//Comp/Department where $b/Dept = $d /DeptId and $b/Dept = "D1" return <Emp> <Name> {$b/EmpName} </Name> <DeptName> {$d/DeptName} </DeptName> </Emp> ************************** I would like to translate the above FLOWR expression so that it could be called from within my java program. Which specific Xquery functions should I use ? I went thru' the documentation but it has sample code only for basic Xquery expressions.. I would greatly appreciate if someone could upload a sample code containing FLOWR expressions. Thanks, Anu


Replies (1)

RE: Calling XQuery from Java - Added by Anonymous almost 19 years ago

Legacy ID: #3220601 Legacy Poster: Michael Kay (mhkay)

Firstly, I'm surprised that doc("d:/saxon/Emp.xml") worked. The argument to doc() is required to be a URI, not a filename. You should write doc(file:///d:/saxon/Emp.xml"). Secondly, the API for running queries is the same regardless how complex the query is. You haven't said what you did, or how it failed, so it's impossible to tell what you did wrong. I can't give you any advice beyond referring you to the documentation at http://www.saxonica.com/documentation/using-xquery/embedding.html If you can't get it to work, please show us your code and tell us how it was failing. Michael Kay

    (1-1/1)

    Please register to reply