[jdom-interest] insertChild in Element

trebor.a.rude at lmco.com trebor.a.rude at lmco.com
Wed Aug 30 12:50:09 PDT 2000

If the JDOM is the first XML API a programmer learns, then you're probably
right. However, for those coming from DOM, the second model is what they're
used to. Personally, I didn't find adapting to the List model that
difficult, but I hadn't used the DOM for very long when I switched to JDOM.
As usual, both sides have their merits. One advantage to having Element
implement List is that it doesn't break existing code, if you're more
comfortable with the first model, you can still use it.

Trebor A. Rude
trebor.a.rude at lmco.com

> -----Original Message-----
> From:	Tom Jenkins [SMTP:tjenkins at devis.com]
> Sent:	Wednesday, August 30, 2000 1:13 PM
> To:	jdom-interest at jdom.org
> Subject:	RE: [jdom-interest] insertChild in Element
> Hello all,
> > -----Original Message-----
> <snip>
> > >All these things are easily done with the List returned by
> getChildren()
> > >using standard Java APIs.  I think it's better to give people access to
> > >the List for them to manipulate as they like than reproduce all the
> List
> > >functionality in Element.
> > >
> >
> > Lately I'm not so sure of that. Certainly, the getting the children
> > and then operating on the list doesn't seem to be obvious. What if
> > Element and Document implemented List instead of containing a List?
> > Would this be more obvious? Would it be more closely reflect people's
> > mental models of XML elements?
> <snip>
> I don't think Element should implement List.  To my mental model, Element
> ->
> List is not an "is-a" relation, but rather a "has-a".
> The line:
> 	element.getChildren().add(newElement, 3);
> makes perfect sense. But the alternative line:
> 	element.add(newElement, 3);
> just doesn't feel right.
> Tom Jenkins
> Systems Analyst
> Development Infostructure
> http://www.devis.com
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourh
> ost.com

More information about the jdom-interest mailing list