SAX Filters to the rescue
Changing the flow
SAX parsers report content to applications as a series of events corresponding to document content. SAX filters take that information, do something to it, and pass it on to another process.
Plug underneath most any kind of processing
Many DOM trees are built from SAX, many XSLT processors accept SAX events, and many applications use SAX parsers. Adding a filter to these cases is generally not very difficut - often one or two lines of code.
Limitations are their own inspiration
SAX makes you work very lean. You have to maintain your own context information, parsers can send information in legal but unexpected ways, and you only see a tiny window on to a document at any given time. This pretty much forces developers to work very lean.
Recursion possible, though hidden from other SAX layers
Performing recursive processing on the results of a SAX filter can be done by stacking filters for limited recursion, or by keeping information inside the filter until the necessary content has been gathered. Then the results are reported as a series of events.
Previous Page <
> Next Page