[jdom-interest] Partial Tree building/instantiation --- XPathFilter

Joseph Bowbeer jozart at csi.com
Mon Apr 2 17:05:39 PDT 2001


Jakob Jenkov mailto:jakob at jenkov.com wrote:

> I'm currently working on a long, long :-) project in which we parse
> through some quite long files.
>
> [ ... ]
>
> My Suggestion would be to insert an XPathFilter, that only builds
> JDOM trees from the records that match the given XPath. In the
> example above, an XPath of    transferBatch::phoneCall   would
> have done the job.
>

Jakob, There was a lot of enthusiastic discussion about this last November.
Look for the subject "Proposal: JDOM event based processing" in the November
archives (both with and without the "Re:" prefix).

You can install your own XMLFilter in SAXBuilder, and you can even implement
your XMLFilter to handle XPath expressions, but the mismatch is that
SAXBuilder is a Document builder and I think you need some way to create a
stream of Elements.

Here are a couple of paragraphs by James Strachan <james at metastuff.com> that
summarize the November discussion:

    "[...] I'm advocating using a SAX based XMLFilter approach to 'route'
SAX events using XPath expressions to an ElementTreeBuilder which then
passes the constructed object on to an ElementHandler. i.e. up front you
decide what sub trees you are interested in before parsing commences."

    "I think much of what we're talking about here is a filtering / layering
on top of SAX to allow XPath expressions to be routed to a ContentHandler
which may then build a JDOM Element tree which then calls an ElementHandler
when the tree is buit. There should be 2 levels of interaction, the SAX
ContentHandler or the JDOM ElementHandler. In fact the JDOM ElementHandler
functionality will probably be implemented as a SAX ContentHandler anyway.."

--
Joe Bowbeer









More information about the jdom-interest mailing list