Consider the two scenarios:
I have one XML that looks like:
<personinfo>
<info>
<option1>Coke</option1>
</info>
</personinfo>
where I should have a choice between an option1 and option2 element.
I have another XML that looks like:
<personinfo>
<info>
<firstname>Yair</firstname>
<lastname>Zaslavsky</lastname>
</info>
</personinfo>
where both firstname and lastname should appear (hence a sequence).
I have tried to use the following schema:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="optionsChoice">
<xs:choice>
<xs:element name="option1" type="xs:string"/>
<xs:element name="option2" type="xs:string"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="optionsSequence">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="personinfo">
<xs:choice>
<xs:element name="info" type="optionsSequence"/>
<xs:element name="info" type="optionsChoice"/>
</xs:choice>
</xs:complexType>
</xs:schema>
With no luck.
Bear in mind that I must have "info" as an element name in both cases.
How can I fix this issue?