This section describes a tutorial example on XML document validation errors related to a complex datatype defined a schema.
To see some examples of the validation errors on elements using complex datatypes,
I wrote the following XML document, term_error.xml:
<?xml version="1.0"?>
<term update="Yesterday" note="To be updated.">
<source>Internet</source>
<name>Extensible</name>
<definition>Capable of being extended.</definition>
</term>
Of course, this XML document does not conform to term.xsd. Here are the errors
generated from XsdSchemaValidator.java:
>java XsdSchemaValidator term.xsd term_error.xml
Error:
Line number: 2
Column number: 48
Message: cvc-datatype-valid.1.2.1: 'Yesterday' is not a valid
value for 'date'.
Error:
Line number: 2
Column number: 48
Message: cvc-attribute.3: The value 'Yesterday' of attribute
'update' on element 'term' is not valid with respect to its
type, 'date'.
Error:
Line number: 2
Column number: 48
Message: cvc-complex-type.3.2.2: Attribute 'note' is not allowed
to appear in element 'term'.
Error:
Line number: 3
Column number: 10
Message: cvc-complex-type.2.4.a: Invalid content was found
starting with element 'source'. One of '{name}' is expected.
Failed with errors: 4
For more tutorials on complex datatypes, read other chapters of this book.