Ian's books |
CPU Magazine
XML Schema Part 4: Creating Custom Simple Types
As described in the October 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 -- oct04.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.
- ex1.xsd : (plain text version: ex1-xsd.txt)
Schema file defining simple type that supports values (bytes) in the range 0 to 255.
The following documents all validate against this schema: if they are invalid, then comments inside
the document explain why:
- ex2.xsd : (plain text version: ex2-xsd.txt)
Schema file defining a simple type that supports string (NMTOKEN) values between 5 and 10 characters long.
The following documents all validate against this schema: if they are invalid, then comments inside
the document explain why:
- ex3.xsd : (plain text version: ex3-xsd.txt)
Schema file defining a simple type that supports text string values between 5 and 10 characters long, and
that can only contain the characters [a-z], [A-Z], [0-9], and the underscore (_), dash (-) and
ampersand (@) characters.
The following documents all validate against this schema: if they are invalid, then comments inside
the document explain why:
- ex4.xsd : (plain text version: ex4-xsd.txt)
Schema file defining a simple type that allows only three specific values ("strategy", "tactics" and "other...").
The following documents all validate against this schema: if they are invalid, then comments inside
the document explain why:
- ex5.xsd : (plain text version: ex5-xsd.txt)
Schema file defining a simple type that allows values of the form "1d" 23h" "15d" etc. or dates in the ISO
standard format (e.g. 2004-08-12 -- the form YYYY-MM-DD).
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/).
D) Some Related Online Articles