<!--
    Copyright (C) 2007 Orbeon, Inc.

    This program is free software; you can redistribute it and/or modify it under the terms of the
    GNU Lesser General Public License as published by the Free Software Foundation; either version
    2.1 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU Lesser General Public License for more details.

    The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
-->
<xs:schema targetNamespace="http://orbeon.org/oxf/examples/test"
           xmlns:test="http://orbeon.org/oxf/examples/test"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified">

    <!--<xs:element name="instance">-->
        <!--<xs:complexType>-->
            <!--<xs:sequence>-->
                <!--<xs:element name="value">-->
                    <!--<xs:complexType>-->
                        <!--<xs:attribute name="state" type="test:state"/>-->
                    <!--</xs:complexType>-->
                <!--</xs:element>-->
                <!--<xs:element name="state1" type="test:state-type"/>-->
                <!--<xs:element name="state2" type="test:state-type"/>-->
            <!--</xs:sequence>-->
        <!--</xs:complexType>-->
    <!--</xs:element>-->

    <xs:attribute name="email" type="test:email"/>

    <xs:simpleType name="email">
        <xs:restriction base="xs:string">
            <xs:pattern value="[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)*@[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)*"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="zip">
        <xs:restriction base="xs:positiveInteger">
            <xs:minInclusive value="10000"/>
            <xs:maxInclusive value="99999"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="state-type">
        <xs:restriction base="xs:string">
            <xs:enumeration value="AL"/>
            <xs:enumeration value="AK"/>
            <xs:enumeration value="AZ"/>
            <xs:enumeration value="AR"/>
            <xs:enumeration value="CA"/>
            <xs:enumeration value="CO"/>
            <xs:enumeration value="CT"/>
            <xs:enumeration value="DE"/>
            <xs:enumeration value="DC"/>
            <xs:enumeration value="FL"/>
            <xs:enumeration value="GA"/>
            <xs:enumeration value="HI"/>
            <xs:enumeration value="ID"/>
            <xs:enumeration value="IL"/>
            <xs:enumeration value="IN"/>
            <xs:enumeration value="IA"/>
            <xs:enumeration value="KS"/>
            <xs:enumeration value="LA"/>
            <xs:enumeration value="ME"/>
            <xs:enumeration value="MD"/>
            <xs:enumeration value="MA"/>
            <xs:enumeration value="MI"/>
            <xs:enumeration value="MN"/>
            <xs:enumeration value="MS"/>
            <xs:enumeration value="MO"/>
            <xs:enumeration value="MT"/>
            <xs:enumeration value="NE"/>
            <xs:enumeration value="NV"/>
            <xs:enumeration value="NH"/>
            <xs:enumeration value="NJ"/>
            <xs:enumeration value="NM"/>
            <xs:enumeration value="NY"/>
            <xs:enumeration value="NC"/>
            <xs:enumeration value="ND"/>
            <xs:enumeration value="OH"/>
            <xs:enumeration value="OK"/>
            <xs:enumeration value="OR"/>
            <xs:enumeration value="PA"/>
            <xs:enumeration value="RI"/>
            <xs:enumeration value="SC"/>
            <xs:enumeration value="SD"/>
            <xs:enumeration value="TN"/>
            <xs:enumeration value="TX"/>
            <xs:enumeration value="UT"/>
            <xs:enumeration value="VT"/>
            <xs:enumeration value="VA"/>
            <xs:enumeration value="WA"/>
            <xs:enumeration value="WV"/>
            <xs:enumeration value="WI"/>
            <xs:enumeration value="WY"/>
            <xs:enumeration value="AS"/>
            <xs:enumeration value="GU"/>
            <xs:enumeration value="MP"/>
            <xs:enumeration value="PR"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="state-with-attribute">
        <xs:simpleContent>
            <xs:extension base="test:state-type">
               <xs:attribute name="code" type="xs:integer"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:element name="state-element">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="test:state-type">
                   <xs:attribute name="code" type="xs:integer"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

    <xs:element name="nillable-state-element" nillable="true">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="test:state-type">
                   <xs:attribute name="code" type="xs:integer"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

</xs:schema>

