- From: Eddie Robertsson <eddie@allette.com.au>
- Date: Fri, 08 Feb 2002 10:09:37 +1100
- To: Marco.Hoendervangers@OVSoftware.com
- CC: xmlschema-dev@w3.org
Hi Marco, > Hi, > > Does anyone knows if it is possible to define dependencies between elements? > Consider the following xml: > > <person> > <name>bill</name> > <married>false</married> > </person> > > When the person is married another element is required: partner. > > <person> > <name>bill</name> > <married>true</married> > <partner>kelly</partner> > </person> > > Is there a way to define this kind of behaviour in xml schema? This is commonly known as a co-occurence constraint and these can generally not be expressed in W3C XML Schema. To express this you can move to another schema language such as RELAX-NG or Schematron or you can choose to embedd Schematron rules in your W3C XML Schema. In this case you could do a workaround by using the xsi:type attribute in your instance document to define the married type: <person xsi:type="notMarriedPerson"> <name>bill</name> <married>false</married> </person> <person xsi:type="marriedPerson"> <name>bill</name> <married>true</married> <partner>kelly</partner> </person> See [1] for more information about embedding Schematron rules and [2] for more info on xsi:type. Cheers, /Eddie [1] http://lists.w3.org/Archives/Public/xmlschema-dev/2001Nov/0049.html [2] http://www.w3.org/TR/xmlschema-0/#UseDerivInInstDocs
Received on Thursday, 7 February 2002 17:59:43 UTC