[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Really Understood W3C Schema Complex Types?
- From: Kohsuke KAWAGUCHI <kohsukekawaguchi@yahoo.com>
- To: Jeff Rafter <jeffrafter@defined.net>, xml-dev@lists.xml.org
- Date: Tue, 04 Sep 2001 12:06:29 -0700
> > First question. How many of the schema authors know this side effect when
> > s/he innocently writes this type hierarchy? I personally saw these kind
> > of mistakes made by relatively experienced schema authors.
>
> Good question, probably not many-- it is outlined in the best practices doc
> and the faq I believe (along with it being demonstrated in the primer)-- but
> it is still not widely acknowledged.
When reading the primer, one understands that the complex type is
substitutable but I guess it's easy to forget it once s/he starts writing
a schema.
> That is why it is probably good practice to utilize the final attribute on
> your complexTypes.
Yes, or may utilize the block attribute (or finalDefault/blockDefault
attributes)
> How is this an example of fragility? If anything it is an example that you
> cannot do *everything* with XML Schemas... rightly so. Your first example
I don't want to say that "hey, you can't do this in XML Schema". If I
sound like so, it's my bad. I'm just trying to defend my claim that
learning W3C XML Schema is not easy.
In this particular "type fragility" topic, I wanted to demonstrate that
sometimes you can't write restriction even if it's a true restriction,
and once it happens, the result is bizarre (because the type hierarchy
will break.)
But apparently there was a problem in my example. "repeating.derived"
should be derived from "repeating" by restriction (not from "annotation".)
<xs:complexType name="repeating">
<xs:complexContent>
<xs:extension base="annotated">
<xs:group ref="list.class" minOccurs="0" maxOccurs="unbounded"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="repeating.derived">
<xs:complexContent>
<xs:restriction base="repeating">
....
<xs:element ref="A"/>
<xs:group ref="list.class" minOccurs="0" maxOccurs="unbounded"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
> As far as I can tell it doesn't seem that "repeating.derived" is in any
> sense of the word a 'restriction' of "repeating" or "annotated". It should
I think it is fair to claim that "repeating.derived" is conceptually a
restriction of "repeating" because if something is valid wrt
"repeating.derived", it is always valid wrt the "repeating" type.
Or am I missing something?
> > (By the way, one of the horrible fact is that the author used a schema
> > editor to produce this schema and still he couldn't detect this error.)
>
> That is a problem-- but new versions are being created all of the time...
> but this shouldn't be counted against the concept of complexTypes, right?
I thought it's an incident that reveals the difficulty of correctly
enforcing the restriction-ok constraint.
regards,
----------------------
K.Kawaguchi
E-Mail: kohsukekawaguchi@yahoo.com