W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2006

Different behavior between saxon and xerces-j on the attribute use derivation mechanism

From: Wang, Zhuo <zhuo.wang@intel.com>
Date: Thu, 7 Dec 2006 10:41:34 +0800
Message-ID: <7B2CABB47D5B094AAACC8A1E001B82F5227FE8@pdsmsx411.ccr.corp.intel.com>
To: "Michael Kay" <mike@saxonica.com>, <xmlschema-dev@w3.org>
Cc: "Moog, Thomas H" <thomas.h.moog@intel.com>, "Wang, Zhuo" <zhuo.wang@intel.com>
Hi Mike,  

 

I'm ambiguous about the attribute use derivation mechanism according

to the schema spec one. 

 

>From spec we know that the attribute use include "required" and
"optional",

all the attribute not give out the use will be treat as "optional". But 

I don't know what "prohibited" will do. So, I write the following cases:


 

Case 1:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">

        <xs:complexType name="One">

                <xs:sequence>

                        <xs:element name="elem1" minOccurs="0"/>

                        <xs:element name="elem2" minOccurs="0" />

                </xs:sequence>

                <xs:attribute name="att1" use="prohibited"/>

                <xs:attribute name="att2" use="prohibited"/>

                <xs:attribute name="att3" use="prohibited"/>

        </xs:complexType>

        <xs:complexType name="Two">

                <xs:complexContent>

                        <xs:restriction base="One">

                                <xs:attribute name="att1"
use="prohibited"/>

                                <xs:attribute name="att2"
use="required"/>

                                <xs:attribute name="att3"
use="optional"/>

                        </xs:restriction>

                </xs:complexContent>

        </xs:complexType>

</xs:schema>

 

Case 2:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">

        <xs:complexType name="One">

                <xs:sequence>

                        <xs:element name="elem1" minOccurs="0"/>

                        <xs:element name="elem2" minOccurs="0" />

                </xs:sequence>

                <xs:attribute name="att1" use="optional"/>

                <xs:attribute name="att2" use="optional"/>

                <xs:attribute name="att3" use="optional"/>

        </xs:complexType>

        <xs:complexType name="Two">

                <xs:complexContent>

                        <xs:restriction base="One">

                                <xs:attribute name="att1"
use="prohibited"/>

                                <xs:attribute name="att2"
use="required"/>

                                <xs:attribute name="att3"
use="optional"/>

                        </xs:restriction>

                </xs:complexContent>

        </xs:complexType>

</xs:schema>

 

Case 3: 

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">

        <xs:complexType name="One">

                <xs:sequence>

                        <xs:element name="elem1" minOccurs="0"/>

                        <xs:element name="elem2" minOccurs="0" />

                </xs:sequence>

                <xs:attribute name="att1" use="required"/>

                <xs:attribute name="att2" use="required"/>

                <xs:attribute name="att3" use="required"/>

        </xs:complexType>

        <xs:complexType name="Two">

                <xs:complexContent>

                        <xs:restriction base="One">

                                <xs:attribute name="att1"
use="required"/>

                                <xs:attribute name="att2"
use="prohibited"/>

                                <xs:attribute name="att3"
use="optional"/>

                        </xs:restriction>

                </xs:complexContent>

        </xs:complexType>

</xs:schema>

 

The case1 and case2 pass the saxon validation but case3 failed. 

 

I also use xerces to validate the cases:

For case1, xerces-j failed. It only allows the prohibited to prohibited.


For case2, it pass.

For case3, it failed. It only allows required to required. 

 

I then try all kind of situation as following:

 

(1)     The xerces result:

Base type:  Sub type extension derivate from a base type directly 

 

extension                                             to opt       to
req       to prohibited

========================================================================
=======================

Base Type Attribute Use Original value = optional      ok             no
ok

Base Type Attribute Use Original value = required      no             ok
ok

Base Type Attribute Use Original value = prohibited    no             no
ok

 

Base type:  Sub type restriction derivate from a base type directly

 

restriction                           to opt       to req       to
prohibited

========================================================================
======

Original value = optional              ok             ok          ok

Original value = required              no             ok          no

Original value = prohibited            no             no          ok

 

 

Restriction: Sub type extension derivate from a restriction type 

 

extension                             to opt       to req      to
prohibited

========================================================================
====

Original value = optional              ok           no          ok

Original value = required              no           ok          ok

Original value = prohibited            ok           ok          ok

 

                                                        Restriction: Sub
type restriction derivate from a restriction type

 

restriction                           to opt       to req     to
prohibited

========================================================================
====

Original value = optional              ok           ok          ok

Original value = required              no           ok          no

Original value = prohibited            no           no          ok

 

(2)     The saxon result: 

 

Directly from base type: 

 

extension            opt          req       prohibited

==========================================================

optional              ok           no          no

required              no           ok          no

prohibited            no           no          ok

 

restriction          opt          req       prohibited

==========================================================

optional              ok           ok          ok

required              no           ok          no

prohibited            ok           ok          ok

 

Derivate from restriction:

 

extension            opt          req       prohibited

==========================================================

optional              ok           no          no

required              no           ok          no

prohibited            ok           ok          ok

 

restriction          opt          req       prohibited

==========================================================

optional              ok           ok          ok

required              no           ok          no

prohibited            no           no          no

 

I can't get the confirmative answer from the result, xeces2-8-1-j and
saxonsa8-8j's

behavior is much different. 

 

What exact answer about the matrix as above? I just want to make clear

the rules about the attribute use derivation between base and sub types.


 

Can you give me some suggestion about this? 

 

Thanks and Regards,

-Wang Zhuo

~~~~~~~~~~~~~~~~~~~~~~~~

Intel Asia-Pacific R&D Ltd.

~~~~~~~~~~~~~~~~~~~~~~~~

 
Received on Thursday, 7 December 2006 14:42:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:56 GMT