<!--
 Copyright (c) 2000-2021 Ericsson Telecom AB
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v2.0
 which accompanies this distribution, and is available at
 https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html

 Contributors:
  Balasko, Jeno
  Baranyi, Botond
  Raduly, Csaba
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
            xmlns:r3="www.XmlTest.org/complex_unique"
            targetNamespace="www.XmlTest.org/complex_unique" 
            elementFormDefault="qualified">
  <annotation>
    <documentation xml:lang="en">
      This documentum tests based on
      XML Schema Part 0: Primer Second Edition
      5 Advanced Concepts III. The Quantity Report
      5.1 Specifying Uniqueness
      XML Schema Part 1: Structures Second Edition
      3.11.2 XML Representation of Identity-constraint Definition Schema Components
    </documentation>
  </annotation>

  <element name="purchaseReport">
    <complexType>
      <sequence>
        <element name="regions" type="r3:RegionsType"/>
          
        <element name="parts" type="r3:PartsType"/>
      </sequence>
      <attribute name="period"       type="duration"/>
      <attribute name="periodEnding" type="date"/>
    </complexType>

    <unique name="dummy1">
      <selector xpath="r3:regions/r3:zip"/>
      <field xpath="@code"/>
    </unique>

    <key name="pNumKey">
      <selector xpath="r3:parts/r3:part"/>
      <field xpath="@number"/>
    </key>

    <keyref name="dummy2" refer="r3:pNumKey">
      <selector xpath="r3:regions/r3:zip/r3:part"/>
      <field xpath="@number"/>
    </keyref>

  </element>

  <complexType name="RegionsType">
    <sequence>
      <element name="zip" maxOccurs="unbounded">
        <complexType>
          <sequence>
            <element name="part" maxOccurs="unbounded">
              <complexType>
                <complexContent>
                  <restriction base="anyType">
                    <attribute name="number"   type="string"/>
                    <attribute name="quantity" type="positiveInteger"/>
                  </restriction>
                </complexContent>
              </complexType>
            </element>
          </sequence>
          <attribute name="code" type="positiveInteger"/>
        </complexType>
      </element>
    </sequence>
  </complexType>

  <complexType name="PartsType">
    <sequence>
      <element name="part" maxOccurs="unbounded">
        <complexType>
          <simpleContent>
            <extension base="string">
              <attribute name="number" type="string"/>
            </extension>
          </simpleContent>
        </complexType>
      </element>
    </sequence>
  </complexType>

</schema>
