Re: Interaction of explicit attributes and wildcards

Original Message From: "srinivasarao vegunta" <mukalsin@lycos.com>
>      According to several schema processors, (Saxon, Xerces, MS .NET), the
>      following instance:
>
>      <e att1="banana"/>
>
>      is valid against the following schema:
>
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>      elementFormDefault="qualified" attributeFormDefault="unqualified">
>
>      <xs:complexType name="B">
>      <xs:sequence/>
>      <xs:attribute name="att1" use="optional" type="xs:decimal"/>
>      <xs:anyAttribute namespace="##local"
>      processContents="skip"/>
>      </xs:complexType>
>
>      <xs:complexType name="R">
>      <xs:complexContent>
>      <xs:restriction base="B">
>      <xs:attribute name="att1" use="prohibited"/>
>      <xs:anyAttribute namespace="##local"
>      processContents="skip"/>
>      </xs:restriction>
>      </xs:complexContent>
>      </xs:complexType>
>
>      <xs:element name="e" type="R"/>
>      </xs:schema>
>
>      But change the element declaration to <xs:element name="e" 
> type="B"/>, and
>      validation fails, saying that "banana" is not a valid xs:decimal (the 
> same
>      set of schema processors agree on this).
>
>      Surely the element cannot be a valid instance of R unless it is also 
> a valid
>      instance of B?

>From memory, the terminology in the spec for an attribute with 
use="prohibited" is to say that the declaration should be treated as if it 
does not exist.  So there is effectively no mention of the attribute att1 in 
type R, rather than a statement that att1 must not exist.  As a result, the 
xs:anyAttribute is picking up the occurrence of att1 when e is of type R.

When handling complex type restriction, the rules for attributes are 
different to the rules for elements.  For example, if you removed the att1 
definition in type R, your first example would become invalid.  This is 
because attributes in the base type are referred to if they are not 
mentioned in the derived type.  This arrangement does not mirror how 
elements are handled.

HTH,

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================

Received on Wednesday, 24 January 2007 12:17:10 UTC