XSD - Different ways to define same element



I have a large set of similar programs that return xml roughly like so:



<result>
<query>
</query>
<transaction>
<revenue>
...
</revenue>
</transaction>
</result>


The query element always has the same structure. The revenue element on the other hand has one of six structure depending on the specific program. While they all contain similar data, due to the underlying system (which I can't fix atm) each variation is completely different. It's not just a case of a few additional attributes for each, they are completely different.


I'm trying to make an XSD to validate the XML returned by any of the programs. I have an XSD for each variation of the revenue element but I'd like to combine them into one that will validate any.


I've tried using:



<xs:choice>
<xs:element name="revenue">
#variation
</xs:element>
<xs:element name="revenue">
#Another variation
</xs:element>
<xs:element name="revenue">
#Another variation
</xs:element">
</xs:choice>


But XSD doesn't like elements with the same names. Is there a way to work around this or otherwise achieve what I'm trying to do?


No comments:

Post a Comment