[jdom-interest] How to ease traversal of JDOM tree

philip.nelson at omniresources.com philip.nelson at omniresources.com
Tue Nov 20 05:36:17 PST 2001


> >   2. use decorators to provide interface functionality. This is 
> > covered in
> > Java and XML, also the reasons why interfaces aren't used. 
> Having seen how 
> > elegant and customisable the decorators are, I no longer 
> see the need for 
> > interface approach.
> > 
> 
> I'm not asking to define every node-type class (Document, 
> Element...) as an 
> interface first and then provide a default implementation. I 
> evaluated DOM4J 
> and decided to continue with JDOM because it is simpler and 
> the JDOMFactory 
> provides everything I want when I need to use custom nodes.
> 

What you are suggesting is to, for the most part, take exisiting methods and
put them into an interface which would be a node.  We looked at that and the
idea is the closest we came to agreeing on what could be in a jdom node.
However, it was never enough for anybodies specific application so to
actually use the node, you will probably have to extend the interface, and
then subclass anyway.  In addition, really nobody likes the idea of a
comment or PI having setContent or other methods that made no sense.  

> Now this is not a reason for not improving things when you 
> think there room 
> for such improvements. JDOM is easy and simple to use most of 
> the time but one 
> area were simplicity disappears is when you want to walk the 
> document tree.

I think in reality you almost always have to cast anyway to anything with
the nodes you walk.  For a specific application, you could find ways for
that statement to false, but I am convinced this is not true for the general
case.  I think I could find a quote from Bob McWhirter where he said in his
Xpath work, the node wouldn't have helped that much.  That was pre JAXEN
though.  The Decorator approach is a good meeting ground between your
applications needs and the needs of XML.  Perhaps we should make the
examples more visible.

> 
> Sure I could use the JDOMFactory to implement my own 
> "walkable" version of 
> JDOM node classes (and maybe I'll do) but I think the 
> proposed feature is 
> general enough to be worth being included in the JDOM core.
> 
> Laurent
> 
> _______________________________________________
> To control your jdom-interest membership: 
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com



More information about the jdom-interest mailing list