W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2002

Re: Schema for schemas bugs?

From: Eddie Robertsson <erobertsson@allette.com.au>
Date: Fri, 12 Apr 2002 12:46:44 +1000
Message-ID: <3CB64A94.6DAB50B3@allette.com.au>
To: Takuki Kamiya <takuki@pacbell.net>
CC: XSD <xmlschema-dev@w3.org>
Hi Takuki,

> Oops, you can find the schema for schema here.
>
> http://nagoya.apache.org/bugzilla/showattachment.cgi?attach_id=1039

Thanks for the schema.
I'm a bit surprised though that this works for you. When I tried this with
Xerces 2.0.1 I'm getting about 20 errors in the schema. Half of them are the
same errors as I had before (see my last email) but now I also get some new
errors. Most of these relate to "Unique Particle Attribution" violations. The
type definition for "attributeGroupRef" is one example:

 <!-- attributeGroupRef has been expanded. tkamiya 2001-08-07 -->
 <xs:complexType name="attributeGroupRef">
  <xs:complexContent>
   <xs:extension base="xs:annotated">
    <xs:sequence>
     <xs:element ref="xs:annotation" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="ref" use="required" type="xs:QName"/>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>

On this type I get the following error from Xerces:

"Schema problem: ("http://www.w3.org/2001/XMLSchema":annotation){0-1} and
("http://www.w3.org/2001/XMLSchema":annotation){0-1}(or elements from their
substitution group) violates "Unique Particle Attribution"".

I must agree with Xerces on this becuse the type created is indeed ambigous. The
base type xs:annotation is defined as:

 <xs:complexType name="annotated">
   <xs:complexContent>
     <xs:extension base="xs:openAttrs">
       <xs:sequence>
          <xs:element ref="xs:annotation" minOccurs="0"/>
       </xs:sequence>
       <xs:attribute name="id" type="xs:ID"/>
     </xs:extension>
   </xs:complexContent>
 </xs:complexType>

This means that the expanded "attributeGroupRef" type will be:

 <xs:complexType name="attributeGroupRef">
  <xs:sequence>
   <xs:sequence>
     <xs:element ref="xs:annotation" minOccurs="0"/>
    </xs:sequence>
    <xs:sequence>
      <xs:element ref="xs:annotation" minOccurs="0"/>
    </xs:sequence>
  </xs:sequence>
  <xs:attribute name="id" type="xs:ID"/>
  <xs:attribute name="ref" use="required" type="xs:QName"/>
 </xs:complexType>

Removal of the empty sequence groups will yield the following type definition:

 <xs:complexType name="attributeGroupRef">
  <xs:sequence>
   <xs:element ref="xs:annotation" minOccurs="0"/>
   <xs:element ref="xs:annotation" minOccurs="0"/>
  </xs:sequence>
  <xs:attribute name="id" type="xs:ID"/>
  <xs:attribute name="ref" use="required" type="xs:QName"/>
 </xs:complexType>

Clearly this type is ambigous because the parser can't tell which of the
xs:annotation elements to match.

I'm surprised that you get this to work with Xerces 2.0.0 but maybe they have
fixed this bug for version 2.0.1.

Cheers,
/Eddie



