I am trying to use the ValidationEventCollector to retrieve the
errors/warning encountered during unmarshalling. I am able to get
error/warning messages, but not the element name which has the error.
My code has the following
_unMarshaller.setEventHandler(_validationEventCollector);
//Set the validation to true
_unMarshaller.setValidating(true);
After unmarshalling, when I loop through the ValidationEventCollector to
obtain the message and the element as follows...
//Loop through all the errors and get the messages
for (int loop = 0; loop < validationEventsArray.length; loop++) {
ValidationEvent validationEvent = validationEventsArray[loop];
ValidationEventLocator validationEventLocator
= validationEvent.getLocator();
Node node = validationEventLocator.getNode();
java.net.URL url = validationEventLocator.getURL();
int columnNumber = validationEventLocator.getColumnNumber();
int lineNumber = validationEventLocator.getLineNumber();
String message = validationEvent.getMessage();
}
I am able to get the message from validationEvent... But I don't get the
element name that caused has the error from ValdationEventLocator...
Since I was unmarshalling I tried using getNode, getURL... both return null.
LineNumber and columnNumber are set though.
for example If I have the following data
<lossAmount>
A200
</lossAmount>
I get the message ""A200" does not satisfy the "decimal" type". I am trying
to identify to get "lossAmount"
Am I doing something wrong here ? How can I get the element name ?
Thanks