xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnaud Le Hors <leh...@us.ibm.com>
Subject Re: How to deal with differences in DOM implementations?
Date Fri, 03 Mar 2000 23:48:16 GMT
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.

Mime
View raw message