This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 6194 - Attribute wildcard union and intersection examples
Summary: Attribute wildcard union and intersection examples
Status: NEW
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Primer: XSD Part 0 (show other bugs)
Version: 1.1 only
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: David Ezell
QA Contact: XML Schema comments list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-31 00:13 UTC by Sandy Gao
Modified: 2008-10-31 00:13 UTC (History)
0 users

See Also:


Attachments

Description Sandy Gao 2008-10-31 00:13:48 UTC
During the 2008-10 F2F meeting, the WG discussed situations when attribute wildcards are unioned and intersected.

Union is used when complex types are derived via extension; intersection is used when multiple attribute wildcards are specified (explicitly, via attribute group reference, or via defaulted attribute group).

We concluded that sometimes union gives the expected behavior, and sometimes intersection. Examples should be added to the primer to highlight these situations to help user choose between explicit specification and extension.

Example1:

<xs:schema>
   <xs:attributeGroup name="c1">
     <xs:anyAttribute namespace="ns1"/>
   </xs:attributeGroup>
   <xs:attributeGroup name="c2">
     <xs:anyAttribute namespace="ns2"/>
   </xs:attributeGroup>

   <xs:complexType name="foo">
     <xs:attributeGroup ref="c1"/>
     <xs:attributeGroup ref="c2"/>
   </xs:complexType>
</xs:schema>

In this case, intersection is used, and the result is a wildcard that allows nothing. Complex type extension should be used in this case:

<xs:schema>
   <xs:attributeGroup name="c1">
     <xs:anyAttribute namespace="ns1"/>
   </xs:attributeGroup>
   <xs:complexType name="fooBase">
     <xs:attributeGroup ref="c1"/>
   </xs:complexType>

   <xs:attributeGroup name="c2">
     <xs:anyAttribute namespace="ns2"/>
   </xs:attributeGroup>
   <xs:complexType name="foo">
     <xs:complexContent>
       <xs:extension base="fooBase">
         <xs:attributeGroup ref="c2"/>
       </xs:extension>
     </xs:complexType>
   </xs:complexType>
</xs:schema>

Example 2:

<xs:schema tns="v1">
   <xs:attributeGroup name="c1">
     <xs:anyAttribute namespace="##other"/>
   </xs:attributeGroup>

   <xs:complexType name="foo">
     <xs:attributeGroup ref="c1"/>
   </xs:complexType>
</xs:schema>

<xs:schema tns="v2">
   <xs:attributeGroup name="c2">
     <xs:anyAttribute namespace="##other"/>
   </xs:attributeGroup>

   <xs:complexType name="foo">
     <xs:complexContent>
       <xs:extension base="v1:foo">
         <xs:attributeGroup ref="c2"/>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
</xs:schema>

This gives you union, which allows all qualified names. This may not be what's expected (names in neither "v1" nor "v2"). In this case, intersection is the correct behavior. That is, v2 reads:

   <xs:complexType name="foo">
     <xs:attributeGroup ref="v1:c1"/>
     <xs:attributeGroup ref="c2"/>
   </xs:complexType>