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:

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


So if I do something like this:

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

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.


thanks,
niko
Received on Friday, 7 December 2001 12:36:44 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:25 GMT