XQJ, option declaration
Friday, 1 February 2013 · 2 messages
MF
marco fregonese1 Feb 2013 18:15 #
Hi there,
In my application I have this method:
public static String getAllPartsAsTree(String a) throws XQException,
XQQueryException
{
XQConnection con = Connection.getConnection();
XQExpression xqe = con.createExpression(); xqe.bindString(new QName("b"), a, null);
String xqueryString =
"import module namespace lib=\"
http://www.example.com/library_module\";" +
"declare option output:method \"xhtml\";" + "declare variable $b external; " +
"lib:gethtml($b)";
XQResultSequence rs = xqe.executeQuery(xqueryString) ;
String b = rs.getSequenceAsString(null);
con.close();
return b;
}When I run the app I get the following error message:
Exception in thread "main" javax.xml.xquery.XQException: The prefix "output" is unknown in this static context.
I can't understand how to interpret the error message.
The same query in BaseXGUI works perfectly.
I hope someone can help me.
Thanks!
CG
Christian Grün1 Feb 2013 18:21 #
You may need to add the namespace declaration in your query. I have slightly revised our documentation to make this more explicit:
http://docs.basex.org/wiki/XQuery_3.0#Serialization
Quoted text · marco fregonese · 46 lines
On Fri, Feb 1, 2013 at 6:15 PM, marco fregonese <marcofregonese at gmail.com> wrote: > Hi there, > > In my application I have this method: > > public static String getAllPartsAsTree(String a) throws XQException, > XQQueryException > { > XQConnection con = Connection.getConnection(); > XQExpression xqe = con.createExpression(); > > xqe.bindString(new QName("b"), a, null); > > String xqueryString = > "import module namespace > lib=\"http://www.example.com/library_module\";" + > "declare option output:method \"xhtml\";" + > "declare variable $b external; " + > "lib:gethtml($b)"; > > XQResultSequence rs = xqe.executeQuery(xqueryString) > ; > > String b = rs.getSequenceAsString(null); > > con.close(); > > return b; > } > > When I run the app I get the following error message: > > Exception in thread "main" javax.xml.xquery.XQException: The prefix "output" > is unknown in this static context. > > I can't understand how to interpret the error message. > The same query in BaseXGUI works perfectly. > I hope someone can help me. > Thanks! > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
Written for BaseX 7.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery