- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Wed, 24 Jul 2002 22:49:11 +0100
- To: xmlschema-dev@w3.org, Calvin Smith <calvins@SIMS.Berkeley.EDU>
Hi Calvin, > I am trying to restrict a type that consists solely of an <xsd:any> > (inside <xsd:sequence>) element, without success. Xerces2-J says > that the particle of the type is not a valid restriction of the > particle of the base, because there is not a complete functional > mapping between the particles. > > Base type: > > <xsd:complexType name="PayloadType"> > <xsd:sequence maxOccurs="unbounded"> > <xsd:any maxOccurs="unbounded"/> > </xsd:sequence> > </xsd:complexType> This specifies that an element of the type PayloadType must have at least one element child, whatever that element is (the minOccurs of both the sequence and the wildcard is 1). > Derived type: > > <xsd:complexType name="LabelType"> > <xsd:complexContent> > <xsd:restriction base="PayloadType"> > <xsd:sequence maxOccurs="unbounded"> > <xsd:element name="LabelGraphic" type="cct:GraphicType" > minOccurs="0" maxOccurs="unbounded"/> > <!-- other elements omitted --> > </xsd:sequence> > </xsd:restriction> > </xsd:complexContent> > <xsd:complexType> Without seeing the full content model, it's hard to be sure, but if this is the only element particle you might be running into problems because the LabelGraphic element is optional. You can't restrict from a type that must have an element to one that only *might* have an element. Even if you did have other elements there, this might still be the cause of the problem. The "complete functional mapping" means that you need to be able to restrict the xs:any wildcard to the element particle. This comes under [http://www.w3.org/TR/xmlschema-1/#rcase-NSCompat], which says: For an element declaration particle to be a ·valid restriction· of a wildcard particle all of the following must be true: 1 The element declaration's {target namespace} is ·valid· with respect to the wildcard's {namespace constraint} as defined by Wildcard allows Namespace Name (§3.10.4). 2 R's occurrence range is a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6). and the occurrence range of the element particle (0 - unbounded) is not a valid restriction of the occurrence range of the wildcard (1 - unbounded). > Am I missing something obvious? What I would like is to do type > substitution (without substitution groups) and have the base type > such that any kind of a restriction is a valid restriction. I would > like to substitute types that don't necessarily have anything in > common except that they restrict the generic PayloadType (which is > abstract) in some way. Is there a better way to do this than what I > am trying to do? Perhaps you can make the minOccurs of the xs:any wildcard 0 -- that makes the content model the same as that of xs:anyType, which should mean that you can restrict it to any content model you want. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Wednesday, 24 July 2002 17:49:13 UTC