OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [xml-dev] Help regarding an XML attribute.

Hi Eddie,

You are correct.  This schema is invalid, both for the reason you describe,
and also because any attribute that exists in a restriction must be an
attribute of the base type.

> > <xs:element name="myOuter">
> >    <xs:complexType>
> >       <xs:complexContent>
> >          <xs:restriction base="xs:string">
> >             <xs:attribute name="color" type="xs:string"/>
> >          </xs:restriction>
> >       </xs:complexContent>
> >    </xs:complexType>
> > </xs:element>

Adding an attribute is always considered an extension.  The only time you
would declare an attribute in a restriction would be to restrict an
attribute that is already part of the base type.  This might be to restrict
the attribute's type, to make it required instead of optional, or to add a
default or fixed value.  A valid example:

<xs:complexType name="base">
    <xs:element name="child"/>
  <xs:attribute name="attr1" type="xs:integer"/>

<xs:complexType name="derived">
    <xs:restriction base="base">
      <xs:attribute name="attr1" type="xs:short" use="required"

In the other example, xs:string does not already have a "color" attribute,
so it is not valid.

Hope that helps,

Priscilla Walmsley                   priscilla@walmsley.com
Vitria Technology                     http://www.vitria.com
Author, Definitive XML Schema    (Prentice Hall, Dec. 2001)