Philip Miess created XALANJ-2584:
------------------------------------

             Summary: EXSLT function Date:Date throws IndexOutOfBounds 
Exception on empty input
                 Key: XALANJ-2584
                 URL: https://issues.apache.org/jira/browse/XALANJ-2584
             Project: XalanJ2
          Issue Type: Bug
      Security Level: No security risk; visible to anyone (Ordinary problems in 
Xalan projects.  Anybody can view the issue.)
          Components: Xalan
    Affects Versions: 2.7.2
            Reporter: Philip Miess
            Assignee: Steven J. Hathaway
            Priority: Minor


When running the following XSL file Xalan-J throws 
bq. 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

[ExsltDatetime.html|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

bq. 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.

h4. The files used to reproduce this problem

h5. The transform file

{code:xml|title=Transform.xsl}
<?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(root/@anAttribute)"/>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>
{code}

h5. An input file that works

{code:xml|title=InputSuccess.xml}
<?xml version="1.0" encoding="UTF-8"?>
<root anAttribute="present"/>
{code}

h5. An input file that causes an StringIndexOutOfBoundsException

{code:xml|title=InputFailure.xml}
<?xml version="1.0" encoding="UTF-8"?>
<root />
{code}




--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to