Re: Handling Error Conditions in Callbacks
"Nick MacDonald" <[email protected]> Fri, 8 Feb 2008 13:43:07 -0500
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <[email protected]> |
Jim: User Data is just for code written by you, the user. It is not examined in any way by the eXpat parsing routines. If you find an error in your code that is being called to interpret the data (you don't like the input, but it is still valid, well formed XML) then you will need to set your own error handling variables and your own routines will need to ignore the input. For example, say you are in the middle of reading tag <X> and a sub tag is wrong, and you want to ignore tag <X> and all the sub tags, you need to code logic to tell all the call back routines to ignore input until you see the proper </X> close tag. If the XML is not valid, eXpat will inform your code via call backs and error returns. You don't have to do anything special here, other than clean up your data at the end (if you don't intend to act on partial/invalid data.) If you want to abort processing in the middle because you don't like the input so far, then there is an eXpat function you can call from a call back that will achieve this for you. Good luck, Nick On Feb 8, 2008 11:17 AM, Themis, Jim <[email protected]> wrote: > I am working on my first XML project, therefore my first experience with > expat. I had a question how other are dealing with error conditions > within their callback handlers. Since the callbacks provide no return > value, I assume, one could use the UserData to store the error condition > and pop that up the callback stack. Just wanted to make sure I wasn't > missing any functionality within expat.