There is more than one error message generated by the schema validator, however you are only getting the first one because your ErrorHandler terminates processing immediately by throwing an exception.
If you do not throw this exception your ErrorHandler will be called again with another SAXParseException containing an error message like: cvc-type.3.1.3: The value '' of element 'ID' is not valid. Thanks. Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: mrgla...@ca.ibm.com E-mail: mrgla...@apache.org ZagZig <powe...@web.de> wrote on 08/20/2010 04:20:44 AM: > Hello everyone, > > i've a problem with the result of the validation. I validate my xml file > against a xsd and everything is working fine, except that i can't get the > name of the element that was not correctly filled. That means if i've an > empty element "id" in my xml, which is from type integer, the error message > i got is > > cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'. > > which is correct, but i would like to print out the name of the element with > the invalid value. > > All information my errorhandler gives me are > > publicId: null > systemId: null > line number: 33 > column number: 22 > localized message: cvc-datatype-valid.1.2.1: '' is not a valid value for > 'integer'. > message: cvc-datatype-valid.1.2.1: '' is not a valid value for 'integer'. > toString(): org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: '' is > not a valid value for 'integer'. > > <code> > public class MyErrorHandler implements ErrorHandler { > > public void error(SAXParseException arg0) throws SAXException { > System.out.println("publicId: " + arg0.getPublicId()); > System.out.println("systemId: " + arg0.getSystemId()); > System.out.println("line number: " + arg0.getLineNumber()); > System.out.println("column number: " + arg0.getColumnNumber()); > System.out.println("localized message: " + arg0.getLocalizedMessage ()); > System.out.println("message: " + arg0.getMessage()); > System.out.println("toString(): " + arg0.toString()); > System.out.print("Parsing XML failed due to a:\n" + > arg0.getClass().getName()); > throw arg0; > > } > > public void fatalError(SAXParseException arg0) throws SAXException { > System.out.println("publicId: " + arg0.getPublicId()); > System.out.println("systemId: " + arg0.getSystemId()); > System.out.println("line number: " + arg0.getLineNumber()); > System.out.println("column number: " + arg0.getColumnNumber()); > System.out.println("localized message: " + arg0.getLocalizedMessage ()); > System.out.println("message: " + arg0.getMessage()); > throw arg0; > > } > > public void warning(SAXParseException arg0) throws SAXException { > System.out.println("publicId: " + arg0.getPublicId()); > System.out.println("systemId: " + arg0.getSystemId()); > System.out.println("line number: " + arg0.getLineNumber()); > System.out.println("column number: " + arg0.getColumnNumber()); > System.out.println("localized message: " + arg0.getLocalizedMessage ()); > System.out.println("message: " + arg0.getMessage()); > throw arg0; > > } > > } > </code> > > The element definition in the xsd is > > <xs:element name="ID" type="ID" /> > > <xs:simpleType name="ID"> > <xs:restriction base="xs:integer"> > <xs:totalDigits value="7" /> > </xs:restriction> > </xs:simpleType> > > Has somebody an idea how i can solve my problem? > > Thanking you in advance for any help you can give me. > > -- > View this message in context: http://old.nabble.com/missing-element- > name-in-validation-result-tp29489740p29489740.html > Sent from the Xerces - J - Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org > For additional commands, e-mail: j-users-h...@xerces.apache.org