Details
-
Bug
-
Status: Open
-
Blocker
-
Resolution: Unresolved
-
The Latest Development Code, 2.7.1, 2.7.D2, 2.7.2
-
None
-
Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
-
None
-
PatchAvailable
Description
In a stylesheet I'm calling method append() on a StringBuilder provided as parameter:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java">
<xsl:param name="SB" />
<xsl:template match="/">
<xsl:message><xsl:value-of select="java:append( $SB, 'text' )"/></xsl:message>
</xsl:template>
</xsl:stylesheet>
Problem #1:
In the example above the MethodResolver may not choose the appropriate method. It does work with Java 7 build 1.7.0-b147 (choosing StringBuilder.append(String)), but not with the latest Java 7 Update 17 (choosing StringBuilder.append(CharSequence)) which causes an IllegalArgumentException to be thrown. Method MethodResolver.scoreMatch() returns the same score for both (and other) methods because the value is of class XObject.CLASS_STRING.
Problem #2:
MethodResolver.convert() is not able to handle values of type CharSequence properly and ends up converting the String value into a Double (NaN).
Please find attached a patch (against trunk, SVN revision 1383083) addressing problem #2 and improving MethodResolver.scoreMatch() to provide a better score if a value exactly matches the target type, compared to a value only assignable to the target type.