vendredi 31 juillet 2015

XSD: Substitutiongroup when there may be multiple elements for that group in xml

Is it possible to make substitutiongroups work if I am uncertain whether or not one or both elements will be present in the xml?

For instance we could get this xml:

<topnode>
    <subnode1/>
    <subnode2/>
</topnode>

or this:

<topnode>
    <subnode1/>
</topnode>

The following xsd will work for the second XML we received, but not the first.

<xs:element name="topnode">
    <xs:complexType>
        <xs:all>
            <xs:element ref="subnodes">
        </xs:all>
    </xs:complexType>
</xs:element>
<xs:element name="subnodes" abstract="true"/>
<xs:element name="subnode1" substitutiongroup="subnodes"/>
<xs:element name="subnode2" substitutiongroup="subnodes"/>

I know that could already take care of this behavior, however I am trying to get "or" type behavior that can be chained.

I appreciate any help!

Aucun commentaire:

Enregistrer un commentaire