Re: simpleContent and restriction

Michael Anderson wrote:

> Arnaud Blandin wrote:
>
> > Hi,
> >
> > I have a basic question and I can't find an answer in the XML Schema Specs
> > nor in the the list archive:
> >
> > given the following
> >
> > <complexType>
> >         <simpleContent>
> >                 <restriction base="type">
> >                         <attribute name="foo2" type="something"/>
> >                 </restriction>
> >         </simpleContent>
> > </complexType>
> >
> > <complexType name="type">
> >         <simpleContent>
> >                 <extension base="string">
> >                         <attribute name="foo" type="somethingelse"/>
> >                 </extension>
> >         </simpleContent>
> > </complexType>
> >
> > this seems to be allowed and I don't think it should be because
> > the first 'restriction' acts as an 'extension'.
> > I am sure I am missing something, could you please help me?
> >
> > Thanks
> > Arnaud
>
> Try looking in 4.3.3 of Structures.  The {content type} property of a "Complex
> Type Definition with simple content Schema Component" talks about a simple
> content that restricts a complex Type that also has a simpleContent.  IMO,
> clause 1 says you can only restrict the facets that are among the facets of
> the restricted type, thus not allowing you to add an attribute.
> Hope this helps a bit,
> mick.

Oops, this is misleading.  While a restriction does not allow you _add_a_new_
attribute as I mentioned, section 4.3.3 doesn't specifically deal with this
issue.  To clarify the misleading part, you _are_ still allowed to have a
attribute declarations in your restriction, but they _must_ match all attribute
declarations in your base type.  Each repeated attribute must have a type that is
validly derived from the original attribute. This is mentioned in 1.1 -> 1.3 in
[1].  So your example will only be OK if foo2 is rewritten as foo and the type
"something" is validly derived from "somethingElse".  Ie, the following is now O
(though probably not what you wanted)

<complexType>
         <simpleContent>
                 <restriction base="type">
                         <attribute name="foo" type="something"/>
                 </restriction>
         </simpleContent>
 </complexType>

 <complexType name="type">
         <simpleContent>
                 <extension base="string">
                         <attribute name="foo" type="somethingelse"/>
                 </extension>
         </simpleContent>
 </complexType>

<simpleType name="something">
  <restriction base="somethingelse">
    <length value="10"/>
  </restriction>
</simpleType>

mick.

[1] http://www.w3.org/TR/xmlschema-1/#derivation-ok-restriction

Received on Wednesday, 31 January 2001 20:04:03 UTC