You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2002/02/20 18:56:25 UTC

DO NOT REPLY [Bug 6587] New: - Wrong data reported for some text nodes following some CDATA nodes

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=6587>.
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=6587

Wrong data reported for some text nodes following some CDATA nodes

           Summary: Wrong data reported for some text nodes following some
                    CDATA nodes
           Product: Xerces2-J
           Version: 2.0.0
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: Major
          Priority: Other
         Component: DOM
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: andy@wego.com


In some cases the wrong value is reported for a text node when it follows a
CDATA section that does not contain a newline. The significant points seem to be
that the marked section has no newlines and the text node begins with a space.
This is probably related to bug 6250. org/apache/xerces/impl/Version reports
"Xerces-J 2.0.0". 

Here's some output from the attached program that demonstrates the problem:
<a><b><![CDATA[yikes]]></b><c> 
</c></a>
[a: null]
[b: null]
[#cdata-section: yikes]
[c: null]
[#text: yikes 
]

import org.w3c.dom.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import java.io.*;

public class DOMTest
{
  public static void main (String [] argv)
  {
    DOMTest t = new DOMTest ();
    // note how the content of the marked section appears in the text node under
element 'c'
    t.show ("<a><b><![CDATA[yikes]]></b><c> \n</c></a>");
    // these are ok
    t.show ("<a><b><![CDATA[yikes]]></b><c></c></a>"); // no content
    t.show ("<a><b><![CDATA[yikes]]></b><c> </c></a>"); // just a space
    t.show ("<a><b><![CDATA[yikes]]></b><c>\n </c></a>"); // newline, then space
    t.show ("<a><b><![CDATA[yikes]]></b><c>\n\n</c></a>"); // multiple newlines
    t.show ("<a><b><![CDATA[yikes]]></b><c>\t</c></a>"); // other whitespace
    t.show ("<a><b>yikes</b><c> \n</c></a>"); // no marked section
    t.show ("<a><b><![CDATA[yikes\n]]></b><c> \n</c></a>"); // newline in marked
section
    t.show ("<a><b><![CDATA[yi\nkes]]></b><c> \n</c></a>"); // newline in the ms
  }

  void show (String s)
  {
    try {
      System.out.println (s);
      StringReader r = new StringReader (s);
      report (DocumentBuilderFactory.newInstance ().newDocumentBuilder ().parse
(new InputSource (r)).getDocumentElement ());
      System.out.println ();
    } catch (Exception e) { e.printStackTrace (); }
  }

  void report (Node n)
  {
    if (n==null) return;
    System.out.println (n);
    report (n.getChildNodes ());
  }

  void report (NodeList nl)
  {
    if (nl==null) return;
    for (int i=0; i<nl.getLength (); i++)
      report (nl.item (i));
  }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org