Is there a way to get the element name from the SAXParseException message while validation an XML file?

319 views Asked by At

The SAXParseException message is:

org.xml.sax.SAXParseException; systemId: file:///home/IdeaProjects/RGAME/FullPHSHuman.xml; lineNumber: 8; columnNumber: 11; cvc-complex-type.2.4.a: Invalid content was found starting with element 'PHSHumanSubjectsAndClinicalTrialsInfo:HumanSubjectsIndicator1'. One of '{"http://apply.grants.gov/forms/PHSHumanSubjectsAndClinicalTrialsInfo-V1.0":HumanSubjectsIndicator}' is expected.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)

A method to: 'PHSHumanSubjectsAndClinicalTrialsInfo-V1.0:HumanSubjectsIndicator' <- getElementNameFromExceptionMessage()

Other than pattern matching, is there a way to get the missing element name from the exception message? The message might be getting formed internally somewhere. Thus the question.

0

There are 0 answers