The iterator() method of the XQueryEvaluator class returns an iteration of XdmItem objects. If your query selects nodes, then the XdmItem will always be an XdmNode. If you need to drill down from this, XdmNode.getUnderlyingNode() returns a NodeInfo object, and if the result is actually a JDOM node then you can cast the NodeInfo to VirtualNode and call its getUnderlyingNode() method to get to the JDOM level.
 
I'm considering providing more direct support in s9api for external object models in a future release, but I wanted to take my time and think carefully how best to do it. It will certainly be more type-safe than the JAXP approach. This will be a lot easier once I'm freed from the constraints of supporting JDK 1.4.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Baxter, Frank (LNG-CON)
Sent: 16 September 2008 15:30
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Returning JDOM Elements from an XQuery

I've been able to return the XPath results as Elements by doing this:
 
      XPathExpression expression = thePathEvaluator.createExpression(query);
      return (List<Element>) expression.evaluate(myDocumentWrapper);
 
I've been unable to figure out how to do something similiar with XQueryExecutable.  How do you return the XQuery results as a list of org.jdom.Element objects?
 
Thanks,
 
Frank