Hi,
I am working on a project with a large XML messaging component for which
we would like to use JAXB.
One of our requirements is to report back validation errors,
encapsulated in an XML message, back to the requesting client. The
problem is that the format of these messages is very specific - in the
case of validation errors on elements enclosing text, we are required to
classify the validation error according to type (too long, out of range,
not an allowed value, non-numeric type etc.) and report it back
associated with the offending element name.
The JAXB ValidationEvent API does not seem to give us access to this
information - firstly it reports the offending object rather than the
element name (and depending on the schema, it may not be simple to
derive the element name from the object class) and while the validation
event message actually gives more detailed information than we need, its
free text form makes it difficult for us to classify the validation
events according to the pre-defined categories our messaging interface
requires.
Any suggestions on how I can do this?
In order to classify the validation events, is there some way I can
customise the validation event messages? At the moment, my only option
is to parse the exception message looking for the restriction type
(minValue etc.)
If I validate while unmarshalling I should be able to get the element
name corresponding to a validation event from the SAX Locator - is this
the only way to extract the element name or am I missing something?
Finally, is there some way to provide custom validation for specific
fields?
Thanks in advance,
Damian