- From: G. Ken Holman <gkholman@CraneSoftwrights.com>
- Date: Mon, 02 Feb 2009 09:13:14 -0800
- To: xmlschema-dev@w3.org
At 2009-02-02 11:33 +0100, Tobias Koenig wrote: >there are the two schemas > >1) ><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > <xsd:element name="doc" type="foo"/> > <xsd:complexType name="foo"> > <xsd:complexContent> > <xsd:restriction base="bar"> > <xsd:choice> > <xsd:element name="e1" minOccurs="0" maxOccurs="0"/> > <xsd:element name="e2"/> > </xsd:choice> > </xsd:restriction> > </xsd:complexContent> > </xsd:complexType> > <xsd:complexType name="bar"> > <xsd:choice> > <xsd:element name="e1"/> > <xsd:element name="e2"/> > </xsd:choice> > </xsd:complexType> ></xsd:schema> > >2) ><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> > <xs:complexType name="base"> > <xs:sequence> > <xs:element name="e1" type="xs:string" /> > </xs:sequence> > </xs:complexType> > <xs:complexType name="derived"> > <xs:complexContent> > <xs:restriction base="base"> > <xs:choice minOccurs="0"> > <xs:element name="e1" type="xs:string" /> > </xs:choice> > </xs:restriction> > </xs:complexContent> > </xs:complexType> ></xs:schema> > >In both cases a complex type with emptiable particle derives by restriction >from a complex type with non-emptiable particle. However the first schema >is valid according to xml schema test suite (and saxon validator) but the >second is not. So what is the real issue in the second schema? That a choice >particle is inherited from an sequence particle? No, as I see it in schema (1) there is always a path through "foo" that conforms to "bar" ... there is no way through "foo" that does not conform to "bar". This is because the only way through "foo" is with <e2> and <e2> is one of the ways through "bar". In schema (2), however, there is a path through "derived" that does not conform to "base", that being no elements where "base" does not allow no elements. Hence the processor cannot allow "derived" to be a restriction of "base" because it allows something that is not allowed in "base". 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 17:15:44 UTC