Bug 22490

Summary: [Standard] * (wildcards) not allowed in dynamic <x: select predicate
Product: Taglibs Reporter: Rick <rick>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED INVALID    
Severity: major CC: pierre.delisle
Priority: P3    
Version: 1.0.2   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Rick 2003-08-17 17:08:21 UTC
[note: using v1.0.3]
You cannot get a * (and probably other wildcards) out from a dynamically 
populated variable in <x: select statements.

Using a string variable in a select predicate results in a properly escaped
xpath statement.

<c:set var="pred" value="clerk" />
<x:forEach select="$doc//employee[role=$pred]" >

results in a select like "$doc//employee[role='clerk']" which is fine.

BUT there is no way to specify wildcards like *.

<c:set var="pred" value="*" />
<x:forEach select="$doc//employee[role=$pred]" >

Appears to result in a select like "$doc//employee[role='*']" which is not
correct.
Comment 1 Pierre Delisle 2003-08-25 20:21:38 UTC
The behavior you experience appears to be a limitation of XPath rather
than a bug in our implementation of JSTL.

Specifically, it does not appear that XPath will allow the evaluation
of a variable to simply return a representation of the wildcard 
character * (without any surrounding quotes).

If I am not mistaken, you'd run into the same issue with XSLT.
Comment 2 Rick 2003-08-31 18:30:36 UTC
Perhaps I'm a bit dense here, but it seems to be the JSTL preprocessor that is
at fault here.  Surely the select statement:

      $doc//employee[role=$param:pred] 

must be preprocessed prior to sending to the XPath engine.  Isn't the variable
$param:pred completely unknown to the XPath engine?  Obviously, I'm not familiar
with the code, but neither was I aware that XPath would have any idea what to do
with $param:pred.
Comment 3 Shawn Bayern 2003-08-31 21:23:51 UTC
No, the XPath language supports variables; the MEANING of those variables, when 
they're encountered in a JSTL page, is defined by JSTL, but the syntax is 
entirely XPath's.