I am using xqj api for implemeting XQuery in java, the following is a sample query I have got and it does work. I need to write the output of the query into a .xml file , any one help me in this please?
String queryString =
"declare variable $docName as xs:string external;" + sep +
"for $cat in doc($docName)/*/"+ objectName +
" where $cat/"+field+" > "+ value +
" order by $cat/" + field + " "+
"return $cat";
XQExpression expression = conn.createExpression();
expression.bindString(new QName("docName"), filename,
conn.createAtomicType(XQItemType.XQBASETYPE_STRING));
XQSequence results = expression.executeQuery(queryString);
System.out.println(results.getSequenceAsString(new Properties()));