Return-Path: Mailing-List: contact general-help@xml.apache.org; run by ezmlm Delivered-To: mailing list general@xml.apache.org Received: (qmail 99916 invoked from network); 4 Mar 2000 01:47:44 -0000 Received: from w110.web2010.com (root@216.157.57.254) by locus.apache.org with SMTP; 4 Mar 2000 01:47:44 -0000 Received: from us.ibm.com (s1.almaden.ibm.com [198.4.83.36]) by w110.web2010.com (8.9.3/8.9.0) with ESMTP id UAA17238 for ; Fri, 3 Mar 2000 20:44:32 -0500 (EST) Message-ID: <38C04F40.AC652A25@us.ibm.com> Date: Fri, 03 Mar 2000 15:48:16 -0800 From: Arnaud Le Hors Organization: IBM X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: general@xml.apache.org Subject: Re: How to deal with differences in DOM implementations? References: <00ca01bf8540$d99fe880$2920a8c0@mongoosetech.clk> <38C040D4.F5F05BA0@apache.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N Pierpaolo Fumagalli wrote: > > > Eric Hodges wrote: > ... > > For instance, in JAXP, here's their example of how to create an > > element and add it to a document: > > > > Document doc = db.newDocument (); > > Element root = doc.createElement ("root"); > > Attr tmp; > > Writer out = new OutputStreamWriter (System.out); > > > > doc.appendChild (root); > > > > In Xerces, this produces an exception. The last line must be changed > > to: > > > > doc.getDocumentElement().appendChild(root); > > This is wrong... And it must be a XERCES bug, even if in all the time I > worked w/ Xerces, I never had to do something like it... What version > are you using? This is not wrong. Again, this is the result of Xerces strictly following the DOM Level 2 spec which says that createDocument() not only create the Document but also the root element. Given that a Document can only have one Element child it is only normal that trying to add any other raises an exception. > > If the same change is applied to JAXP, getDocumentElement() returns a > > null, since the document is empty. > > That should be the right behaviour. According to who? -- Arnaud.