This seems a wierd way to define and use keys.. I would use keys as follows (I have adapted the example you gave) ..
XML file - <test> <date>2004-01-01</date> <date>2005-01-02</date> <date>2005-01-03</date> <date>2004-01-04</date> </test> XSLT file - <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method = "text" /> <xsl:key name="key_test" match ="date" use = "substring(., 1, 4)" /> <xsl:template match="/test"> <xsl:for-each select="key('key_test', '2004')"> <xsl:value-of select="." /><xsl:text>
</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet> I get correct output - 2004-01-01 2004-01-04 I tested with Xalan-J 2.6.0 bundled with JDK 1.5.0_02 .. But I do feel for the example you gave, that "error message can be improved" .. I do not think it can be called a bug! Regards, Mukul On 4/20/05, arn44 (JIRA) <[email protected]> wrote: > incorrect use of xsl:key cause NullPointerException > ---------------------------------------------------- > > Key: XALANJ-2108 > URL: http://issues.apache.org/jira/browse/XALANJ-2108 > Project: XalanJ2 > Type: Bug > Components: XSLTC > Versions: 2.6 > Environment: windows jdk 1.42.06 > Reporter: arn44 > Priority: Minor > > my stylesheet > ------------- > <?xml version="1.0"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method = "html" encoding="iso-8859-1" /> > > <xsl:variable name = "x" select = "'1'" /> > <xsl:variable name = "y" select = "'4'" /> > <xsl:key name = "key_test" match ="test" use = "substring(date, $x, > $y)" /> > > <xsl:template match="/"> > > </xsl:template> > </xsl:stylesheet> > > xml file > <test><date>2004-01-01</date></test> > > java.lang.NullPointerException > at > java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:980) > at java.lang.Double.valueOf(Double.java:202) > at > org.apache.xalan.xsltc.runtime.BasisLibrary.stringToReal(BasisLibrary.java:838) > at ent_recherche_simple.buildKeys() > at ent_recherche_simple.transform() > at > org.apache.xalan.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:580) > > -- > This message is automatically generated by JIRA. > - > If you think it was sent incorrectly contact one of the administrators: > http://issues.apache.org/jira/secure/Administrators.jspa > - > For more information on JIRA, see: > http://www.atlassian.com/software/jira > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
