Ian's books |
CPU Magazine
XML Schema Part 3: Complex Types and Type Declarations
As described in the September 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 -- sep04.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.
- example-1.xsd : (plain text version: example-1.txt)
Schema file defining an element (ex1-a) that contains a single element (heading) but mixed content. The following
documents all validate against this schema:
- example-2.xsd : (plain text version: example-2.txt)
A complex type with a sequence containing a choice. All elements are defined locally (except for the root element).
The following documents validate against this schema:
- example-3.xsd : (plain text version: example-3.txt)
Similar to example-2.xsd, but here a complex type with a choice containing a sequence.
- example-4.xsd : (plain text version: example-4.txt)
A complex type defined as a sequence of two elements (xxx yyy) and an xs:any.
The following documents validate against this schema:
- example-5.xsd : (plain text version: example-5.txt)
Same schema as in example-4.xsd, but using a named complexType (as opposed to an anonymous one).
The following documents (same as with example-4, only the schemaURI has been changed) validate against this schema:
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/).