>
>
> -taki
>
> ----- Original Message -----
> From: "Takuki Kamiya" <takuki@pacbell.net>
> To: "Eddie Robertsson" <erobertsson@allette.com.au>; "XSD"
> <xmlschema-dev@w3.org>
> Sent: Thursday, April 11, 2002 6:22 PM
> Subject: Re: Schema for schemas bugs?
>
> > Hi,
> >
> > Interesting.
> >
> > I have a version of schema for schema that I have been using
> > in production system for quite some time, so you might want
> > to take a look for comparison. It works with xerces 1.4.3 and
> > 2.0.0.
> >
> > -taki
> >
> >
> > ----- Original Message -----
> > From: "Eddie Robertsson" <erobertsson@allette.com.au>
> > To: "XSD" <xmlschema-dev@w3.org>
> > Sent: Wednesday, April 10, 2002 1:02 AM
> > Subject: Schema for schemas bugs?
> >
> >
> > > Hi all,
> > >
> > > Since the schema at http://www.w3.org/2001/XMLSchema.xsd can't be used
> > > directly for validation I've rewritten it so that it now can be used to
> > > validate an XML Schema document. Most changes involved the removal of
> > > the type definitions for the built-in primitive datatypes but I also had
> > > to modify some of the complexTypes since they wouldn't pass validation.
> > > These complexTypes are:
> > >
> > > * complexRestrictionType AND simpleRestrictionType
> > > * groupRef AND attributeGroupRef
> > > * all
> > >
> > > Different validators give me different results so I'd appreciate your
> > > comments before reporting this as a bug in any of the validators.
> > >
> > > complexRestrictionType AND simpleRestrictionType
> > > -----------------------------------------------------
> > > Both these types are very similar so I'll illustrate with
> > > complexRestrictionType. The relevant types in the XMLSchema.xsd file
> > > are:
> > >
> > >  <xs:complexType name="openAttrs">
> > >   <xs:complexContent>
> > >    <xs:restriction base="xs:anyType">
> > >     <xs:anyAttribute namespace="##other" processContents="lax"/>
> > >    </xs:restriction>
> > >   </xs:complexContent>
> > >  </xs:complexType>
> > >
> > >  <xs:complexType name="annotated">
> > >   <xs:complexContent>
> > >    <xs:extension base="xs:openAttrs">
> > >     <xs:sequence>
> > >      <xs:element ref="xs:annotation" minOccurs="0"/>
> > >     </xs:sequence>
> > >     <xs:attribute name="id" type="xs:ID"/>
> > >    </xs:extension>
> > >   </xs:complexContent>
> > >  </xs:complexType>
> > >
> > >  <xs:complexType name="restrictionType">
> > >   <xs:complexContent>
> > >    <xs:extension base="xs:annotated">
> > >     <xs:sequence>
> > >      <xs:choice>
> > >       <xs:group ref="xs:typeDefParticle" minOccurs="0"/>
> > >       <xs:group ref="xs:simpleRestrictionModel" minOccurs="0"/>
> > >      </xs:choice>
> > >      <xs:group ref="xs:attrDecls"/>
> > >     </xs:sequence>
> > >     <xs:attribute name="base" type="xs:QName" use="required"/>
> > >    </xs:extension>
> > >   </xs:complexContent>
> > >  </xs:complexType>
> > >
> > >  <xs:complexType name="complexRestrictionType">
> > >   <xs:complexContent>
> > >    <xs:restriction base="xs:restrictionType">
> > >     <xs:sequence>
> > >      <xs:element ref="xs:annotation" minOccurs="0"/>
> > >      <xs:group ref="xs:typeDefParticle" minOccurs="0"/>
> > >      <xs:group ref="xs:attrDecls"/>
> > >     </xs:sequence>
> > >    </xs:restriction>
> > >   </xs:complexContent>
> > >  </xs:complexType>
> > >
> > > Most schema validators give me an error saying that the last derivation
> > > by restriction is not valid. However, it feels to me that this
> > > derivation step should be valid since the resolved xs:restrictionType
> > > would be:
> > >
> > >  <xs:complexType name="restrictionType_resolved">
> > >   <xs:sequence>
> > >    <xs:element ref="xs:annotation" minOccurs="0"/>
> > >    <xs:sequence>
> > >     <xs:choice>
> > >      <xs:group ref="xs:typeDefParticle" minOccurs="0"/>
> > >      <xs:group ref="xs:simpleRestrictionModel" minOccurs="0"/>
> > >     </xs:choice>
> > >     <xs:group ref="xs:attrDecls"/>
> > >    </xs:sequence>
> > >   </xs:sequence>
> > >   <xs:attribute name="base" type="xs:QName" use="required"/>
> > >   <xs:attribute name="id" type="xs:ID"/>
> > > </xs:complexType>
> > >
> > > It seems to me that xs:complexRestrictionType is a valid restriction of
> > > this type.
> > >
> > > groupRef AND attributeGroupRef
> > > -----------------------------------
> > > Again these two types are similar in their derivation chain so I'll use
> > > groupRef to illustrate. The relevant types are (+ annotated and
> > > openAttrs above):
> > >
> > >  <xs:complexType name="group" abstract="true">
> > >   <xs:complexContent>
> > >    <xs:extension base="xs:annotated">
> > >     <xs:group ref="xs:particle" minOccurs="0" maxOccurs="unbounded"/>
> > >     <xs:attributeGroup ref="xs:defRef"/>
> > >     <xs:attributeGroup ref="xs:occurs"/>
> > >    </xs:extension>
> > >   </xs:complexContent>
> > >  </xs:complexType>
> > >
> > >  <xs:complexType name="realGroup">
> > >   <xs:complexContent>
> > >    <xs:restriction base="xs:group">
> > >     <xs:sequence>
> > >      <xs:element ref="xs:annotation" minOccurs="0"/>
> > >      <xs:choice minOccurs="0" maxOccurs="1">
> > >       <xs:element ref="xs:all"/>
> > >       <xs:element ref="xs:choice"/>
> > >       <xs:element ref="xs:sequence"/>
> > >      </xs:choice>
> > >     </xs:sequence>
> > >    </xs:restriction>
> > >   </xs:complexContent>
> > >  </xs:complexType>
> > >
> > >  <xs:complexType name="groupRef">
> > >   <xs:complexContent>
> > >    <xs:restriction base="xs:realGroup">
> > >     <xs:sequence>
> > >      <xs:element ref="xs:annotation" minOccurs="0"/>
> > >     </xs:sequence>
> > >     <xs:attribute name="ref" use="required" type="xs:QName"/>
> > >     <xs:attribute name="name" use="prohibited"/>
> > >    </xs:restriction>
> > >   </xs:complexContent>
> > >  </xs:complexType>
> > >
> > > The situation is similar to the previous, some validators give an error
> > > in the last derivation step saying that groupRef is not a valid
> > > restriction of realGroup. Again I think that this restriction is fine.
> > >
> > > all
> > > ---
> > > All validators I've tried with give me an error on this derivation
> > > chain. The types involved are:
> > >
> > >  <xs:complexType name="explicitGroup">
> > >   <xs:complexContent>
> > >    <xs:restriction base="xs:group">
> > >     <xs:sequence>
> > >      <xs:element ref="xs:annotation" minOccurs="0"/>
> > >      <xs:group ref="xs:nestedParticle" minOccurs="0"
> > > maxOccurs="unbounded"/>
> > >     </xs:sequence>
> > >     <xs:attribute name="name" type="xs:NCName" use="prohibited"/>
> > >     <xs:attribute name="ref" type="xs:QName" use="prohibited"/>
> > >    </xs:restriction>
> > >   </xs:complexContent>
> > >  </xs:complexType>
> > >
> > >   <xs:complexType name="all">
> > >     <xs:complexContent>
> > >      <xs:restriction base="xs:explicitGroup">
> > >       <xs:group ref="xs:allModel"/>
> > >       <xs:attribute name="minOccurs" use="optional" default="1">
> > >        <xs:simpleType>
> > >         <xs:restriction base="xs:nonNegativeInteger">
> > >          <xs:enumeration value="0"/>
> > >          <xs:enumeration value="1"/>
> > >         </xs:restriction>
> > >        </xs:simpleType>
> > >       </xs:attribute>
> > >       <xs:attribute name="maxOccurs" use="optional" default="1">
> > >        <xs:simpleType>
> > >         <xs:restriction base="xs:allNNI">
> > >          <xs:enumeration value="1"/>
> > >         </xs:restriction>
> > >        </xs:simpleType>
> > >       </xs:attribute>
> > >      </xs:restriction>
> > >     </xs:complexContent>
> > >    </xs:complexType>
> > >
> > > In this case I agree with the validators since in the "all" complexType
> > > restriction the group xs:allModel is referenced without being declared
> > > in the the base type.
> > >
> > > I'd appreciate any comments you might have about this.
> > >
> > > Cheers,
> > > /Eddie
> > >
> > >
> > >
> > >
> > >
> >
Received on Thursday, 11 April 2002 22:31:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:30 GMT