DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13815>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13815

normalize-space does not properly handle empty text data

           Summary: normalize-space does not properly handle empty text data
           Product: XalanJ2
           Version: CurrentCVS
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xml.utils
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [EMAIL PROTECTED]


Using normalize-space() with empty text data results in a 
java.lang.ArrayIndexOutOfBoundsException.

Example:

test.xml:
<page>
  <data id="1">data1</data>
  <data id="2">data2</data>
  <data id="">data</data>
</page>

test.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/page">
  <xsl:for-each select="data">
    <data>
      <xsl:value-of select="normalize-space(@id)"/>:
      <xsl:value-of select="normalize-space(.)"/>
    </data>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

result:
file:///test.xsl; Line #6; Column #55; XSLT Error 
(javax.xml.transform.TransformerException): 
java.lang.ArrayIndexOutOfBoundsException


I traced down this problem to FastStringBuffer.java, method
sendNormalizedSAXcharacters(). At the beginning there is a test
if first character is whitespace - without check if this character
exists (I must admit that I send the corresponding patch that
leads to this problem a while ago :-( ).

I'll send a patch to resolve this problem.

Reply via email to