I have an XML doc that includes a repeating series of addresses whose actual content depends on the value of an included enumeration. I suppose this is a type of "tagged union" [or "discriminated union"?]:
{
<AddressList>
<Address>
<AddressType type="addressEnum" fixed="CanadianAddress"/>
<AddressValue>
<Street type="textstring">123 Yonge Street</Street>
<Province type="provinceEnum" value="Ontario"/>
<PostalCode type="postalCodeType" value="M1N 2O3"/>
</AddressValue>
</Address>
<Address>
<AddressType type="addressEnum" fixed="USAddress"/>
<AddressValue>
<Street type="textstring">456 Front Street</Street>
<State type="stateEnum" value="New York"/>
<ZipCode type="zipCodeType" value="12345"/>
</AddressValue>
</Address>
</AddressList>
}
I'm unclear how to express an XML schema [i.e. XSD] for the above XML. Do I need an empty 'AddressType' which both 'CanadianAddressType' and 'USAddressType' would extend? If I have 50 AddressTypes, would I require 50 such extensions?
NOTE: In case it's not obvious, the elements of a USAddress cannot appear following a CanadianAddress enumeration. Likewise, the elements of a CanadianAddress cannot appear following a USAddress enumeration.