[jdom-interest] Streaming JDOM

Gregor Zeitlinger gregor at zeitlinger.de
Mon Jul 24 11:36:59 PDT 2006

On 7/24/06, Tatu Saloranta <cowtowncoder at yahoo.com> wrote:
> > Regarding the last issue:
> > I am wondering if the JDOM implementors do not want
> > to have a
> > streaming API or if this is just the wrong mailing
> > list to ask this
> > question.
> > Can anybody enlighten me?
> I'm not a JDOM implementor per se, but reasons I can
> think of
> for not getting many responses are:
> (and btw, I think this mailing list is just right for
> the
> questions):
> * JDom is a rather mature tree model, and most users
>   are either content with it, or moved to
> investigating
>   more suitable alternatives
seems reasonable.

> * Being a tree model implementation, focusing on
> streaming
>   may be considered out of scope.
maybe, but using that rationale, we'll never have a streaming API that
is seamless with JDOM.

> * Implementing any truly streaming mode of operation
> that
>   maintains convenience of a tree model is quite
> difficult
>   thing to do.
yes, but I was hoping that my code example would show that it is quite possible.
Did they not convice you? Maybe the examples were not optimal.

> But regarding "streaming in JDOM", the main question
> to me is
> what exactly are you trying to achieve?
> Efficiency/speed of streaming approach, or something
> that is
> "just faster than the eager loading"?
Efficiency of SAX (nothing less) combined with as much JDOM experience
as possible (you cannot read a node twice, but you can use the API
you're familiar with)

> There may be other goals too, but from these two,
> you'll get
> following obvious implementation choices:
> (a) Faking a real tree structure by allowing limited
>   (one-way, forward-and-parents only, or such)
> traversal
>   ability.

> (b) Implementing what amounts to 'lazy instantiation',
> ie.
>   only build parts of the tree that one needs
> Latter allows full convenience, but generally does not
> really
> either speed things up or really reduce memory usage.
> In common
> case, the whole tree still ends up being loaded. At
> least that
> seemed to be the conclusion of Xerces/DOM implementors
> and users.
That was not my intention.

> In former case, usage limitations are such that it's
> debatable
> whether it's much more convenient than using an
> approach that
> makes such limitations
When I compared SAX, StAX to StaxMate/Streaming JDOM I found the
difference really significant.
Especially having worked with SAX, this new approach seems natural,
easy to understand and thus easy to maitain.

Have you ever liked SAX?

Gregor Zeitlinger
gregor at zeitlinger.de

More information about the jdom-interest mailing list