Ian's books |
CPU Magazine
XML Schema Part 5: Schemas and Namespaces
As described in the November 2004 issue of
CPU - Computer Power User
magazine.
Examples
A) Downloadable ZIP File
-
There are several examples here -- why not download the whole lot
as a ZIP file -- nov04.zip -- and install
them on your own machine?
B) The example XML documents
To play with these documents, simply load them into an XML or XML schema editor and
test them for validity, or load them into a browser and view the results. Some editors will
test for validity automatically as the file is loaded, while others will require
that you select to validate.
- schema1.xsd : (plain text version: schema1.txt)
A simple schema file defining a global and local element in no namespace. The following schemas
introduce an explicit target namespace to this schema. The following document validate against
this 'no namespace' schema:
- schema2.xsd : (plain text version: schema2.txt)
This schema defined a targetNamespace, and internally uses the default namespace to make sure the
type attributes refer to the correct target namespace-defined types.
The following documents all validate against this schema: if they are invalid, then comments inside
the document explain why:
- schema3.xsd : (plain text version: schema3.txt)
This schema declares all elements to be qualified, using the elementFormDefault attribute.
The following documents all validate against this schema: if they are invalid, then comments inside
the document explain why:
C) Some XML Editors with Validation Features
See the listing provided in the March 2004 CPU article (http://www.iangraham.org/writing/cpu-articles/mar04/).
Also, Altovia provides a free 'Home use' Version of their XML Spy XML editor. This editor has pretty good
diagnostic messages for XML schema errors, and can be a useful tool for learning about XML schema. The package
is available form Altovia at
http://www.xmlspy.com/download_spy_home.html.