Verify 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 latest Xerces2 Java 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 Xerces2 package in the "-cp" option in the "java" command line.

To avoid repeating this long "-cp" option in the command line each time, I created a batch file with .bat or .sh script to wrap "java -cp ..." as a new command. Here is the java_xerces.bat for Windows computers.

herong> type java_xerces.bat
java -cp .;.\xerces-2_12_1-xml-schema-1.1\xml-apis.jar;
^^^.\xerces-2_12_1-xml-schema-1.1\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.

Also note that the list of JAR files and and -cp file delimiters are different for different Xerces2 versions and computer platforms.

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

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

herong> java_xerces dom.Counter hello.xml
hello.xml: 30;4;0 ms (1 elems, 0 attrs, 0 spaces, 12 chars)

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

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

Verify 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 APIs

 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


 Archived Tutorials


 Full Version in PDF/EPUB