Bug 49578 - XPath handling only supports single reference to variable
Summary: XPath handling only supports single reference to variable
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.2.0
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2010-07-09 15:11 UTC by Jeremy Boynes
Modified: 2010-12-31 18:19 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Boynes 2010-07-09 15:11:47 UTC
The XPath union expression "$src/root/x | $src/root/y" is not handled correctly as only the first set of nodes is returned. For example, the JSP
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<x:parse var="src">
<x:forEach select="$src/root/x | $src/root/y">
    <x:out select="."/>

only displays the "x" elements. Swapping the arms of the union operator returns the "y" elements.
Comment 1 Jeremy Boynes 2010-07-09 15:20:59 UTC
This appears to be because of the transformation of the expression performed in XPathUtil#adaptParamsForXalan which takes a variable reference at the start of the expression and maps to a context node. The documentation implies this is because:
     * Given all of this, if no context node is set for the evaluation
     * of the XPath expression, one must be set so Xalan 
     * can successfully evaluate a JSTL XPath expression.
     * (it will not work if the context node is given as a varialbe
     * at the beginning of the expression)
However, Xalan is able to handle variable references like this through its VariableStack API (or as a XPathVariableResolver when called via the JAXP API).
Comment 2 Jeremy Boynes 2010-12-31 18:19:44 UTC
Fixed with refactoring of XPath support in r1054175