poi/xmlbeans/test/cases/xbean/scomp/derivation/GroupRestrictionTest.xsd
2018-02-16 22:41:27 +00:00

95 lines
3.5 KiB
XML

<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://xbean/scomp/derivation/GroupRestriction"
targetNamespace="http://xbean/scomp/derivation/GroupRestriction"
xmlns:base="http://xbean/scomp/contentType/ModelGroup"
>
<xsd:import namespace="http://xbean/scomp/contentType/ModelGroup"
schemaLocation="../contentType/Group.xsd"/>
<xsd:complexType name="restrictedSequenceT">
<xsd:complexContent>
<xsd:restriction base="base:SequenceT">
<xsd:sequence>
<xsd:element name="child1" type="xsd:integer" minOccurs="1"/>
<xsd:element name="child3" type="xsd:integer" minOccurs="1"
maxOccurs="2"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<!--elts must be a subset of the original choice group-->
<xsd:complexType name="restrictedChoiceT">
<xsd:complexContent>
<xsd:restriction base="base:ChoiceT">
<xsd:choice>
<xsd:element name="child3" type="xsd:integer" minOccurs="1"
maxOccurs="2"/>
</xsd:choice>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="restrictedAllT">
<xsd:complexContent>
<xsd:restriction base="base:AllT">
<xsd:all>
<xsd:element name="child2" type="xsd:string" maxOccurs="1"/>
<xsd:element name="child3" type="xsd:integer" minOccurs="1"/>
</xsd:all>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<!--examples from Walmsley book p. 327-->
<xsd:complexType name="replaceableChoiceT">
<xsd:choice maxOccurs="2">
<xsd:element name="a" type="xsd:string"/>
<xsd:element name="b" type="xsd:string"/>
<xsd:element name="c" type="xsd:int"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="replaceableAllT">
<xsd:all>
<xsd:element name="a" type="xsd:string" minOccurs="1"/>
<xsd:element name="b" type="xsd:string" minOccurs="0"/>
<xsd:element name="c" type="xsd:int"/>
</xsd:all>
</xsd:complexType>
<!--replace All group with sequence group-->
<xsd:complexType name="All2SequenceT">
<xsd:complexContent>
<xsd:restriction base="replaceableAllT">
<xsd:sequence>
<xsd:element name="a" type="xsd:string"/>
<xsd:element name="c" type="xsd:int"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<!--replace choice group with sequence group-->
<xsd:complexType name="Choice2SequenceT">
<xsd:complexContent>
<xsd:restriction base="replaceableChoiceT">
<xsd:sequence>
<xsd:element name="a" type="xsd:string"/>
<xsd:element name="c" type="xsd:int"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="RestrictedSequenceElt" type="restrictedSequenceT"/>
<xsd:element name="RestrictedChoiceElt" type="restrictedChoiceT"/>
<xsd:element name="RestrictedAllElt" type="restrictedAllT"/>
<xsd:element name="Choice2SeqElt" type="Choice2SequenceT"/>
<xsd:element name="All2SeqElt" type="All2SequenceT"/>
</xsd:schema>