Hello,

Forgive me if this question is a little garbled, but I'm new to a lot of
this.

I want to be able to execute an XPATH expression, and then execute another
one for each node returned.

I'm using the XPathAPI class in Xalan to do this, but the problem I'm
finding is that the nodelist returned by the first call is simply a series
of pointers back into the original XML document, and what I really need is
for the XPath execution to produce a series of new document instances.

For example, consider the following XML file:

<people>
<manager>
<name>
    <firstname>Bob</firstname>
    <lastname>Smith</lastname>
</name>
<address>
    <town>St Albans</town>
    <county>Hertfordshire</county>
</address>
</manager>
<employee>
<name>
    <firstname>Jane</firstname>
    <lastname>Doe</lastname>
</name>
<address>
    <town>Hatfield</town>
    <county>Hertfordshire</county>
</address>
</employee>
<employee>
<name>
    <firstname>John</firstname>
    <lastname>Doe</lastname>
</name>
<address>
    <town>London Colney</town>
    <county>Hertfordshire</county>
</address>
</employee>
</people>

If my first XPath expression is:        //employee

which results in 2 nodes:

<employee>
<name>
    <firstname>Jane</firstname>
    <lastname>Doe</lastname>
</name>
<address>
    <town>Hatfield</town>
    <county>Hertfordshire</county>
</address>
</employee>

<employee>
<name>
    <firstname>John</firstname>
    <lastname>Doe</lastname>
</name>
<address>
    <town>London Colney</town>
    <county>Hertfordshire</county>
</address>
</employee>


However, executing a subsequent XPathAPI call using each of these nodes as
the context node, e.g. //firstname results in:

<firstname>Bob</firstname>
<firstname>Jane</firstname>
<firstname>John</firstname>

- as the XPath call reverts to DocumentRoot when it finds a "//" in an XPath
expression.
when I really only want the following:
 
<firstname>Jane</firstname>
<firstname>John</firstname>

So, my question is: how do I ensure that subsequent calls to the XPathAPI
methods use the context node as the document root? FYI, I've tried using
"importNode" and "clone" to create new copies of the nodes, but the XPathAPI
calls fail to find anything, I guess because DocumentRoot is set to NULL
following an importNode or clone call.

Cheers

Darren.