OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   ErrorHandler in SAX2

[ Lists Home | Date Index | Thread Index ]

Hello Guys,

This is my first post to this mailing list and I am new to XML development, 
so excuse my knowledge of XML.

I am trying to parse a XML string, get all the values out of the XML and 
bind it to an object.  I have managed to parse the string using SAX2 that 
was all right.  What I am doing is, I am creating a Hashtable of tag and its 
value, by passing the localName parameter from startElement as a key and a 
string from characters methods as a value to this hashtable, then I pass 
this hashtable to the object which I want to populate, so all this is 
working fine.

In error handling, I am validating the received XML string with a XSD, if 
there is an error I need to append the namespace with an error code, e.g.

<Name Error="1">xxxxx</Name>

I have set Warning code to 1, Error code to 2, and fatal-error to 3.  I 
don't want to stop parsing until the whole document is gone through, i.e. I 
want to continue parsing  even the fatal-errors occured.  What I do for 
error handling is during the parsing phase I construct a stringBuffer even 
there is no errors by putting Error code="0" for example

<Name Error="0">xxxxx</Name>
This means that there is no error, but when an error occurs I set a boolean 
as a true in the warning, error or fatal-error method and get the error code 
from one of these methods and then append the stringbuffer with this error 
code and set the error code back to "0".

The problem I am having is, if I received XML like this
Its an error and a fatal-error as well, so I want parser to raise this as 
one error either in error method or fatal-error, because if there are two 
errors raised by ErrorHandler methods, then the first element(which created 
an error) will get the first error code raised, but the next element which 
does not have any error will get the error code raised by the second method 
of ErrorHandler for the first element.

Second problem, I am having is to build my error XML StringBuffer, I pass 
the localName from startElement method to my constructXML method where I am 
building the strigBuffer, but if I received an XML like 
this<Name>xxxx<</Surname>  where the tags are not matching I need to build 
the same tags with error code in, e.g. <Name Error="3">xxxx</Surname>.  But 
I cant find a way to get the "Surname" value from any method.

Any help on these things will be appreciated, particularly second issue.



Express yourself with cool emoticons - download MSN Messenger today! 


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS