Value equality - and following siblings
Value equality - and following siblings (a co-constraint use case)
Make the content model depend on the value of a particular child element. (In this case, only the following part of the content model need vary.)
source: Valeri Gavrilovets [1]
Other use cases: Co-constraint Use Cases.
Description
The schema should describe two distinct kinds of possible documents:
<result type="java.util.Hashtable"> <STATUS>OK</STATUS> <Key1>123</Key1> <Key2>234</Key2> <Key3>324</Key3> <Key4>256</Key4> </result>
and
<result type="java.util.Hashtable"> <STATUS>INIT</STATUS> <ERROR>200</ERROR> </result>
Analysis
(Add your analysis here; see your name in pixels!)
MSM
It's hard to escape the feeling that this would be better done by specifying distinct status_ok and status_nok elements. If there are reasons why that would not work in some situations, I'm having trouble identifying them.
If we removed the Element Declarations Consistent constraint, I suppose one could write something like this:
<xsd:complexType name="result"> <xsd:choice> <xsd:sequence> <xsd:element name="STATUS"> <xsd:simpleType> <xsd:restriction base="xsd:NMTOKEN"> <xsd:enumeration value="OK"> </xsd:enumeration> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element ref="key1"/> <xsd:element ref="key2"/> <xsd:element ref="key3"/> <xsd:element ref="key4"/> </xsd:sequence> <xsd:sequence> <xsd:element name="STATUS"> <xsd:simpleType> <xsd:restriction base="xsd:NMTOKEN"> <xsd:enumeration value="INIT"> </xsd:enumeration> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element ref="ERROR"/> </xsd:sequence> </xsd:choice> </xsd:complexType>