[jdom-interest] getElementById()

Attila Szegedi szegedia at freemail.hu
Thu Nov 14 06:27:15 PST 2002

> One way of doing this is make an IdDocument class, with methods for
> manipulating elements and attributes that do this checking. If elements
> attributes are manipulated directly, this checking is not performed.

Therefore it can be circumvented causing potentially hard to track bugs... I
pretty much feel that an ability to have *fast* lookup by ID (*slow* one is
trivial to implement - just brute-force walk the tree :-) ) should be
supported by core JDOM classes so that (if it is turned on), it works
consistently no matter how you manipulate the tree.

> This
> also means that we don't need special sub-classes for Element and
> I have implemented the multi-subclass variant, with sub-classes for
> Document, Element, Attribute and JDOMFactory (and even DocumentNavigator
> Jaxen), based on Laurent Bihanic's earlier work. It works and I've never
> been bothered by the slow-down, but I've never needed the speed either.

It'd be great to integrate your/Laurent's work into JDOM core, with the
optional on/off switch for people concerned with performance during tree
transformations. As you have sent it over to me in private this morning, I'm
currently studying it. Having it in JDOM core could allow for some
additional performance optimizations (i.e. AttributeList could be modified
so that it ensures that if there is an ID attribute, it is always the first
attribute in the list, therefore it would be enough to check the first
attribute in the element's list to determine if it has an ID and if it does
what is its value). (AFAIK, the ordering of attributes is actually


> Hallvard
> _______________________________________________
> To control your jdom-interest membership:

More information about the jdom-interest mailing list