From: "Spam Cut" <[EMAIL PROTECTED]>
> Is there any way to use XPATH in a sax-like manner as
> opposed to executing XPATH statements on already
> parsed Document objects?
>
> Perhaps in a manner similar to Apache Digester, where
> the "pattern" would be an XPATH statement, which
> whenever matched, would execute an associated set of
> logic?

Its a bit hard to do in the general case, but certainly a subset of XPath
could be implemented such that a SAX parser could then extract the required
path(s). This came up on the Jaxen list recently

http://www.mail-archive.com/jaxen-interest%40lists.sourceforge.net/msg00790.
html

the most interesting part of the discussion was Christian introducing us all
to STX

http://stx.gingerall.cz/stx/index.html

which is kinda like XSLT for SAX which includes its own kind of XPath
language that can operate directly on SAX. Interesting stuff.

Incidentally, creating an Element with some attributes is usually pretty
cheap, and I guess implementations of things like STX or a SAX XPath engine
would have to do that anyways. So the SAX versus DOM issue on XPath /
parsing seems to be just a question of how long the Nodes stay around for.
So for example if you removed each Element after it were fully created,
you'd have SAX like processing using a DOM like API.

So maybe you could solve your problem using regular XPath on the dom4j API,
but just use the pruning-while-parsing capability to ensure that only a
small subset of the tree is in RAM at any time? e.g. using the
ElementHandler callbacks during parsing to call element.detach() when you're
done with an element. Then you can still use XPath to navigate around the
fragment of document in RAM, while parsing is still occurring.

James




_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



-------------------------------------------------------
This sf.net email is sponsored by: Jabber Inc.
Don't miss the IM event of the season | Special offer for OSDN members! 
JabConf 2002, Aug. 20-22, Keystone, CO http://www.jabberconf.com/osdn
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to