A Simple Document W3C XML Schema

This schema defines the urn:publicid:-:Norman+Walsh:Schema Example:EN namespace by defining several elements and their complex types.

Documents that conform to this schema have the general form:

<doc xmlns="urn:publicid:-:Norman+Walsh:Schema Example:EN">
  <title>Sample Document</title>
  <para>Some paragraphs.</para>
</doc>

The Types

This schema only defines three element types: doc, title, and para.

The doc Type

This is a document.

§1.
  <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>

The title Type

This is a title.

§2.
  <xs:complexType name="title"
                  mixed="true">
    §4. The role Attribute
    <xs:anyAttribute namespace="##other"
                     processContents="lax"/>
  </xs:complexType>

The para Type

This is a paragraph.

§3.
  <xs:complexType name="para"
                  mixed="true">
    §4. The role Attribute
    <xs:anyAttribute namespace="##other"
                     processContents="lax"/>
  </xs:complexType>

The role Attribute

Each of the complex types in this schema allows an optional role attribute. The role attribute is simply a string.

§4.
    <xs:attribute name="role"
                  type="xs:string"/>

The Elements

This schema defines one element of each complex type.

§5.
  <xs:element name="doc"
              type="ex:doc"/>
  <xs:element name="para"
              type="ex:para"/>
  <xs:element name="title"
              type="ex:title"/>

The Schema

The schema wrapper surrounds all these definitions.

§6.
<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">
  §1. The doc Type
  §2. The title Type
  §3. The para Type
  §5. The Elements
</xs:schema>