有没有办法在验证XML文件时从SAXParseException消息中获取元素名称?

时间:2017-12-04 12:52:28

标签: xml dom sax javax.xml

SAXParseException消息是:

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)

一种方法: 'PHSHumanSubjectsAndClinicalTrialsInfo-V1.0:HumanSubjectsIndicator'< - getElementNameFromExceptionMessage()

除了模式匹配之外,有没有办法从异常消息中获取缺少的元素名称?消息可能会在某处内部形成。因此问题。

0 个答案:

没有答案