Andy Clark wrote:
> 
> "K. Ari Krupnikov" wrote:
> > > 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:
> > > [...]
> >
> > 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
> 
> Why is it not possible? Is this your own document impl or
> something else?

It's my (and a few other people's) own.
http://sourceforge.net/projects/dbdom

> If it's you own, why can't you create a
> document without creating it from the DOMImplementation
> factory?

Because my Java DOM is a facade to a database. A Document cannot be
created, much less populated, outside a database. So at the very least,
a Document constructor needs an open JDBC connection. It doesn't have to
be produced by a factory, but it can't have a no-args constructor,
either.

> I think that this feature was added before DOM L2 Rec so
> we don't have a way of setting the document factory and
> using that for constructing a DOM tree. Also, say we *did*
> have a way to set this, then what would we pass in as the
> doctype parameter? Null? If so, how do we set the document
> type later when we see one in the document? If not, then
> what if the document doesn't contain a DOCTYPE line? Some
> users would argue that a DOM tree should not have a
> DocumentType node if there is no DOCTYPE line in the
> document instance. And I think that I agree.

I'm not sure I follow you here. The Rec [1] specifies createDocumentType
in addition to createDocument. If "<!DOCTYPE..." is found before the
first element, use its information to create a DocumentType; if not, use
null in createDocument. Is the problem holding comments and PIs that
might come before the doctype?

In any case, regardless of the DocType, init() can be overloaded to
produce something like init(Document) where Document is expected to be
empty.

As I mentioned, what we did was subclass DOMParser with a public
constructor that takes an empty Document, which is essentially the same,
except the parser is non-reusable.


[1] http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490

-- 
K. Ari Krupnikov

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

Reply via email to