(unknown charset) Re: another restriction question

Hi Jeni,

On Wed, 24 Jul 2002, Jeni Tennison wrote:

>
> 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).
>

This was an oversight and should have been minOccurs="0".  Having changed
this, it still doesn't work.  I also tried setting the namespace for
xsd:any to ##any, but that also doesn't make a difference.

> > 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.
>

The full definition for the LabelType is:

<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"/>
        <xsd:element name="LabelURI" type="xsd:anyURI" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element name="LabelHTML" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:restriction>
  </xsd:complexContent>
</xsd:complexType>

And PayloadType, for the sake of completeness, is:

<xsd:complexType name="PayloadType" abstract="true">
  <xsd:sequence minOccurs="0" maxOccurs="unbounded">
    <xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
  </xsd:sequence>
</xsd:complexType>

> 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).

With the occurrence range of the wildcard now set to 0 - unbounded and the
namespace constraint set to ##any, it seems that it satisfies all the
requirements, but it still fails.

thanks,

calvin

Received on Wednesday, 24 July 2002 18:12:20 UTC