Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Streaming Path Filters

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Michael Kay" <mike AT saxonica.com>
  • To: "'John Patterson'" <jdp2000 AT gmail.com>, <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Streaming Path Filters
  • Date: Thu, 15 Jun 2006 15:22:15 +0100

Saxon has a streaming push-based XPath implementation which implements the
subset of XPath defined in XML Schema, and does much what you want (assuming
this subset is suitable). It runs on any data source supported by Saxon,
which of course includes XOM. However the bad news is that (a) it's not part
of the open source product, and (b) it's sufficiently complicated to make
your head hurt on occasions.

The concept is simple enough:

(1) create a SelectionParser to parse the expression
(2) the result of parsing is a PathSelection
(3) create a WatchManager to handle filtering and notification of events
(4) create a Watch to process your particular PathSelection
(5) write a Receiver (this can be a wrapper around a SAXContentHandler) to
process events once
the Watch is activated
(6) register the Watch with the WatchManager
(7) pipe the SAX events (translated into Saxon Receiver events) into the
WatchManager
(8) events relating to the subtree matched by the path expression are then
notified to your Receiver

But the detail is quite complicated, for example you need to allow for the
fact that a path expression like //SECTION can be active more than once if
there are nested sections.

Most of these classes are in packages com.saxonica.* - see
http://www.saxonica.com/documentation/javadoc/index.html

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: xom-interest-bounces AT lists.ibiblio.org
> [mailto:xom-interest-bounces AT lists.ibiblio.org] On Behalf Of
> John Patterson
> Sent: 15 June 2006 14:51
> To: xom-interest AT lists.ibiblio.org
> Subject: [XOM-interest] Streaming Path Filters
>
> Hi,
>
> I would like to process a document using SAX and when certain
> paths (an XPath subset) are encountered have a custom hander
> called so that I can do something with the data. Is this
> possible or easy with XOM?
>
> Thanks,
>
> John.
> _______________________________________________
> XOM-interest mailing list
> XOM-interest AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/xom-interest





Archive powered by MHonArc 2.6.24.

Top of Page