XSD Tutorials - Herong's Tutorial Examples

http://www.herongyang.com/XSD

Copyright © 2014 by Dr. Herong Yang. All rights reserved.

XSD Tutorials This free book is a collection of tutorial examples and notes written by the author while he was learning XSD (XML Schema Definition). Topics include XSD, XML, Schema, simpleType, complexType, simpleContent, complexContent, dataTime, dateTimeStamp, gYear, gMonth, gDay, duration, yearMonthDuration, dayTimeduration, anyURI, Namespace, Xerces2.

Table of Contents

About This Book

Introduction to XML Schema

What Is XSD (XML Schema Definition)?

"Hello world!" Example of XSD

XML Schema Processors

XML Editor and Schema Processor - XMLPad

Installing WMHelp XMLPad Pro

Creating and Editing XML Documents

Creating and Editing XML Schema Documents

Assigning XML Schema to XML Documents

Validating XML Documents with Assigned XSD

Validating Non-Conforming XML Documents

XMLPad Crash When Validating Non-Conforming XML Documents

Generating XML Schema Diagrams

Generating XML Schema Documentations

Java API for XML Processing - JAXP

What Is JAXP?

Downloading and installing Java SE 1.6 Update 2

Compiling and Running Java Programs

XML File DOM Parser - XmlDomFileParser.java

JAXP - XML Schema (XSD) Validation

Standard Steps to Validate XML Documents Against a Schema

XSD Schema File Loader - XsdSchemaLoader.java

XSD Schema File Loading Errors

XSD Schema XML DOM Validator - XsdSchemaDomValidator.java

XSD Schema XML DOM Validation Errors

XSD Schema XML DOM Validator with Error Handler

XSD Schema XML SAX Validator - XsdSchemaSaxValidator.java

XSD Schema XML SAX Validation Errors

XSD Schema XML SAX Validator with Error Handler

XSD Schema XML Validator - Final Version

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 (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

Schema and Schema XML Representation

Checking Schema Documents - XsdSchemaChecker.java

Creating Schema Documents - "schema" Element

Declaring Root Elements - "element" Element

Specifying Element Datatype - "type" Attribute

Using XML Schema Built-in Datatypes

Using XML Schema Built-in Datatypes Incorrectly

Validating XML Documents against Schema Documents

Deriving New Simple Datatypes - "simpleType" Element

Defining Complex Datatypes - "complexType" Element

Validation Error Examples on Complex Datatypes

Introduction of XSD Built-in Datatypes

Overview of XSD 1.1 Built-in Datatypes

List of Built-in Datatypes

Datatypes, Values and Representations

Datatypes, Values and Representations - Example

Built-in Datatypes Lexical Representation Examples

Declaring Elements and Attributes with Built-in Datatypes

Defining New Datatypes with Built-in Datatypes

"anyType" Built-in Datatype Values and Representations

"anySimpleType" Built-in Datatype Values and Representations

"anyAtomicType" Built-in Datatype Values and Representations

"string" and Its Derived Datatypes

"string" Datatype Values and Representations

"normalizedString" Datatype Values and Representations

"token" Datatype Values and Representations

"language" Datatype Values and Representations

"language" Datatype Values - Invalid Inputs

"Name" Datatype Values and Representations

"NMTOKEN" Datatype Values and Representations

"NCName" Datatype Values and Representations

"ENTITY" Datatype Values and Representations

"ID" Datatype Values and Representations

"IDREF" Datatype Values and Representations

"decimal" and Its Derived Datatypes

"decimal" Datatype Values and Representations

"integer" Datatype Values and Representations

"long", "int", "short" and "byte" Datatypes

"nonNegativeInteger", "positiveInteger", "nonPositiveInteger", "negativeInteger" Datatypes

""unsignedLong" and "unsignedShort" Datatypes

"dateTime" and Its Related Datatypes

Date/Time Seven-Property Model

"dateTime" Datatype Values and Representations

"dateTimeStamp" Datatype Values and Representations

"date" Datatype Values and Representations

"time" Datatype Values and Representations

"gYear", "gMonth" and "gDay" Datatypes

"gYearMonth" and "gMonthDay" Datatypes

"duration" Datatype Values and Representations

"yearMonthDuration" Datatype Values and Representations

"dayTimeDuration" Datatype Values and Representations

Date, Time and Duration Datatype Summary

Miscellaneous Built-in Datatypes

"anyURI" Datatype Values and Representations

"QName" Datatype Values and Representations

"NOTATION" Datatype Values and Representations

"base64Binary" Datatype Values and Representations

"hexBinary" Datatype Values and Representations

"float" and "double" Datatype Values and Representations

"boolean" Datatype Values and Representations

Facets, Constraining Facets and Restriction Datatypes

What Is Facet?

List of Facets

Constructing New Datatypes with Restriction Facets

Facets Supported in "string"

Facets Supported in "dateTime"

Facets Supported in "decimal"

"simpleType" - Defining Your Own Simple Datatypes

What Is Simple Datatype?

"simpleType" Components - User-Defined Simple Datatypes

"simpleType" Components with "restriction" Child Components

"simpleType" Components with "union" Child Components

"simpleType" Components with "list" Child Components

Atomic, List, Atomic Union and List Union Datatypes

Constraining Facets on List Datatypes

Constraining Facets on Union Datatypes

Nested List Datatypes - Not Allowed

Nested Atomic and List Union Datatypes

Complex Element Declaration

Complex Element vs. Simple Element

Declaring Empty Elements

Declaring Simple Elements

Declaring Complex Elements with Simple Content

Declaring Complex Elements with Attributes Only

Declaring Complex Elements with Sub Elements Only

Declaring Complex Elements with Attributes and Sub Elements

Declaring Complex Elements with Attributes, Sub Elements & Text Content

Using Shorthand for "complexContent" with "restriction"

Identity-Constraints: unique, key and keyref

What Are Identity-Constraints?

What Is "unique" Identity-Constraint?

What Is "key" Identity-Constraint?

What Is "keyref" Identity-Constraint?

"keyref" Identity-Constraint XSD Example

Identity-Constraint with Multiple Fields

Assertion as Custom Validation Rules

What Is an Assertion?

Assertion as the Forth Level Constraints

"assert" Statements for "complexType" Datatype

"assertion" Statements for "simpleType" Datatype

XML Schema Location and Namespace in XML Documents

Assigning XML Schema Location in XML Documents

Validating XML Documents with Schema Locations

Validating XML Documents with Schema Locations - JAXP

Assigning XML Schema Location with Namespaces

Testing XML Schema Location with Namespaces

Testing XML Schema Location with Namespaces - JAXP

Overriding Element Types in XML Documents

Overriding Element Type to Empty Content - nillable

Overriding Element Type to Empty Content - xsi:nil

Defining a Derived Datatype from a Base Datatype

Overriding the Base Datatype - xsi:type

Overriding the Base Datatype - Errors

Linking Multiple Schema Documents Together

Schema Component Reuse - "include", "redefine" or "import"

Including Old Schema Documents - "include" Component

Including Old Schema Documents - Examples

Including Old Schema Documents - Errors

Redefining Old Datatypes - "redefine" Component

Redefining Old Datatypes - XML Examples

Redefining Old Datatypes - Errors

Importing Declarations Across Namespaces - "import" Component

Importing Declarations Across Namespaces - Examples

Using Elements Declared in Different Namespaces

Using Elements Declared in Different Namespaces - Errors

Glossary

References

PDF Printing Version

Keywords: XSD, XML, Schema, Validation, W3C, Tutorial, Example