Bug 33032

Summary: string() works incorrectly in conjunction with scoped variables
Product: Taglibs Reporter: Yuriy Yatsyk <yatsyk>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P2    
Version: 1.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Example showing 33032 is a bug

Description Yuriy Yatsyk 2005-01-11 00:10:40 UTC
Below are two snippets of code, first one works (i.e. variable is initialized to
string correctly), second one does not (variable is set to empty string). The
only difference is that in the first one function string() is used on a simple
variable instead of complex expression.

Working snippet:

<x:set var="navigationPath" select="$content/content/pages/page/url[text() =
$contentUrl]/../navigation-path" scope="request"/>
<x:set var="navigationPath" select="string($navigationPath)" scope="request"/>

Non-working snippet:

<x:set var="navigationPath"
select="string($content/content/pages/page/url[text() =
$contentUrl]/../navigation-path)" scope="request"/>
Comment 1 Dhiru Pandey 2005-03-03 22:29:48 UTC
Could the submitter please attach a testcase so that one could reproduce the
problem

Thanks,
-Dhiru
Comment 2 Henri Yandell 2006-12-06 13:41:23 UTC
Created attachment 19219 [details]
Example showing 33032 is a bug

Here's a jsp file that when dropped into the standard-examples/xml/ directory
shows this bug.
Comment 3 Henri Yandell 2006-12-06 15:24:07 UTC
Debugging...

It doesn't seem to be a problem with Xalan itself. An xsl with the following in
works fine:

<xsl:template match="/">
    <xsl:value-of select="string(games/country/athlete/sport[text() =
'wrestling']/../name)"/>
</xsl:template>

However, the call to Xalan via JSTLXPathUtils is returning an XObject that
contains an empty string. There's nothing obviously different between the calls
to the XPath API, just the addition of the test variable to the scope. Seems to
imply to me that the problem is one of the taglib not calling down to Xalan in
quite the right way and will be painful to resolve. 

JSTLXPathUtils is a fork of a Xalan class (XPathUtils), but I can't see anything
obvious in its svn history that would suggest a fix to this.

Given that it can be worked around pretty easily - my suggestion would be to put
it in a FAQ of known bugs.
Comment 4 Henri Yandell 2007-01-29 16:59:53 UTC
Added to the FAQ:

http://wiki.apache.org/jakarta-taglibs/Standard1%2e1%2e3FAQ
Comment 5 Henri Yandell 2009-11-29 19:57:05 UTC
Resolving as wontfix. No obvious path to resolution; this isn't a part of the spec I would rely on.