- From: G. Ken Holman <gkholman@CraneSoftwrights.com>
- Date: Mon, 02 Feb 2009 12:42:39 -0800
- To: <xmlschema-dev@w3.org>
At 2009-02-02 19:18 +0000, Michael Kay wrote: >Just to reinforce this, 4 validators (Saxon-SA, Xerces, XSV, and Ms .NET) >agree that the instance document > ><doc/> > >is valid against the schema > ><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > <xsd:element name="doc" type="foo"/> > <xsd:complexType name="foo"> > <xsd:sequence> > <xsd:element name="e1" minOccurs="0" maxOccurs="0"/> > </xsd:sequence> > </xsd:complexType> ></xsd:schema> > >but invalid against > ><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > <xsd:element name="doc" type="foo"/> > <xsd:complexType name="foo"> > <xsd:choice> > <xsd:element name="e1" minOccurs="0" maxOccurs="0"/> > <xsd:element name="e2"/> > </xsd:choice> > </xsd:complexType> ></xsd:schema> > >I'm having great difficulty seeing how it can be valid against a particle P >but invalid against a choice of which P is one of the options. But if you took the perspective that the particle doesn't even exist because of the minOccurs="0" and maxOccurs="0", then the above two schemas would be equivalent to the schemas written as: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="doc" type="foo"/> <xsd:complexType name="foo"> <xsd:sequence> </xsd:sequence> </xsd:complexType> </xsd:schema> .... and .... <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="doc" type="foo"/> <xsd:complexType name="foo"> <xsd:choice> <xsd:element name="e2"/> </xsd:choice> </xsd:complexType> </xsd:schema> Which would, in fact, be valid against the first schema but not the second. >But that seems to be the weight of opinion... I think it is explicit. http://www.w3.org/TR/xmlschema-1/#declare-element states: "the corresponding schema components are as follows (unless minOccurs=maxOccurs=0, in which case the item corresponds to no component at all):" Which tells me that my rewriting of the schemas is equivalent to the original ... there is no schema component for a declaration with minOccurs=maxOccurs=0, which means that when <doc/> is being tested with the second schema, there is no schema component e1 with minOccurs="0" for it to match against. Of course there would be if maxOccurs="1" or any other value and minOccurs="0", in which case it would have matched. I hope this helps. . . . . . . . . . . . Ken -- Upcoming hands-on XSLT, UBL & code list hands-on training classes: Brussels, BE 2009-03; Prague, CZ 2009-03, http://www.xmlprague.cz Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@CraneSoftwrights.com Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/x/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Received on Monday, 2 February 2009 20:43:40 UTC