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/11 15:05:42 UTC

DO NOT REPLY [Bug 6365] New: - DOM Parsers seems to create 'wrong' tree

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

DOM Parsers seems to create 'wrong' tree

           Summary: DOM Parsers seems to create 'wrong' tree
           Product: Xerces2-J
           Version: 2.0.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: DOM
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: Peter.Coppens@datadirect-technologies.com


Using the following input document for the DOM parser

<?xml version="1.0" encoding="UTF-8"?>
<jxtr-result>
  <![CDATA[33013.12345]]>
  <![CDATA[VarChar 13]]>
  <el-c_char>Char 13   </el-c_char>
  <el-c_time>
    <![CDATA[15:41:13]]>
    15:41:13
  </el-c_time>
</jxtr-result>

And then serializing the DOM tree, results in 

<jxtr-result>
   <![CDATA[33013.12345]]>
   <![CDATA[VarChar 13]]>
   <el-c_char>Char 13   </el-c_char>
   <el-c_time>
     <![CDATA[15:41:13]]>33013.12345VarChar 1315:41:13     15:41:13   
   </el-c_time> 
</jxtr-result>


The application used to reproduce this was:

import  org.w3c.dom.*;
import  org.apache.xerces.dom.DocumentImpl;
import  org.apache.xerces.dom.DOMImplementationImpl;
import  org.w3c.dom.Document;
import  org.apache.xml.serialize.OutputFormat;
import  org.apache.xml.serialize.Serializer;
import  org.apache.xml.serialize.SerializerFactory;
import  org.apache.xml.serialize.XMLSerializer;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.InputSource;

import  java.io.*;
  
public class tx2
  {
  static void main ( String [] args )
    {
    try
      {
      InputSource is = new InputSource ( new FileReader ( "i.xml" ) );
      is.setSystemId ( "" );
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
      dbf.setValidating ( false );
      dbf.setNamespaceAware ( true );
      DocumentBuilder db = dbf.newDocumentBuilder ();
      // Parse the XML from the provided reader
      Document doc = db.parse ( is );
      // Print
      OutputFormat format  = new OutputFormat( doc );
      XMLSerializer serial = new XMLSerializer( new FileWriter ("o.xml"), 
format );
      serial.asDOMSerializer();                            // As a DOM 
Serializer
      serial.serialize( doc.getDocumentElement() );
      }
    catch ( Exception e )
      {
      e.printStackTrace();
      }
    }
  }

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