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

Confusion about SimpleContent and SimpleType restrictions

From: Niko Suave <niko@alum.mit.edu>
Date: Fri, 7 Dec 2001 12:41:22 -0500 (EST)
To: xmlschema-dev@w3.org
Message-ID: <Pine.LNX.4.21.0112071217370.16573-100000@sub-zero.mit.edu>
I don't understand why simple restrictions (both simpleType and simpleContent)
allow a "simpleType" to be specified within them.

i.e., simpleContent looks like this:

  base = QName
  id = ID
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (simpleType?, <facets>*)?, 
                         ((attribute | attributeGroup)*, anyAttribute?))

So if I do something like this:

<xs:complexType name="base">
    <xs:extension base="xs:string">
      <xs:attribute name="x" type="xs:decimal"/>
<xs:complexType name="extended">
    <xs:restriction base="base">
      <xs:simpleType name="embedded">
        <xs:restriction base="xs:decimal">
          <xs:totalDigits value="2"/>
          <xs:fractionDigits value="2"/>
      <xs:fractionDigits value="1"/>

is this valid?  what does this mean?  It's clear from the spec that
the Base Type for "extended" is still formally the complex type "base" 
that I defined earlier.  However, the content model is based purely on the 
"embedded" simple type, which I suppose must still be a valid restriction of 
the formal base type.

Based on this, I'd say this particular example is invalid b/c the "embedded"
simple type is a xs:decimal, which is not a restriction of the simple type
of "base" (xs:string), right?  If I changed the embedded simpleType to be a 
restriction of string and likewise changed the facets to other things, 
would it then be valid?  So why include this embedded simpleType at all, 
since essentially it just lets me add another layer of facets?

I must be missing something.

Received on Friday, 7 December 2001 12:36:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:56 UTC