OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Complex type inheritance is evil!



Title: RE: Complex type inheritance is evil!

 Yep, I'd played around with that and it solved the problem. However, as I posted on the W3C list to HT's answer, it leaves a very clear inconsistency:

If I try restricting the following:

<xsd:complexType name="Items">
  <xsd:sequence>
   <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="productName" type="xsd:string"/>
      <xsd:element name="quantity">
       <xsd:simpleType>
        <xsd:restriction base="xsd:positiveInteger">
         <xsd:maxExclusive value="100"/>
        </xsd:restriction>
       </xsd:simpleType>
      </xsd:element>
      <xsd:element name="USPrice"  type="xsd:decimal"/>
      <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
  </xsd:sequence>
  <xsd:attribute name="shipBy">
   <xsd:simpleType>
    <xsd:restriction base="xsd:string">
     <xsd:enumeration value="air"/>
     <xsd:enumeration value="land"/>
     <xsd:enumeration value="any"/>
    </xsd:restriction>
   </xsd:simpleType>
  </xsd:attribute>
</xsd:complexType>

the restriction of the anonymous simple type for the element "quantity" is acceptable, but the restriction of the anonymous simple type for the attribute "shipBy" is not. Maybe this is just a misinterpretation in Xerces, but if it is intended to be allowed then what is the rationale for treating anonymous types of elements differently from anonymous types of attributes?

In any case, I can't help agree somewhat. If we all agree not to use them, perhaps restrictions will just go away (although I have to say, if you can manage it intelligently, both extension and restriction have some application in design in combination with the use of abstract types)

John



-----Original Message-----
From: K.Kawaguchi
To: xml-dev@lists.xml.org
Cc: Eddie Robertsson; Anderson, John
Sent: 06/06/2001 22:06
Subject: Complex type inheritance is evil!


> My question:
> Is this an error in the Primer or in the validator? Or am I missing
some
> arcane point about restrictions?

I think the latter is the case.

I believe the problem is the anonymous simple type definition.

You are using an anonymous type:

                    <xsd:simpleType>
                        <xsd:restriction base="positiveInteger">
                            <xsd:maxExclusive value="100"/>
                        </xsd:restriction>
                    </xsd:simpleType>

Although the spec is unclear about this, but in practice two
independently derived simple types are considered different, even if
they are derived in exactly the same way.

It is very hard for validators to consider them as equal. Imagine a
simple type who has tons of facets!


Things like this is just the tip of iceberg. So I'd suggest not to use
extension/restriction at all. As I advocate in my "DOs and DON'Ts".

http://www.geocities.com/kohsukekawaguchi/XMLSchemaDOsAndDONTs.html


Or if you really need to use restriction, then I think you can avoid the
problem by getting rid of anonymous datatypes.

                    <xsd:simpleType name="upto100integer">
                        <xsd:restriction base="positiveInteger">
                            <xsd:maxExclusive value="100"/>
                        </xsd:restriction>
                    </xsd:simpleType>

regards,
----------------------
K.Kawaguchi
E-Mail: kohsukekawaguchi@yahoo.com