According to this page (and my practice), xs:group
element cannot be child of xs:all
.
So something like
<xs:group name="g">
<xs:element name="first" type="xs:string"/>
<xs:element name="last" type="xs:string"/>
</xs:group>
<xs:all>
<xs:group ref="g" minOccurs="0" maxOccurs="1"/>
<xs:element name="id" type="xs:string"/>
</xs:all>
is not valid because group cannot be inside xs:all
. But I want to define a schema, in which two elements (first
and last
in above example) both exist or neither of them exists, so I make them into a group. Then I want to make the group part of xs:all
because the group can appear with other elements (for example, id element above) in any order. In other words, I want to have several elements are optional as a whole group. Without xs:group
being able to be child of xs:all
, how can I achieve this?