Xsd11SchemaValidator.java XSD 1.1 Test Result

This section provides a tutorial example on validating XML documents with XSD 1.1 schema using 'Xerces2 (XML Schema 1.1)' version.

First, let's see if my Xsd11SchemaValidator.java program will work with JDK 13 (no Xerces2 JAR files added) or not:

herong> java Xsd11SchemaValidator.java xsd11_datatype_test.xsd xsd11_datatype_test.xml

java.lang.IllegalArgumentException: No SchemaFactory that implements
   the schema language specified by:
   http://www.w3.org/XML/XMLSchema/v1.1 could be loaded

java.lang.NullPointerException

I am not surprised on this error. I knew that the default implementation of JAXP in JDK does not support XSD 1.1. So now run it again with JDK 13 and with Xerces2 2.12.1 (XML Schema 1.1) JAR files added:

herong> java_xerces Xsd11SchemaValidator.java xsd11_datatype_test.xsd
^^^ xsd11_datatype_test.xml

Error:
   Line number: 17
   Column number: 67
   Message: cvc-type.3.1.2: Element 'AnyAtomicType' is a simple type,
   so it must have no element information item [children].

Error:
   Line number: 23
   Column number: 51
   Message: cvc-datatype-valid.1.2.1: '?' is not a valid value for
   'dateTimeStamp'.

Error:
   Line number: 23
   Column number: 51
   Message: cvc-type.3.1.3: The value '   ?      ' of element
   'DateTimeStamp' is not valid.

Error:
   Line number: 29
   Column number: 65
   Message: cvc-datatype-valid.1.2.1: 'P1Y2M3DT5H20M30.123S' is not a
   valid value for 'dayTimeDuration'.

Error:
   Line number: 29
   Column number: 65
   Message: cvc-type.3.1.3: The value '   P1Y2M3DT5H20M30.123S    '
   of element 'DayTimeDuration' is not valid.

Error:
   Line number: 35
   Column number: 69
   Message: cvc-datatype-valid.1.2.1: 'P1Y2M3DT5H20M30.123S' is not a
   valid value for 'yearMonthDuration'.

Error:
   Line number: 35
   Column number: 69
   Message: cvc-type.3.1.3: The value '   P1Y2M3DT5H20M30.123S
   ' of element 'YearMonthDuration' is not valid.

Failed with errors: 7

The same result as shown above was not changed from I my last test run with JDK 1.7 and with Xerces2 2.11.0 (XML Schema 1.1) (Beta) JAR files with the same output as above

Congratulations, we have successfully created a Java program to validate an XML document with a XSD 1.1 schema!

Table of Contents

 About This Book

 Introduction to XML Schema

 XML Editor and Schema Processor - XMLPad

 Java API for XML Processing - JAXP

 JAXP - XML Schema (XSD) Validation

 Xerces2 Java Parser - Java API of XML Parsers

Using Xerces2 Java APIs

 JAXP, DOM and SAX APIs in Xerces2 JARs

 XML Schema (XSD) Validation using XMLReader

 Running XMLReaderValidator on XSD 1.1 Schema

 XML Schema (XSD) Validation using SAXParser

 SAXParser for XSD Validation Fixed

 SAXParser for XSD 1.1 Validation

 Xsd11SchemaValidator.java for XSD 1.1 Validation

Xsd11SchemaValidator.java XSD 1.1 Test Result

 XML Schema Language - Basics

 Introduction of XSD Built-in Datatypes

 "string" and Its Derived Datatypes

 "decimal" and Its Derived Datatypes

 "dateTime" and Its Related Datatypes

 Miscellaneous Built-in Datatypes

 Facets, Constraining Facets and Restriction Datatypes

 "simpleType" - Defining Your Own Simple Datatypes

 Complex Element Declaration

 Identity-Constraints: unique, key and keyref

 Assertion as Custom Validation Rules

 XML Schema Location and Namespace in XML Documents

 Overriding Element Types in XML Documents

 Linking Multiple Schema Documents Together

 Glossary

 Archived Tutorials

 References

 Full Version in PDF/EPUB