<?xml version="1.0" encoding="ISO-8859-2" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

 <xsd:element name="lista-adresow">
   <xsd:complexType>
    <xsd:sequence>
     <xsd:element name="wpis" minOccurs="0" maxOccurs="unbounded">
  <!-- definicja typu od razu (i anonimowo) -->
      <xsd:complexType>
       <xsd:sequence>
  <!-- tutaj deklaracja elementu od razu, odwolanie do typu nazwanego -->
        <xsd:element name="osoba" type="typ-osoby"/>

  <!-- tutaj odwolanie do deklaracji elementu na zewnatrz -->
        <xsd:element ref="adres" minOccurs="0" maxOccurs="unbounded"/>
       </xsd:sequence>
       <xsd:attribute name="id" type="xsd:ID" use="optional"/>
      </xsd:complexType>
     </xsd:element>
    </xsd:sequence>
   </xsd:complexType>
 </xsd:element>

 <xsd:element name="adres" type="typ-adresu"/>

  <!-- definicja typu nazwanego -->
 <xsd:complexType name="typ-osoby">
  <xsd:sequence>
   <xsd:element name="nazwisko" type="xsd:string"/>
   <xsd:element name="imie" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/>
  </xsd:sequence>
 </xsd:complexType>

 <xsd:complexType name="typ-adresu">
  <xsd:sequence>
   <xsd:element name="miejscowosc" type="xsd:string" minOccurs="1"/>
   <xsd:element name="kod" type="typ-kodu"/>
   <xsd:element name="ulica" type="xsd:string"/>
   <xsd:element name="dom" type="xsd:string"/>
   <xsd:element name="mieszkanie" type="xsd:string" minOccurs="0"/>
  </xsd:sequence>
 </xsd:complexType>

 <xsd:simpleType name="typ-kodu">
  <xsd:restriction base="xsd:string">
   <xsd:pattern value="\d{2}-\d{3}"/>
  </xsd:restriction>
 </xsd:simpleType>
</xsd:schema>