[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Interaction of explicit attributes and wildcards

From: Pete Cordell <petexmldev@tech-know-ware.com>
Date: Wed, 24 Jan 2007 12:16:47 -0000
Message-ID: <000701c73fb1$8765de70$8f00a8c0@Codalogic>
To: "srinivasarao vegunta" <mukalsin@lycos.com>, <xmlschema-dev@w3.org>
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 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.