> Here is what you do...

Thanks for all the effort. Unfortunately, this doesn't work for me.
position() returns "111". Interestingly, last() now returns "012".

Does it work on your machine? And what about output from "last()"? I've
tried with Xalan 2.6.0 and JRE 1.4.2.

Here's the version I used (I've tried also variations on theme), just to
be sure the code got transported ok:

    String es1 = "/a/b";
    String es2 = "position()";
    XPathContext context = new XPathContext();
    XPath xp1 = new XPath( es1, null, null, XPath.SELECT );
    XPath xp2 = new XPath( es2, null, null, XPath.SELECT );
    XObject xo1 = xp1.execute( context, doc, null );
    NodeList nodelist = xo1.nodelist();
    int contextSize = nodelist.getLength();
    context.pushContextNodeList( (org.apache.xml.dtm.DTMIterator) xo1 );
    for ( int i = 0; i < contextSize; i ++ )
    {
      Node n = nodelist.item( i );
      context.getContextNodeList().nextNode();
      XObject xo2 = xp2.execute( context, n, null );
      System.out.print( xo2 );
    }


Reply via email to