[jdom-interest] DOMBuilder with customized adapter

Christian Holmqvist acroo at iname.com
Fri Feb 16 09:37:18 PST 2001


> > So I have created my own Adapter class extending the
> > org.jdom.adopters.AbstractAdapter this to be able to adapte my parser to
> > suit my need.
> > But now to the problem, the org.jdom.input.DOMBuilder rellay
> completely on
> > reflection of the adapter class, I want to be able to customize it for
> > different reasons. This would normally not be a problem if the
> > org.jdom.input.DOMBuilder.buildTree() method would not have
> been private!!!
> > I really don't want to implement my own DOMBuilder (i.e.
> basically cut and
> > past the buildTree method from DOMBuilder...).
> > Is there a way to maybe not relay so much on reflection since
> most of the
> > values are hardcoded into the class anyway.
>
> Why aren't you using SAXBuilder?

Because with the frequent changes to specific element and the lack of
support of XPath to retrive element DOM just workes bether.
(And old habbit I imagin, I have almost never used SAX... I feel that DOM
gives me more control over the XML...)...

Is there an easy way to perform validation of single elements with SAX ? I
would like it to work the way that when I create a Element from a Document
it already then tells me if the element is valid to create. So that the
"main" XML document is always intact. The way I do it now is to read the XML
file (parse and validate it), clone it, pipe the doc throght the builder
again to revalidate it, and then (if it works) replace the original version
with the clone.

Preferbly it would work that invalid changes could not be done and thereby
rejected with a exception.

> BTW, we use reflection so we can compile JDOM without having to have
> *every supported parser* available in the classpath at compile time.

That could easily be solved with the setup of ant.

/Christian




More information about the jdom-interest mailing list