Confusion about SimpleContent and SimpleType restrictions

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 UTC