Return-Path: Delivered-To: apmail-xml-general-archive@xml.apache.org Received: (qmail 49005 invoked by uid 500); 13 Mar 2001 02:01:34 -0000 Mailing-List: contact general-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: general@xml.apache.org Delivered-To: mailing list general@xml.apache.org Received: (qmail 48969 invoked from network); 13 Mar 2001 02:01:31 -0000 From: Scott_Boag@lotus.com Subject: Re: Potential Xerces regression (bug# 933) To: general@xml.apache.org Cc: xerces-j-dev@xml.apache.org X-Mailer: Lotus Notes Release 5.0.1 July 16, 1999 Message-ID: Date: Mon, 12 Mar 2001 21:04:35 -0500 X-MIMETrack: Serialize by Router on CAMMAIL04/CAM/M/Lotus(Release 5.0.6a |January 17, 2001) at 03/12/2001 08:56:51 PM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N > JAXP 1.1, which is based on DOM Level 2, exposes a new method to create > a DOM Document object to conform to DOM Level 2. This is the preferred > method to create a DOM Level 2 tree: > > DocumentBuilderFactory dbf = new DocumentBuilderFactory(); > dbf.setNamespaceAware(true); // needed b/c default value is false > DocumentBuilder db = dbf.newDocumentBuilder(); > DOMImplementation di = db.getDOMImplementation(); // W3C DOM Impl > DocumentType dt = di.createDocumentType("pref:root", pubID, sysId); > Document doc = createDocument("http://someuri", "pref:root", dt); Edwin, this will not work for XSLT processing with JAXP 1.1. People want to create a Document node and have it populated by the XSLT processor. In order to support this we will have to change javax.xml.transform.dom.DOMResult to hold a DOMImplementation that can be passed in, so that Xalan can create the document node when an element node is created (besides the change in JAXP, this is a fair amount of work in Xalan, because this non-node will have to be passed through the entire processing flow). God, I wish this had been caught 3 months ago. Perhaps we can make that change for JAXP 1.2 or 1.1.1. But, in any case, the Javadoc does not seem to deprecate DocumentBuilderImpl#newDocument() that I can see, so there's nothing to say it's "not preferred". This is a flat-out mismatch with DOM2. I think that the near term solution to this is that it be documented that DocumentBuilder#newDocument() can throw a not supported exception for some DOM implementations, and precisely document that the Document returned is in a temporarily invalid state that does not match any state recognized by the DOM. -scott Edwin Goei cc: "xerces-j-dev@xml.apache.org" , "general@xml.apache.org" , (bcc: Scott 03/12/2001 Boag/CAM/Lotus) 06:08 PM Subject: Re: Potential Xerces regression (bug# 933) Please respond to general Scott_Boag@lotus.com wrote: > > ======== > The other problem is "DOM006 Hierarchy request error" when outputting to a > DOM. For some very strange reason someone decided that > DocumentBuilder#newDocument() should add an element named "root" to the > Document it creates. Then, when Xalan goes to add the first element out of > the transform to the Document element, you predictable get "DOM006 > Hierarchy request error". In a unit test I do: > > DocumentBuilder docBuilder = dfactory.newDocumentBuilder(); > Node xmlDoc = docBuilder.parse(new InputSource("foo.xml")); > org.w3c.dom.Document outNode = docBuilder.newDocument(); > transformer.transform(new DOMSource(xmlDoc, "foo.xml"), > new DOMResult(outNode)); > > In Xerces 1.2.3 and Xerces 1.3.0, DocumentBuilderImpl#newDocument() > [version 1.2] was (properly, I think) implemented as: > > public Document newDocument() { > return(new org.apache.xerces.dom.DocumentImpl()); > } > > In DocumentBuilderImpl#newDocument() [version 1.3] and on this is > implemented as: > > DocumentBuilderImpl#newDocument() is implemented as: > public Document newDocument() { > DOMImplementation di = getDOMImplementation(); > // XXX What should the root element be named??? > String qName = "root"; > DocumentType docType = di.createDocumentType(qName, null, null); > return di.createDocument(null, qName, docType); > } I'll take responsibility for this bug. The real problem, though, is that DocumentBuilder.newDocument() was part of JAXP 1.0 which was based on DOM Level 1 and so it had to be carried over to JAXP 1.1. I was in a hurry when implementing this method which should be deprecated since DOM Level 2 came out. Still, it should work for backwards compatibility, so I'll check in a fix. JAXP 1.1, which is based on DOM Level 2, exposes a new method to create a DOM Document object to conform to DOM Level 2. This is the preferred method to create a DOM Level 2 tree: DocumentBuilderFactory dbf = new DocumentBuilderFactory(); dbf.setNamespaceAware(true); // needed b/c default value is false DocumentBuilder db = dbf.newDocumentBuilder(); DOMImplementation di = db.getDOMImplementation(); // W3C DOM Impl DocumentType dt = di.createDocumentType("pref:root", pubID, sysId); Document doc = createDocument("http://someuri", "pref:root", dt); Substitute appropriate values of the root node qname "pref:root" and uri. -Edwin --------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: general-unsubscribe@xml.apache.org For additional commands, e-mail: general-help@xml.apache.org --------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: general-unsubscribe@xml.apache.org For additional commands, e-mail: general-help@xml.apache.org