W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2008

RE: anyAttribute via attributeGroup refs problem

From: Michael Kay <mike@saxonica.com>
Date: Tue, 11 Nov 2008 11:09:52 -0000
To: "'Christian Roth'" <roth@visualclick.de>, "'XML Schema Development List'" <xmlschema-dev@w3.org>
Message-ID: <F07A93D7F95A4F4ABFA532959E0B1513@Sealion>

There is a very surprising rule here: when you reference two attribute
groups and they both contain attribute wildcards, you get the intersection
of the wildcards, not the union as you might expect. In this case of course
the intersection is empty.

As it happens the WG debated changing this rule (at some length) a couple of
weeks ago, and decided to make no change - partly for backwards
compatibility reasons, partly because someone thinks there are use cases
where it makes sense to take the intersection, partly because you can get
the union if you want it by defining two types, one of which extends the
other (when type T extends type S, the attribute wildcard is the union of
those defined on T and S).

Michael Kay

> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Christian Roth
> Sent: 11 November 2008 10:43
> To: XML Schema Development List
> Subject: anyAttribute via attributeGroup refs problem
> Hello,
> during schema development, I stumbled upon the following 
> issue with anyAttribute elements included via an 
> attributeGroup reference into a
> complexType:
> -- instance.xml --
> <root
>   xsi:noNamespaceSchemaLocation="schema.xsd"
>   xmlns:ns1="ns1"
>   xmlns:ns2="ns2"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   ns1:attr="val1" 
>   ns2:attr="val2"
> />
> -- schema.xsd --
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>   <xs:element name="root">
>     <xs:complexType>
>       <xs:attributeGroup ref="ns1-atts"/>
>       <xs:attributeGroup ref="ns2-atts"/>
>     </xs:complexType>
>   </xs:element>
>   <xs:attributeGroup name="ns1-atts">
>       <xs:anyAttribute namespace="ns1" processContents="skip"/>
>   </xs:attributeGroup>
>   <xs:attributeGroup name="ns2-atts">
>       <xs:anyAttribute namespace="ns2" processContents="skip"/>
>   </xs:attributeGroup>
> </xs:schema>
> I expected the given schema to validate the instance 
> document, however I am presented with the following validation errors:
> [Xerces] cvc-complex-type.3.2.2: Attribute 'ns1:attr' is not 
> allowed to appear in element 'root'.
> [Xerces] cvc-complex-type.3.2.2: Attribute 'ns2:attr' is not 
> allowed to appear in element 'root'.
> In my understanding, both of them are allowed via the 
> anyAttribute element allowing all attributes in the 
> respective namespace name via wildcard.
> When I comment out *one* of the attributeGroup references in 
> the "root"
> element's content model, the remaining namespace's attribute 
> is no longer reported as an error, just the namespace's 
> attribute that has been commented out (as expected).
> Is this a problem with my schema file (and if so, why does it 
> validate both standalone and when performing the actual 
> validation on an
> instance) or a bug in the validator? I have tried Xerces and 
> SaxonSA, both with identical behaviour.
> Regards,
> Christian
Received on Tuesday, 11 November 2008 11:10:32 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:48 UTC