Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - >Thread Next - RE: Different behavior between saxon and xerces-j on the attribute use derivation mechanism Different behavior between saxon and xerces-j on the attribute use derivation mechanismTo: "Michael Kay" <mike@--------.--->, <xmlschema-dev@--.---> Date: 12/7/2006 6:42:00 PM 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.
~~~~~~~~~~~~~~~~~~~~~~~~
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
