Verifying Installation of Xerces2

This section describes a tutorial example on how to verify the installation of the Xerces2 Java 2.11.0 XML Schema 1.1 Beta version by running a sample program dom.Counter.

After installing the Xerces2 Java 2.11.0 XML Schema 1.1 Beta version, I want to run some sample programs provided in the xercesSamples.jar file to verify the installation. For example, the dom.Counter sample program uses a DOM parser to count the total number of elements and attributes in an XML file.

dom.Counter is provided as a pre-compiled .class in the xercesSamples.jar. To run dom.Counter, I need to included xercesSamples.jar and other .jar files provided in the installation package in the "-cp" option in the "java" command line.

To avoid repeating this long "-cp" option, I I created as two small .bat files to help me compile and run Java programs:

>type jdk8c.bat
C:\Progra~1\Java\jdk1.8.0\bin\javac %1

set "x2path=c:\local\xerces-2_11_0-xml-schema-1.1-beta"
C:\Progra~1\Java\jdk1.8.0\bin\java -cp ".;%x2path%\xml-apis.jar;
^^^%x2path%\xercesSamples.jar;" %1 %2 %3 %4 %5 %6

Note that "^^^" indicates a line break inserted because of the limitation of the book format. You need to remove "^^^" and join the rest of the line with the previous line.

Now let's try to use jdk8x2r.bat to run dom.Counter:

>type hello.xml
<?xml version="1.0"?>
<p>Hello world!</p>

>jdk8x2r dom.Counter hello.xml
hello.xml: 64;6;0 ms (1 elems, 0 attrs, 0 spaces, 12 chars)

Okay. The Xerces2 Java 2.11.0 XML Schema 1.1 Beta version seems to be installed correctly. I see the counts in the output: "1 elems, 0 attrs, 0 spaces, 12 chars".

Last update: 2014.

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

 Installing Xerces2 Java Parser for XSD 1.1

Verifying Installation of Xerces2

 Xerces2 Sample Program List

 Xerces2 Sample Program dom.Counter

 dom.Counter Validating XML with Associated XSD

 dom.GetElementsByTagName and dom.Writer

 sax.DocumentTracer and sax.Writer

 Examples of XSD and XML Files with Errors

 sax.Writer Reporting Errors Embedded in XML Structure

 XSD 1.1 not Supported by sax.Writer

 XSD 1.1 Supported by jaxp.SourceValidator

 Examples of XSD 1.1 and XML Files with Errors

 jaxp.TypeInfoWriter as an XSD 1.1 Validation Tool

 Using Xerces2 Java API

 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