>Is there a way to convert Xalan Nodeset back to Xerces Dom node list?

Xalan's NodeSet class partially implements the W3C's DOM NodeList API. Just
cast it. This will not be a _Xerces_ NodeList, but it should be close
enough for most purposes. (Note that this is a feature of Xalan, _not_
something guaranteed by XSLT or XPath.)

We also partially implement the DOM's NodeIterator API, if you'd rather
view the results that way.

(What's partial about it? Mostly that we don't attempt to re-run the query
if you change the source document, as both NodeList and NodeIterator
theoretically expect us to.)

>Alternatively, is there a way to convert the result Xpath nodeset to DOM
>Document?

If you really need a new Document containing the results of an XPath, the
easiest way to do that is probably to build a stylesheet which uses that
XPath as a selection pattern and outputs copies of the nodes it has found.
If you want to do it manually: Construct a new DOM document, use its
importNode operation to obtain copies of each of the nodes found by the
XPath, and insert these copies into appropriate places in the new document.


Reply via email to