From: Michael Kay [mailto:firstname.lastname@example.org]
Sent: March 5, 2005 18:29
Subject: RE: [saxon] Way to efficiently turn an Element into a NodeInfoI think you can do this as follows:Locate the Document node at the root of the DOM tree and doDocumentWrapper saxonDoc = new net.sf.saxon.dom.DocumentWrapper(doc, baseURI, config);NodeInfo saxonNode = saxonDoc.wrap(node);dynamicContext.setContextNode(saxonNode);Michael Kay
From: email@example.com [mailto:firstname.lastname@example.org] 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
Discover the Power of MetaSolvSubscribe to our Company Newsletter