∟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:
c:\Progra~1\Java\jdk1.7.0_07\bin\java
-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:
org/eclipse/wst/xml/xpath2/processor/XPathParserException
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(XMLReaderValidator.java:24)
Caused by: java.lang.ClassNotFoundException:
org.eclipse.wst.xml.xpath2.processor.XPathParserException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 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:
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"
XMLReaderValidator dictionary_invalid_xsd.xml
Error:
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
'boolean'.
...