Re: creating XML document from scratch

Heather Lindsay wrote:
> 
> hi,
>         I want to create a DOM document without originally having an XML
> document.  So, instead of parsing an XML document and getting the DOM
> document, I want to just create an empty DOM document and then fill in
> whatever elements, etc. that I need.  After extensive searching through Java
> docs (Xerces implementation), it seems that creating a document from scratch
> is not possible using the DOM.  Is this true or am I misunderstanding the
> documentation?  I'm sorry if this question has already been answered in FAQ
> or the archives but I could not find anything in either source and I just
> joined this list.  Any help or clarification would be greatly appreciated.

I'm not an expert in Xerces but you should be allowed to get a DOMImplementation
object (see org.apache.xerces.dom.DOMImplementationImpl.getDOMImplementation())
Using this object, you can use the createDocument method to create a DOM
Document:
http://www.w3.org/TR/DOM-Level-2/core.html#Level-2-Core-DOM-createDocument

Note:
- Since DOM Level 2 is not a recommendation yet, the implementation
of DOM Level 2 in Xerces is still in beta stage.
- DOMImplementationImpl is not an official DOM method. The bootstrapping problem
in Java will be resolved in DOM Level 3.

Philippe

Received on Tuesday, 30 May 2000 15:12:40 UTC