From: firstname.lastname@example.org [mailto:email@example.com] On Behalf Of Dueck, Brian
Sent: 05 March 2005 21:15
Subject: [saxon] Way to efficiently turn an Element into a NodeInfo
I'm using Saxon83 to invoke an Xquery expression. In my scenario I need to pass in a DOM element from another document that has already been parsed as the context node for the query. The DOM Element I need to set as the query context is some node in a large DOM tree that my function is being passed by another component. I have to just execute the query with the supplied DOM Element as the context, and return the result as a DOM Document.
Ideally, I'd like to be able to set the query context node using DynamicQueryContext.setContextNode(org.w3c.dom.Element), but of course setContextNode() only accepts a NodeInfo object.
Calling StaticQueryContext.buildDocument(Source) seems to be the only way to turn a DOM object into a NodeInfo, but this approach is not appealing to me as it returns the DOM Document object, not the DOM Element I was supplied. In other words, once I call buildDocument() I have no way of getting back to the original DOM Element (somewhere in that tree) I was interested in.
What I'm hoping is that there is some way of calling a buildDocument() like function that accepts a DOMSource but always returns me the NodeInfo representing the equivalent of the node returned by DOMSource.getNode().
Thanks in advance for any assistance,
Discover the Power of MetaSolv
Subscribe to our Company Newsletter