Schema and Schema XML Representation
This section describes what is a schema and what is a schema XML representation.
What is a schema? A schema is a container for schema components that defines a set of rules
to which an XML document must conform in order to be considered 'valid' according to that schema.
There are 7 types of schema components that mentioned in the XML Schema specification:
- Named type definition component - Defines a named simple or complex datatype.
- Attribute declaration component - Declares an attribute to be used in element declarations.
- Element declaration component - Declares an XML element for the XML document to be validated.
- Named attribute group definition component - Defines a named attribute group.
- Name model group definition component - Defines a named model group.
- Notation declaration component - Declares a notation.
A schema can be represented in XML by one or more schema documents, commonly called XSD (XML Schema Definition) documents
In another word, a schema XML document, XSD file, may contain one complete schema, or a part of one schema.
For example, the following XML document, hello.xsd, is the XML representation, XSD document, of a schema
which contains only 1 component, an element declaration component that defines a validation rule
for the XML document to be validated.
<xsd:element name="p" type="xsd:string"/>
Apparently, the validation rule defined in hello.xsd says that the XML document to be validated can have a root element
named as "p" with no attributes and no sub (child) elements. But it can have a "string" as its text content.
Base this concept, the more technically correct definition of an XSD document should be:
What is an XSD document? An XSD document is the XML representation
of an XML schema, or a part of an XML schema, expressed in XML Schema language.
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 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
"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