Re: Confusion about SimpleContent and SimpleType restrictions

> Within simpleType, restriction is used to define the base type from
> which the derived type is a restriction. You can *either* specify the
> base attribute *or* specify the simpleType element child, not both.
> Using an anonymous nested simpleType is handy if you want to restrict
> a list or union in some way, but don't want to create the list or
> union as a type on its own. It can also be handy for the same reason
> if you want to do the restriction from the base type in two steps,
> which sometimes happens when both steps involve restricting using
> simple but complex-to-combine regular expression patterns.

I see, this is what I had assumed, but I looked at the Schema for Schema
and thought that I had found a contrary result.  However, upon further
examination, I realize that I was getting confused because simpleTypes
are declared in the datatype schemas, and it is indeed as you say.  That
makes more sense to me.

> As I understand it, the point is to allow you to derive complex types
> with simple content from mixed complex types (with complex content).
> So you can have:
> 
> <xs:complexType name="base" mixed="yes">
>   <xs:sequence>
>     <xs:element name="ele" minOccurs="0" />
>   </xs:sequence>
> </xs:complexType>
> 
> <xs:complexType name="derived">
>   <xs:simpleContent>
>     <xs:restriction base="base">
>       <xs:simpleType>
>         <xs:restriction base="xs:decimal">
>           <xs:totalDigits value="2"/>
>           <xs:fractionDigits value="2"/>
>         </xs:restriction>
>       </xs:simpleType>
>     </xs:restriction>
>   </xs:simpleContent>
> </xs:complexType>
> 
> The base type allows an 'ele' element amongst the text, whereas the
> derived type doesn't allow any element content, *and* ensures that
> the content has to be a decimal number of the type specified.
> 
> It's debatable whether this is actually compliant with the Rec - see
> http://lists.w3.org/Archives/Public/xmlschema-dev/2001Oct/0174.html
> and the preceding thread for a previous discussion on this topic.

My first thought was that perhaps you would use this to restrict a
mixed content type, but it does seem to be in violation of the spec, as 
I see you and others have pointed out in this previous thread.  My apologies 
for not locating that before I asked this question, I should have known it 
would have come up before!  I just haven't had much luck searching the
archives the previous few times I tried.


thanks a bunch,
niko

Received on Friday, 7 December 2001 13:31:42 UTC