XSD Tutorials - Herong's Tutorial Examples - v5.23, by Herong Yang
Using Elements Declared in Different Namespaces
This section describes a tutorial example on how to use imported element declarations from a different namespace.
In the previous section, we wrote a new schema called xhtml_import.xsd that imported elements declarations from another namespace: xmlns:xhtml="http://www.w3.org/1999/xhtml". The final schema document represented a single schema with declarations from multiple namespaces:
When writing XML documents to conform to a schema with multiple namespaces, you need to remember the following rules:
Here is a good example XML document, xhtml_import.xml, that conforms to xhtml_import.xsd:
<?xml version="1.0"?> <book xmlns:xhtml="http://www.w3.org/1999/xhtml"> <!-- xhtml_import.xml - Copyright (c) 2002-2013 HerongYang.com. All Rights Reserved. --> <title>XML Schema Tutorials</title> <author>Herong Yang</author> <xhtml:p>What is XML Schema? ...</xhtml:p> <xhtml:pre>... schema code ...</xhtml:pre> </book>
Table of Contents
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
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
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
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