- From: Lieve Laporte <lieve.laporte@uz.kuleuven.ac.be>
- Date: Wed, 28 Nov 2001 15:23:51 +0100
- To: "Erik Beijnoff" <erik@addsystems.com>
- Cc: <xmlschema-dev@w3.org>
- Message-ID: <00b301c17818$4d8eb1b0$2d63a8c0@uz.kuleuven.ac.be>
Re: conditional schemas----- Original Message ----- From: Erik Beijnoff To: 'Eddie Robertsson' Cc: lieve.laporte@uz.kuleuven.ac.be ; xmlschema-dev@w3.org Sent: Wednesday, November 28, 2001 1:53 PM Subject: Re: conditional schemas >> <actions name="access"> >> ... >> ==> the document has to contain tag <tag> >> ... >> </actions> >> >> <actions name="settings"> >> ... >> ==> the document may not contain tag <tag> >> ... >> </actions> >> >> In this case, can I express in the schema that if the value >of name is >> access, the <tag> should be present, and if the value of >name is settings, >> it shouldn't? > >Unfortunately you can't do this with W3C XML Schema. RELAX-NG >can do this and >the other alternative is to use W3C XML Schema with embedded >Schematron rules. >See my previous post [1] for an example of how to use embedded >Schematron rules. > Wouldn't it be possible to express this with something on the form: <xs:element name="testelement"> <xs:complexType> <xs:choice> <xs:element name="actions"> <xs:complexType> <xs:sequence> <xs:element name="tag"/> </xs:sequence> <xs:attribute name="name" use="required" fixed="access"/> </xs:complexType> </xs:element> <xs:element name="actions"> <xs:complexType> <xs:attribute name="name" use="required" fixed="settings"/> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> This is, of curse only valid under the condition that attribute "name" only can have the values "access" ot "settings". And if you feel uncomfortable with defining actions twice, make the element declaration references two global elements, which extends a common "actions" base type. Best regards Erik Beijnoff Systems development erik.beijnoff@addsystems.com erik@beijnoff.com In this case, wouldn't I have to duplicate everything that is inside the "actions" element? 'Cause that's quite a lot... Regards, Lieve
Received on Wednesday, 28 November 2001 09:23:57 UTC