Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-514

Error by appending a text node to a child

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Incomplete
    • 2.2.0
    • None
    • None
    • Operating System: All
      Platform: All
    • 14480

    Description

      By appending a textnode to a child the text node will not appended. The
      following junit test failes with the newest xerces 2.2.1. When I run this test
      with crimson it works.

      TestCase:
      ---------
      import javax.xml.parsers.DocumentBuilder;
      import javax.xml.parsers.DocumentBuilderFactory;
      import org.w3c.dom.Document;
      import org.w3c.dom.Element;
      import junit.framework.AssertionFailedError;
      import junit.framework.TestCase;
      import junit.framework.TestSuite;

      public class XMLTest extends TestCase
      {
      /**

      • Constructor
      • @param name the name
        */
        public XMLTest( String name ) { super( name ); }

      /**

      • Test append a text node to an element
        */
        public void testAppendTextNode() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element e = doc.createElement( "TEST" ); e.appendChild( doc.createTextNode( "42" ) ); System.err.println("element:"+e); assertNotNull( e ); assertNotNull( e.toString() ); assertEquals( e.toString(), "<TEST>42</TEST>" ); }

      /**

      • Run test cases
      • @param args
        */
        public static void main( String[] args ) { TestSuite suite = new TestSuite( XMLTest.class ); junit.textui.TestRunner.run( suite ); }

        }

      // compile;
      [xercesTest]$ javac -classpath "junit.jar;xercesImpl.jar;xmlParserAPIs.jar"
      XMLTest.java

      // run test:
      [xercesTest]$ java -cp "junit.jar;xercesImpl.jar;xmlParserAPIs.jar;." XMLTest
      .element:[TEST: null]
      F
      Time: 0.911
      There was 1 failure:
      1) testAppendTextNode(XMLTest)junit.framework.ComparisonFailure: expected:<
      [TEST: null]> but was:<<TEST>42</TEST>>
      at XMLTest.testAppendTextNode(XMLTest.java:35)
      at XMLTest.main(XMLTest.java:46)

      FAILURES!!!
      Tests run: 1, Failures: 1, Errors: 0

      [xercesTest]$

      Attachments

        Activity

          People

            Unassigned Unassigned
            mep@gmx.ch Meier Patrick
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: