hi all, I have a org.w3c.dom.Node variable and I'm trying to use the JSTL with it. Something like: <x:out select="$node/@name"/> The odd thing is that the XPath expression is evaluated relative to the document root, not to the specified node. The following works: <x:out select="$node/full/path/to/node/@name"/> I'm filing this bug after a discussion on the taglibs-user mailing list: http://www.mail-archive.com/taglibs-user@jakarta.apache.org/msg07667.html A solution proposal is in this message: http://www.mail-archive.com/taglibs-user@jakarta.apache.org/msg07682.html regards, flavio
I've got what appears to be a working fix, but I'll want to post a patch for review as opposed to blindly committing it. I'm just not that familiar with the nuances of XPathUtil. Patch to follow, hopefully tonight.
Created attachment 12691 [details] Patch for XPathUtil.java
Maybe there is another (faster) way to achieve the same result. instead of creating a new Document and prepend "/*" to the original XPath, we may simply remove the starting slash from the XPath. xpath = xpath.substring( xpath.indexOf("/")); (XPathUtils 648) would become: xpath = xpath.substring( xpath.indexOf("/") + 1); Then evaluate the XPath with the original Node as its context. I don't know if this may have side-effects, but I think this is the way to go. What do you think? flavio
I tested Flavio's fix and found that it did not work in all cases. Tested and verified Kris Schneider's fix and committed it to the JSTL 1.1.x workspace.