You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2005/01/27 16:17:41 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm SAX2DTM.java

zongaro     2005/01/27 07:17:41

  Modified:    java/src/org/apache/xml/dtm/ref/sax2dtm SAX2DTM.java
  Log:
  Fix for Jira bug report XALANJ-1888.
  
  It is possible for the characters SAX event to specify a length of zero.  Text
  nodes should not be created in such situations.  Changed the charactersFlush
  method to guard against this case.
  
  Reviewed by Morris Kwan (mkwan () ca ! ibm ! com)
  
  Revision  Changes    Path
  1.39      +14 -11    xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
  
  Index: SAX2DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- SAX2DTM.java	24 Jan 2005 00:34:36 -0000	1.38
  +++ SAX2DTM.java	27 Jan 2005 15:17:41 -0000	1.39
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 The Apache Software Foundation.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -1521,18 +1521,21 @@
           doStrip = m_chars.isWhitespace(m_textPendingStart, length);
         }
   
  -      if (doStrip)
  +      if (doStrip) {
           m_chars.setLength(m_textPendingStart);  // Discard accumulated text
  -      else
  -      {
  -        int exName = m_expandedNameTable.getExpandedTypeID(DTM.TEXT_NODE);
  -        int dataIndex = m_data.size();
  +      } else {
  +        // Guard against characters/ignorableWhitespace events that
  +        // contained no characters.  They should not result in a node.
  +        if (length > 0) {
  +          int exName = m_expandedNameTable.getExpandedTypeID(DTM.TEXT_NODE);
  +          int dataIndex = m_data.size();
   
  -        m_previous = addNode(m_coalescedTextType, exName,
  -                             m_parents.peek(), m_previous, dataIndex, false);
  +          m_previous = addNode(m_coalescedTextType, exName,
  +                               m_parents.peek(), m_previous, dataIndex, false);
   
  -        m_data.addElement(m_textPendingStart);
  -        m_data.addElement(length);
  +          m_data.addElement(m_textPendingStart);
  +          m_data.addElement(length);
  +        }
         }
   
         // Reset for next text block
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org