[jdom-interest] Updated StAXBuilder

Bradley S. Huffman hip at cs.okstate.edu
Tue Nov 16 18:59:01 PST 2004

Tatu Saloranta writes:

> I think SAXBuilder should use it, by default, too: any
> SAX parser that lets through invalid stuff is not
> worth using... so there's little point in defaulting
> to
> stricter checking? And since I would expect that
> majority of usage is using Xerces/Crimson to parse XML
> documents, use where other factories are needed should
> be minority?

I think it currently does. Hmmm, no it doesn't. Something for
the TODO list.

> About the only thing that UncheckedJDOMFactory is
> lacking (compared to fast factory I hacked together)
> is simple local namespace Object caching, I could
> easily add that in.
> The way NS objects are recycled by Namespace object is
> yucky (specifically, use of temp StringBuffers for
> key), and it's easy to improve its performance
> significantly (I profiled doc construction and
> Namespace.getNamespace() was a significant overhead)
> Could be done in Namespace object, too, but locality
> is probably better in individual factory object.

I'd say put any speed up in Namespace first, that way it also benefits
documents constructed using the constructors (instead of a factory).
> > Also you don't need to "simulate recursion" since
> > you have access to the
> > parent hierarchy through getParent() or
> > getParentElement().
> Well, I don't need to simulate recursion at all, since
> parent can also be passed as an argument, but I just
> eliminated recursion for fun. :-D
> [and for hopes of more efficient JIT compilation --
> but granted, speed difference wasn't remarkable]
> That's something I could just replace with simple
> recursion too; not a huge difference either way (wrt.
> either readability or speed).

No, I meant use the tree under construction as the stack. "push" is just

     factory.addContent(currentElement, newElement);
     currentElement = newElement;

and "pop" at the end of a element is just

     currentElement = currentElement.getParnetElement();


More information about the jdom-interest mailing list