[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

ErrorHandler in SAX2

  • To: xml-dev@l...
  • Subject: ErrorHandler in SAX2
  • From: "Khurram Chaudhary" <kc5uk@h...>
  • Date: Thu, 05 Jun 2003 10:50:06 +0100
  • Bcc:

msn error code 0
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
<Name>xxxx</Surname>
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.

Thanks

Khurram.

_________________________________________________________________
Express yourself with cool emoticons - download MSN Messenger today! 
http://www.msn.co.uk/messenger


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.