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:
The root "book" element is declared with no namespace.
Child elements "title" and "author" are declared with no namespace.
Child elements "p" "pre", and "ul" are declared in the namespace of http://www.w3.org/1999/xhtml.
When writing XML documents to conform to a schema with multiple namespaces, you need to remember the following rules:
A namespace prefix must be declared for each namespace involved in XML document.
The correct namespace prefix must be used for each element that is defined in a named namespace.
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) 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>