Running XMLReaderValidator with Xerces2 2.11.0 Beta

This section describes a tutorial example on how to the Xerces2 XMLReader class to validate an XML document assigned with an XSD file with 'Xerces2 2.11.0 (XML Schema 1.1) (Beta)' version.

Now I am ready to test the "Xerces2 2.11.0 (XML Schema 1.1) (Beta)" version, with the same program, XMLReaderValidator:

   -cp ".;c:\local\xerces-2_11_0-xml-schema-1.1-beta\xercesImpl.jar"
   XMLReaderValidator dictionary_invalid_xsd.xml

Exception in thread "main" java.lang.NoClassDefFoundError: 
   at org.apache.xerces.impl.xs.traversers.XSDHandler.createTravers...
   at org.apache.xerces.impl.xs.traversers.XSDHandler.prepareForTra...
   at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(U...
   at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown ...
   at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGramma...
   at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartEleme...
   at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unk...
   at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElem...
   at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDisp...
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragmen...
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDoc...
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown So...
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown So...
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Sou...
   at XMLReaderValidator.main(
Caused by: java.lang.ClassNotFoundException: 
   at Method)
   at java.lang.ClassLoader.loadClass(
   at sun.misc.Launcher$AppClassLoader.loadClass(
   at java.lang.ClassLoader.loadClass(
   ... 16 more

I am surprised to see this ClassNotFoundException error. But it is not hard to fix it. The missing class is actually provided in org.eclipse.wst.xml.xpath2.processor_1.1.0.jar in the "Xerces2 2.11.0 (XML Schema 1.1) (Beta)" package.

Rerunning XMLReaderValidator with org.eclipse.wst.xml.xpath2.processor_1.1.0.jar included in the classpath, I get the correct validation result:

   -cp ".;c:\local\xerces-2_11_0-xml-schema-1.1-beta\xercesImpl.jar;
   XMLReaderValidator dictionary_invalid_xsd.xml

   Public ID: null
   System ID: file:///C:/herong/dictionary_invalid_xsd.xml
   Line number: 7
   Column number: 22
   Message: cvc-datatype-valid.1.2.1: 'yes' is not a valid value for 


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 for XSD 1.1 Validation 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



 PDF Printing Version