Class XmlValidationError

java.lang.Object
org.apache.xmlbeans.XmlError
org.apache.xmlbeans.XmlValidationError
All Implemented Interfaces:
Serializable

public class XmlValidationError
extends XmlError
The XmlValidationError class extends the XmlErrorXMLError class. The XML Validator contains extra attributes that can be used to construct the XML validation error programatically.

To extract the validation error cast the errors to XmlValidationError instead of XmlError for example:

 xobj.validate(new XmlOptions().setErrorListener(errors))
 for (Iterator it = errors.iterator(); it.hasNext(); )
 {
      XmlError err = (XmlError)it.next());
      if (err instanceof XmlValidationError)
      {
          XmlValidationError validationError = (XmlValidationError) err;
     }
 }
Whenever an XmlValidationError is retrieved it will always be populated with the following information:
  • Message
  • Severity
  • Error Type

The error type is very important because the other attributes of the XMLValidationError are populated based on the error type.

if errortype == INCORRECT_ELEMENT then
offendingQName, badSchemaType will always be present, however expectedSchemaType and expectedQNames are available only if it is possible to determine them during vaildation.

if errortype == ELEMENT_NOT_ALLOWED then
badSchemaType will always be present, however expectedSchemaType and offendingQName are available only if it is possible to determine them during vaildation.

if errortype == INCORRECT_ATTRIBUTE then
offendingQName, badSchemaType will always be present

if errortype == ATTRIBUTE_TYPE_INVALID then
no other addtional attributes are populated

if errortype == LIST_INVALID then
expectedSchemaType will always be present

if errortype == UNION_INVALID then
expectedSchemaType will always be present

if errortype == NIL_ELEMENT then
offendingQName, expectedSchemaType and badSchemaType will always be present

if errortype == ELEMENT_TYPE_INVALID then
offendingQName will always be present, other attributes may be available

See Also:
Serialized Form