You haven't shown your source document, so I can't tell why this query retrieves nothing. My guess would be that the <input> elements are in a namespace, whereas your query is only selecting <input> elements that are in no namespace.
Incidentally, the query
   for $x in //input return $x
can be abbreviated to


Michael Kay


From: Gaurav sharma []
Sent: 19 November 2009 10:10
Subject: [saxon] issue while compile and execute an XQuery expression withSaxon.

Hi All,

I am SAXON user. And trying to compile and execute an XQuery expression with Saxon.

objective : execute the Xquey on document object and get the Domelement list.

I am using below code for that.
Configuration c = new Configuration();
StaticQueryContext qp = new StaticQueryContext(c);
XQueryExpression xe = qp.compileQuery(query);
DynamicQueryContext dqc = new DynamicQueryContext(c);
dqc.setContextNode(new DocumentWrapper(dom, url, c));
List result = xe.evaluate(dqc);



Here query= "for $x in  //input \n" + "return $x \n";

And dom is a object of org.w3c.dom.Document.

Document object is having input element. But when I evaluate xquery expression, list size is coming zero. Also I am not getting any exception.

I tried same code with some other URL where I am able to see the result. So what is the problem with other one.


Can anyone please answer following question?


-        Why the list size is coming zero if Document object is having input element.

-        How can I find the baseURI (variable name - url).

-        Is there any way to trace the log/warning/errors.