- From: C. M. Sperberg-McQueen <cmsmcq@acm.org>
- Date: Wed, 02 Oct 2002 20:17:11 -0600
- To: Steven Noels <stevenn@outerthought.org>
- Cc: W3C XML Schema Comments list <www-xml-schema-comments@w3.org>
At 2002-10-02 13:08, Steven Noels wrote: >Hi all, > >Due to the non-deterministic nature of XML Schema, ? I'm not sure what non-determinism you mean. In XML Schema 1.0, content models must be 'deterministic' in the sense used by XML 1.0. >I was wondering if it is possible at all to define this model: > >Allowed: > ><a><b/></a> ><a><c/></a> ><a><b/><c/></a> ><a><c/><b/></a> > >Not allowed: > ><a/> > >Does anyone has an idea? How about this? It's the schema equivalent of ((b,c?) | (c,b?)), which would be the DTD notation for this. <xsd:schema targetNamespace="http://cmsmcq.com/testns" xmlns:my="http://cmsmcq.com/testns" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="a" type="my:abc"/> <xsd:element name="b"/> <xsd:element name="c"/> <xsd:complexType name="abc"> <xsd:choice> <xsd:sequence> <xsd:element ref="my:b"/> <xsd:element ref="my:c" minOccurs="0" maxOccurs="1"/> </xsd:sequence> <xsd:sequence> <xsd:element ref="my:c"/> <xsd:element ref="my:b" minOccurs="0" maxOccurs="1"/> </xsd:sequence> </xsd:choice> </xsd:complexType> </xsd:schema> The following instance illustrates that (according to xsv, at least) this schema allows what you want it to allow, without allowing empty 'a' elements. You should get an error on the final 'a' element; comment it out and the document is schema-valid. <test xmlns="http://cmsmcq.com/testns"> <a><b/></a> <a><b/><c/></a> <a><c/></a> <a><c/><b/></a> <a/> </test> I hope this helps. -CMSMcQ
Received on Wednesday, 2 October 2002 22:18:45 UTC