Hi all, I'm having an issue with evaluating an XPath expression in an extension element. It works fine for almost all cases I've tried so far, but if I have a variable in my stylesheet which has child nodes under it, I'm having difficulty when I try to resolve any of the children more than once. So for a variable $blahVar which resolves to this element:
<entry code="blah"> <firstamount>12345</firstamount> <secondamount>67890</secondamount> </entry> ... I can pass my element something like <tst:myElement value="$blahVar/firstamount" /> and have it work on '12345', however after accessing the variable for the first time any subsequent accesses fail. If I put that same call in again, or substitute $blahVar/secondamount then the XPath variable always resolves to the empty string. This is obviously possible - I have xsl:value-of doing the exact same lookups with the same XPath strings right alongside and getting the correct results. I've been checking through the xalan-j source this morning to see if I could see what I'm missing, but I'm still quite new to xalan-j and nothing has jumped out at me so far. The code I'm using is as follows: protected static String xpathLookup(XSLProcessorContext context, ElemExtensionCall call, String exp) throws TransformerException { String nodeText = ""; if ((exp != null && exp.length() != 0)) { TransformerImpl transformer = context.getTransformer(); XPathContext xpContext = transformer.getXPathContext(); try { xpContext.pushNamespaceContext(call); int current = xpContext.getCurrentNode(); xpContext.pushCurrentNodeAndExpression(current,current); XPath dynamicXPath = new XPath( exp, xpContext.getSAXLocator(), xpContext.getNamespaceContext(), XPath.SELECT, transformer.getErrorListener()); Expression expression = dynamicXPath.getExpression(); XObject xobj1 = expression.execute(xpContext); xpContext.popCurrentNodeAndExpression(); xpContext.popNamespaceContext(); nodeText = xobj1.toString(); } catch(TransformerException te) {} } return nodeText; } I know this has to be something really simple that I'm missing, any help is appreciated. Thanks, Peter Carberry.