Andy Clark wrote:
> 
> "K. Ari Krupnikov" wrote:
> > What is the recommended way to use Xerces parser to build a DOM tree in
> > a different implementation?
> >
> > I subclassed org.apache.xerces.parsers.DOMParser such that
> > DEFAULT_DOCUMENT_CLASS_NAME is set to my Document implementation, and
> > fDocument is set to an empty Document from my implementation. [1]
> >
> > Is there a better way?
> 
> You don't need to subclass the parser itself; you only need to
> set the appropriate property on the parser to set the new DOM
> implementation by using the fully qualified class name. For
> example:
> 
> 
> domParser.setProperty("http://apache.org/xml/properties/dom/document-class-name";,
>                         "andyc.MyDocumentImpl");
> 

I'm afraid that's not possible. My Document doesn't have a public
no-argument constructor. It can only be instantiated using a factory
method in DOMImplementation, because it cannot exist outside of an
Implementation instance, same as regular Node cannot exist outside of
the context of a Document.

Also, I ran into problems with org.apache.xerces.parsers.DOMParser when
it attempts to cast Attr into AttrImpl regardless of
http://apache.org/xml/properties/dom/document-class-name. I reported
that as a bug: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=832

-- 
K. Ari Krupnikov

DBDOM - bridging XML and relational databases
http://www.iter.co.il

Reply via email to