SAXParseException is a subclass of SAXException which is basically a container for the "real" exception. I'm not sure if there's a "real" exception underneath the SAXParseException, but have you tried calling the getException() method on SAXParseException to see if it is wrapping another exception that may contain more information (such as a stack trace or different error message)?
Brion -----Original Message----- From: Nguyen, Linh [mailto:[EMAIL PROTECTED] Sent: Friday, February 21, 2003 12:50 PM To: '[EMAIL PROTECTED]' Subject: RE: <empty></empty> vs <empty /> Sorry I wasn't clear...by "exception", I meant Xerces throws me a SAXParseException through the callback error(). You mentioned > and do what you want with it, including looking at some field > somewhere that contains the name of the last or next element seen. Could you be more specific please (or point me to some doc), I'm not sure how to make good use out of SAXParseException and I don't want to parse its textual message. Thanks. -- Linh -----Original Message----- From: Elliotte Rusty Harold [mailto:[EMAIL PROTECTED] Sent: February 21, 2003 12:35 PM To: [EMAIL PROTECTED] Subject: Re: <empty></empty> vs <empty /> >Hi everyone, > >I need some help on a Xerces SAX issue. > >If a mandatory field (mandatory as defined by the schema) is empty and the >full empty tax syntax is used, Xerces calls startElement before throwing the >exception. But if the short form is used, Xerces never calls >startElement/endElement, so I don't have a chance to find out the name of >the tag in error. Curious. I'm not sure if it's really legal or not for Xerces to treat an empty-element tag as different from a start-tag end-tag pair in this case. They mean the same thing, but is it legal to detect the validity error earlier or later depending on form? I suspect what's going on is that when Xercecs sees the end of the start-tag it doesn't know yet the element is empty so it calls startElement() and then parses and discovers the problem. With an empty-element tag, it notices the emptiness immediately. I don't really know the code base, but I suggest Xercces should be fixed so these two cases are treated the same; that is, call startElement() before reporting the exception in both cases. >Is there any way to obtain the name of the tag in error, if the short form >of empty tag is used? Xerces eventually includes the tag name in its >textual exception message, but who wants to parse it for information. Yes. The exception is not actually thrown by the parser. (At least it shouldn't be. If it is, that's a bug.) It is reported to the registered ErrorHandler through the error() method. You can trap this and do what you want with it, including looking at some field somewhere that contains the name of the last or next element seen. You do not need to stop parsing due to the validity error. In fact, in most circumstances, I recommend that you do not stop parsing. However, it's still tricky to figure out whether you need the next or the last element, but I suspect that it's possible if a little hackish. -- +-----------------------+------------------------+-------------------+ | Elliotte Rusty Harold | [EMAIL PROTECTED] | Writer/Programmer | +-----------------------+------------------------+-------------------+ | Processing XML with Java (Addison-Wesley, 2002) | | http://www.cafeconleche.org/books/xmljava | | http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA | +----------------------------------+---------------------------------+ | Read Cafe au Lait for Java News: http://www.cafeaulait.org/ | | Read Cafe con Leche for XML News: http://www.cafeconleche.org/ | +----------------------------------+---------------------------------+ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
