In the article you referenced (http://www.w3.org/wiki/Needs_choice_inside_all) they provide an example with substitution group. So, why not to use one?
Here's how it should look:
<xs:element name="xml">
<xs:complexType>
<xs:all>
<xs:element ref="gender" minOccurs="1"/>
<xs:element ref="first_name"/>
<xs:element ref="last_name"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="gender" abstract="true"/>
<xs:element name="boy" substitutionGroup="gender"> ... </xs:element>
<xs:element name="girl" substitutionGroup="gender"> ... </xs:element>
Specifically, I tried this full schema:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="xml">
<xs:complexType>
<xs:all>
<xs:element ref="gender" minOccurs="1"/>
<xs:element ref="first_name"/>
<xs:element ref="last_name"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="gender" abstract="true"/>
<xs:element name="boy" substitutionGroup="gender"/>
<xs:element name="girl" substitutionGroup="gender"/>
<xs:element name="first_name" type="xs:string"/>
<xs:element name="last_name" type="xs:string"/>
</xs:schema>
to validate this XML:
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<girl/>
<first_name>Lara</first_name>
<last_name>Croft</last_name>
</xml>
It worked! At that, if in place of <girl/>
I specified <boy/>
, it passed too,
but did not when there was neither <girl/>
not <boy/>
or any of them together.