# Test correct behaviour on unions with a good schema
# This defines a union using inline simpleTypes.  This syntax isn't
# described in http://www.w3schools.com/schema/el_union.asp but it is
# presumably contained somewhere in the formal definitions and is
# recognised by other validators. In any case we've been using this format
# extensively for some time.

--- |
<?xml version="1.0" encoding='ISO-8859-1'?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:documentation>
      #########################################################################
      Union test
      #########################################################################
    </xs:documentation>
  </xs:annotation>
  
   
  
  <xs:element name="Message-Text">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:minLength value="0"/>
        <xs:maxLength value="200"/>
      </xs:restriction>    
    </xs:simpleType>
  </xs:element>
  
    

  <xs:element name="decimal-or-tba">
    <xs:simpleType>
      <xs:union>
        <xs:simpleType>
          <xs:restriction base="xs:decimal">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="999999"/>
          </xs:restriction>
        </xs:simpleType>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="TBA"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:union>
    </xs:simpleType>
  </xs:element>      

 
  <xs:element name="my-root">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Message-Text" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="decimal-or-tba" minOccurs="1" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
         
</xs:schema>

--- |
<my-root>
   <Message-Text>union test pass</Message-Text>
   <decimal-or-tba>99999</decimal-or-tba>
   <decimal-or-tba>TBA</decimal-or-tba>
</my-root>
--- >
PASS

--- |
<my-root>
   <Message-Text>union test fail 1</Message-Text>
   <decimal-or-tba>xyz</decimal-or-tba>
</my-root>
--- >
FAIL

