- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Mon, 15 Jul 2002 19:11:06 +0100
- To: Rainer Becker <r.becker@Nitro-Software.com>
- CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Rainer, > Is it possible, to perform two or more consecutive derivations by > restriction? Yes, it is. > Given the following schema: [snip] > <xsd:complexType name="FirmaType"> > <xsd:complexContent> > <xsd:restriction base="ListType"> > <xsd:sequence> > <xsd:element name="Name" type="xsd:string" /> > <xsd:element name="Comment" type="xsd:string" minOccurs="0" > maxOccurs="2" /> > <xsd:element name="Street" type="xsd:string" /> > </xsd:sequence> > </xsd:restriction> > </xsd:complexContent> > </xsd:complexType> > > <xsd:complexType name="OperatorType"> > <xsd:complexContent> > <xsd:restriction base="FirmaType"> > <xsd:sequence> > <xsd:element name="Name" type="xsd:string" /> > </xsd:sequence> > </xsd:restriction> > </xsd:complexContent> > </xsd:complexType> > > Although I am not 100% sure I donīt think it is, because this schema > produces an "invalid particle derivation by restriction". I can not > find any other mistake in it. There is another mistake in it. You're deriving the OperatorType from the FirmaType by restriction, which means that a valid element of the type OperatorType must (by definition) be a valid element of the type FirmaType. The FirmaType has an obligatory Name, an optional Comment and an obligatory Street. In the OperatorType, on the other hand, there's no Street. That means that an element of the type OperatorType mustn't have a Street element, but if it doesn't have a Street element it can't be a valid FirmaType. So the derivation must be wrong. To fix it, either the OperatorType must contain a Street or the Street in the FirmaType must be optional (have a minOccurs of 0). > Second question: I tried to find some kind of confirmation in the > "Structures" for this problem. The section that gives the constraints on valid derivations by restriction is 3.4.6, specifically Schema Component Constraint: Derivation Valid (Restriction, Complex) at http://www.w3.org/TR/xmlschema-1/#cos-ct-restricts Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Monday, 15 July 2002 14:11:09 UTC