SAX XPath callbacks (was Re: [XML-SIG] Proposal: Marrying SAX2 and DOM)

Ken MacLeod
14 Mar 2000 11:37:04 -0600

[I'm replying seperately to "marrying SAX2 and DOM" and "full XPath
callbacks".  This message is about "full XPath callbacks".]

Paul Prescod <> writes:

> Here are the basic ideas:

>  * callbacks are labelled with *full XPaths* (a la XSLT)
> 	 * abuses "docstrings" (a la "spark")
> def start_spam( self, textNode ):
>     "figure/title/text()"
>     print "Figure title:"+`textNode`
>     print "tagname:"+textNode.parentNode.tagName
>  * you can ask for an event to be handed to you as a tree
> def start_applets(self,elementNode):
>     "object/applet as tree"
>     for node in elementNode.childNodes:
>         print node
>  * if you do, then child nodes are available
>  * the tree disappears after the end event

XPath callbacks are awesome!

Does this need to be in the stream head (parser or generator) and be
part of the SAX binding or is it better implemented as a base class
for handlers and filters?  I would think the latter.

If it's implemented in parsers and generators, then it's going to be
the same code for all event generators, including parsers and filters.
This seems odd because they, themselves don't generally "use" this
feature, their downstream event receivers do.

Implemented as a base class then only those filters and handlers that
use these callbacks need to be derived from the XPath base module.

Does that make sense?

  -- Ken

P.S. Probably too much detail for one message, but it might also be
beneficial to seperate XPath callbacks and partial-DOM tree support
into seperate base classes as well.