Altova Mailing List Archives


Re: Partial SAX parsing

From: William Park <opengeometry@-----.-->
To: NULL
Date: 8/21/2004 11:56:00 PM
Chris Warr <cwarr@--no-spam--.labyrinth.net.au> wrote:
> Hi, I'm working on an existing app. that parses an xml doc with SAX and does
> some work in start_element and end_element handlers.  My problem is I need
> to speed things up a bit, only 1/4 of the xml document is relevant, I'd
> rather not have SAX go down some paths, ie. In the following:
> 
> <doc>
>     <interesting-stuff>
>         <things>...</things>
>     </interesting-stuff>
>     <boring-stuff>
>         <blah>...</blah>
>     </boring-stuff>
> </doc>
> 
> I want sax to process the elements below interesting-stuff but not below
> boring-stuff.  Is this level of control possible?  Or can you only process
> every element?

In start callback, if element is <boriing-stuff>, then zero all handlers
except for end handler.  In end callback, if element is
</boriing-stuff>, re-register your normal handlers.

Or, use global flag, and test for it in every handler you have.

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.