XML Schemas Example 2: Message schema


<schema xmlns='http://www.w3.org/1999/XMLSchema'
        targetNamespace='http://www.w3.org/namespace/'
        xmlns:t='http://www.w3.org/namespace/'>

<element name='message'>
  <complexType content='elementOnly'>
    <element ref='t:sender'/>
    <element ref='t:receiver'/>
    <element ref='t:subject' minOccurs='0' maxOccurs='1'/>
    <element ref='t:date'/>
    <element ref='t:body'/>
    <attribute name='lang' use='required'>
       <simpleType base='string'>
           <enumeration value='fr'/>
           <enumeration value='en'/>
           <enumeration value='sp'/>
           <enumeration value='it'/>
       </simpleType>
    </attribute>
  </complexType>
</element>

<element name='body'>
  <complexType content='elementOnly'>
    <sequence maxOccurs='unbounded'>
      <element ref='t:para'/> </sequence>
  </complexType>
</element>


<element name='sender'> <complexType content='mixed'> </complexType> </element>
<element name='receiver'> <complexType content='mixed'> </complexType> </element>
<element name='subject'> <complexType content='mixed'> </complexType> </element>
<element name='date'> <complexType content='mixed'> </complexType> </element>
<element name='para'> <complexType content='mixed'> </complexType> </element>
</schema>