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

Running the new schema test suite last week revealed a bug in this area:
 
http://sourceforge.net/tracker/index.php?func=detail
<http://sourceforge.net/tracker/index.php?func=detail&aid=1602527&group_id=2
9872&atid=397617> &aid=1602527&group_id=29872&atid=397617
 
I think this bug is fixed in the latest patch release
 
http://www.saxonica.com/download/patched/saxon-saj-8804.zip
 
However, this bug affects instance validation, whereas you seem to be
concerned only with which schemas are valid.
 
The case where Saxon differs from Xerces is that Saxon apparently allows an
attribute to be required on a derived type when it is prohibited on the
parent type. This clearly should not be allowed, so you seem to have found a
bug.
 
Michael Kay
http://www.saxonica.com/


  _____  

From: Wang, Zhuo [mailto:zhuo.wang@intel.com] 
Sent: 07 December 2006 02:42
To: Michael Kay; xmlschema-dev@w3.org
Cc: Moog, Thomas H; Wang, Zhuo
Subject: Different behavior between saxon and xerces-j on the attribute use
derivation mechanism



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 04:04:03 UTC