XSD: Define attributes based on the value of previous attribute

h00p7

New Member
I'm going to guess that this functionality doesn't exist, but I thought I'd give it one last shot.I've got an XML structure I'm trying to validate (I have no control over this structure).In this structure I can have multiple "Condition" tags, each tag has an attribute "type" and then the remaining attributes in that tag is dependent on what that type is. So if for example it looked like so:\[code\]<Condition type="LessThan" maxAmount="3"> <Effect type="Add" value="http://stackoverflow.com/questions/11412224/2" /></Condition><Condition type="GreaterThan" minAmount="1"> <Effect type="Transform" action="Skew" value="http://stackoverflow.com/questions/11412224/4" /> <Effect type="Transform" action="Stretch" value="http://stackoverflow.com/questions/11412224/3" /></Condition><Condition type="Range" minAmount="1" maxAmount="3"> <Effect type="YouGetTheDrift" /></Condition>\[/code\]Then if it's type LessThan, it only needs a maxAmount tag, etc.There is no way to make attributes required/optional/prohibited base on the value of a previous attribute, hey?I tried to create a choice with multiple Condition tags, with fixed values of type and custom attribute sets per type, but it complained about the tags having the same name.
 
Back
Top