Xsd11SchemaValidator.java XSD 1.1 Test Result

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

First, let's see if my Xsd11SchemaValidator.java program will work with the Xerces2 version integrated in JDK 1.7:

c:\Progra~1\Java\jdk1.7.0_07\bin\javac Xsd11SchemaValidator.java

c:\Progra~1\Java\jdk1.7.0_07\bin\java Xsd11SchemaValidator 
   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 surprised on this error. I knew that the Xerces2 version integrated in JDK 1.7 does not support XSD 1.1. So now run it again with the "Xerces2 2.11.0 (XML Schema 1.1) (Beta)" version:

c:\Progra~1\Java\jdk1.7.0_07\bin\java 
   -cp ".;c:\local\xerces-2_11_0-xml-schema-1.1-beta\xercesImpl.jar;
   c:\local\xerces-2_11_0-xml-schema-1.1-beta
   \org.eclipse.wst.xml.xpath2.processor_1.1.0.jar"
   Xsd11SchemaValidator 
   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

Congratulations, we have successfully validated an XML document with a XSD 1.1 document!

Last update: 2013.

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 API

 XML Schema (XSD) Validation using XMLReader

 Running XMLReaderValidator with Xerces2 2.11.0 Beta

 Running XMLReaderValidator on XSD 1.1 Schema

 XML Schema (XSD) Validation using SAXParser

 SAXParser for XSD Validation in JDK 1.7

 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

 References

 PDF Printing Version