views:

32

answers:

1

the name sums it up GRP2 can come in multiple shapes and flavors heres my schema

<xsd:element name="root">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="GRP1" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

    <xsd:complexType name="GRP1">
        <xsd:sequence>
            <xsd:element name="GRP2" minOccurs="0" maxOccurs="100" type="GRP2"/>
        </xsd:sequence>
    </xsd:complexType>


    <xsd:complexType name="GRP2" abstract="true">
        <xsd:sequence minOccurs="1"/>
    </xsd:complexType>


    <!-- G09 -->
    <xsd:complexType name="GRP2OPT9">
        <xsd:complexContent>
            <xsd:extension base="GRP2">
                <xsd:sequence minOccurs="1">
                    <xsd:element name="G01"/>
                    <xsd:element name="G02"/>
                    <xsd:element name="G04" minOccurs="0"/>
                    <xsd:sequence minOccurs="0">
                        <xsd:element name="G06"/>
                        <xsd:element name="G07"/>
                    </xsd:sequence>
                    <xsd:element name="G09"/>
                    <xsd:element name="G10"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <!-- G03 and 09 -->
    <xsd:complexType name="GRP2OPT39">
        <xsd:complexContent>
            <xsd:extension base="GRP2">
                <xsd:sequence minOccurs="1">
                    <xsd:element name="G01"/>
                    <xsd:element name="G02"/>
                    <xsd:element name="G03"/>
                    <xsd:element name="G04" minOccurs="0"/>
                    <xsd:sequence minOccurs="0">
                        <xsd:element name="G06"/>
                        <xsd:element name="G07"/>
                    </xsd:sequence>
                    <xsd:element name="G09"/>
                    <xsd:element name="G10"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <!-- G08 -->
    <xsd:complexType name="GRP2OPT8">
        <xsd:complexContent>
            <xsd:extension base="GRP2">
                <xsd:sequence minOccurs="1">
                    <xsd:element name="G01"/>
                    <xsd:element name="G02"/>
                    <xsd:element name="G04" minOccurs="0"/>
                    <xsd:sequence minOccurs="0">
                        <xsd:element name="G06"/>
                        <xsd:element name="G07"/>
                    </xsd:sequence>
                    <xsd:element name="G08"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <!-- G03 and 08 -->
    <xsd:complexType name="GRP2OPT38">
        <xsd:complexContent>
            <xsd:extension base="GRP2">
                <xsd:sequence minOccurs="1">
                    <xsd:element name="G01"/>
                    <xsd:element name="G02"/>
                    <xsd:element name="G03"/>
                    <xsd:element name="G04" minOccurs="0"/>
                    <xsd:sequence minOccurs="0">
                        <xsd:element name="G06"/>
                        <xsd:element name="G07"/>
                    </xsd:sequence>
                    <xsd:element name="G08"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <!-- G03 and 05 -->
    <xsd:complexType name="GRP2OPT35">
        <xsd:complexContent>
            <xsd:extension base="GRP2">
                <xsd:sequence minOccurs="1">
                    <xsd:choice>
                        <xsd:sequence>
                            <xsd:element name="G01"/>
                            <xsd:element name="G02"/>
                            <xsd:element name="G03"/>
                            <xsd:element name="G04" minOccurs="0"/>
                        </xsd:sequence>
                        <xsd:sequence>
                            <xsd:element name="G04" minOccurs="0"/>
                            <xsd:element name="G05"/>
                        </xsd:sequence>
                    </xsd:choice>
                    <xsd:sequence minOccurs="0">
                        <xsd:element name="G06"/>
                        <xsd:element name="G07"/>
                    </xsd:sequence>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <!-- G03 -->
    <xsd:complexType name="GRP2OPT3">
        <xsd:complexContent>
            <xsd:extension base="GRP2">
                <xsd:sequence minOccurs="1">
                    <xsd:element name="G01"/>
                    <xsd:element name="G02"/>
                    <xsd:element name="G03"/>
                    <xsd:element name="G04" minOccurs="0"/>
                    <xsd:sequence minOccurs="0">
                        <xsd:element name="G06"/>
                        <xsd:element name="G07"/>
                    </xsd:sequence>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>



and heres the psuedodata



 <root>
       <GRP1>
          <GRP2>
             <G01/>
             <G02/>
             <G03/>
             <G08/>
          </GRP2>
       </GRP1>
    </root>

This data I thought would fail-but as Ive found out the GRP2 only inits to the abstract one and never its extended "children"

the requirements are this :

req'd: G01, G02 G03

one of G08, G09 , G05 or G03 must exist

G08 , G09 and G05 cannot exist together

and G04 is optional and so are G06 and G07

(10 only exists when 9 exists)

In short Im losing over this and cannot come up with one that will validate all of thes requirements any help? thank you

A: 

I went about it differently just using a complex choice

<xsd:complexType name="GRP2">
    <xsd:sequence>
        <xsd:element name="G">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="G01"/>
                    <xsd:element name="G02"/>
                    <xsd:choice maxOccurs="1">
                        <xsd:sequence>
                                <xsd:element name="G03" maxOccurs="1"/>
                                <xsd:element name="G04" minOccurs="0" maxOccurs="1"/>
                                <xsd:group ref="G5to10"/>
                        </xsd:sequence>
                        <xsd:sequence>
                            <xsd:element name="G04" minOccurs="0" maxOccurs="1"/>
                            <xsd:group ref="G5to10" maxOccurs="1"/>
                        </xsd:sequence>
                    </xsd:choice>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
        <xsd:element name="G73"/>
    </xsd:sequence>
</xsd:complexType>

<xsd:group name="G5to10">
    <xsd:sequence>
        <xsd:choice maxOccurs="1">
            <xsd:sequence>                      
                <xsd:element name="G05" maxOccurs="1"/>
                <xsd:sequence minOccurs="0" maxOccurs="1">
                    <xsd:element name="G06"/>
                    <xsd:element name="G07"/>
                </xsd:sequence>
            </xsd:sequence>
            <xsd:sequence maxOccurs="1" minOccurs="0">
                <xsd:sequence minOccurs="0" maxOccurs="1">
                    <xsd:element name="G06"/>
                    <xsd:element name="G07"/>
                </xsd:sequence>
                <xsd:choice maxOccurs="1" minOccurs="0">
                    <xsd:element name="G08" maxOccurs="1"/>
                    <xsd:sequence maxOccurs="1">
                        <xsd:element name="G09"/>
                        <xsd:element name="G10"/>
                    </xsd:sequence>
                </xsd:choice>
            </xsd:sequence>
        </xsd:choice>
    </xsd:sequence>
</xsd:group>
jtzero