You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by ph...@thomsonreuters.com on 2014/01/30 19:58:31 UTC

Date:Date throws IndexOutOfBounds Exception on empty input

j-users,

When running the following XSL file Xalan-J 2.7.1 throws java.lang.StringIndexOutOfBoundsException: String index out of range: 0 - String index out of range: 0
As long as the root node does not have an attribute named "anAttribute".


Expected output is an single root node
https://xalan.apache.org/xalan-j/apidocs/org/apache/xalan/lib/ExsltDatetime.html#date(java.lang.String) indicates that it should produce an empty string instead of throwing
"If the argument is not in either of these formats, date:date returns an empty string ('')"
Saxon produces the expected. output

If the null check where moved to the start of the date function it world work as specified.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org"
    xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="date exsl"
    version="1.0">
    <xsl:template match="/">
        <xsl:element name="root">
            <xsl:value-of select="date:date(@anAttribute)"/>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

Is this a bug? Should I write it up?
Thanks,
Philip Miess