xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <philip.mi...@thomsonreuters.com>
Subject Date:Date throws IndexOutOfBounds Exception on empty input
Date Thu, 30 Jan 2014 18:58:31 GMT
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




Mime
View raw message