Vary type in XSD according to element value?
问题 I have the following two XML documents: <struct> <type>a</type> <p1 xsi:nil="true"/> <p2 xsi:nil="true"/> </struct> <struct> <type>b</type> <p1 xsi:nil="true"/> <p2 xsi:nil="true"/> </struct> I wish to build a schema which validates that in case the value of the element type is "a", then it's sub elements (aka p1 & p2 ) should be nil or empty. Whereas when the element type is something else, such as "b", then p1 or p2 elements can contain anything or nothing. 回答1: That's a classic example of