I am inheriting an Xml format and have been tasked with designing a schema around it. Schema generation is fairly simple in most cases, but I have come to a snag.
The issue is that there are elements that have the same name, but will have different content based on an attribute.
Here is an example. This isnt exactly what the Xml looks like, but should show the issue:
<TravelArrgangement type="Hotel">
<startDate>11-8-2016</startDate>
<endDate>11-9-2016</endDate>
<hotelName>Motel 6</hotelName>
<address>123 Fake Street</address>
</TravelArrgangement>
<TravelArrgangement type="Flight">
<startDate>11-8-2016 11:30:00AM</startDate>
<endDate>11-8-2016 4:30:00PM</endDate>
<carrier>Delta</carrier>
<origin>NYC</origin>
<destination>MIA</destination>
</TravelArrgangement>
Note that they are both TravelArrangements, but they have different child elements. Is there any way for me to write a schema definition where the same element can have different content based on a condition, such as the "type" attribute.
Now I know one suggestion would be to alter the Xml format so that a Flight and a HotelStay are their own elements, but there are many old systems relying on this data and they are unlikely to change any time soon.