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 10:43:46 UTC