html xmlns="http://www.w3.org/TR/xhtml-basic"
xmlns:xs='http://www.w3.org/2001/XMLSchema'
xmlns:src="http://nwalsh.com/xmlns/litprog/fragment"
xmlns:ex='urn:publicid:-:Norman+Walsh:Schema Example:EN'
head
titleDocument Schematitle
head
body
div
h1A Simple Document W3C XML Schemah1
pThis schema defines the
tturn:publicid:-:Norman+Walsh:Schema Example:ENtt namespace
by defining several elements and their complex types.
p
pDocuments that conform to this schema have the general form:p
preltdoc xmlns="urn:publicid:-:Norman+Walsh:Schema Example:EN">
lttitle>Sample Documentlt/title>
ltpara>Some paragraphs.lt/para>
lt/doc>pre
div
div
h1a name="types"The Typesh1
pThis schema only defines three element types: ttdoctt,
tttitlett, and ttparatt.p
div
h2The ttdoctt Typeh2
pThis is a document.p
src:fragment id="doc.type"
xs:complexType name='doc'
xs:sequence
xs:element ref="ex:title" minOccurs='0' maxOccurs='1'
xs:choice minOccurs='1' maxOccurs='unbounded'
xs:element ref='ex:para'
xs:choice
xs:sequence
xs:complexType
src:fragment
div
div
h2The tttitlett Typeh2
pThis is a title.p
src:fragment id="title.type"
xs:complexType name='title' mixed="true"
src:fragref linkend="role.attrib"
xs:anyAttribute namespace="##other" processContents="lax"
xs:complexType
src:fragment
div
div
h2The ttparatt Typeh2
pThis is a paragraph.p
src:fragment id="para.type"
xs:complexType name='para' mixed="true"
src:fragref linkend="role.attrib"
xs:anyAttribute namespace="##other" processContents="lax"
xs:complexType
src:fragment
div
div
div
h1The ttrolett Attributeh1
pEach of the complex types in this schema allows an optional role attribute.
The role attribute is simply a string.p
src:fragment id="role.attrib"
xs:attribute name="role" type="xs:string"
src:fragment
div
div
h1The Elementsh1
pThis schema defines one element of each a href="#types"complex
typea.p
src:fragment id="elements"
xs:element name="doc" type="ex:doc"
xs:element name="para" type="ex:para"
xs:element name="title" type="ex:title"
src:fragment
div
div
h1The Schemah1
pThe schema wrapper surrounds all these definitions.p
src:fragment id="top" mundane-result-prefixes="ex xs"
xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
xmlns:ex='urn:publicid:-:Norman+Walsh:Schema Example:EN'
targetNamespace='urn:publicid:-:Norman+Walsh:Schema Example:EN'
elementFormDefault='qualified'
src:fragref linkend="doc.type"
src:fragref linkend="title.type"
src:fragref linkend="para.type"
src:fragref linkend="elements"
xs:schema
src:fragment
div
body
html