[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Help regarding an XML attribute.

  • From: Priscilla Walmsley <priscilla@w...>
  • To: 'Eddie Robertsson' <eddie@a...>,'Vance Christiaanse' <cintech@t...>
  • Date: Tue, 16 Oct 2001 09:11:31 -0400

xml attribute name
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:sequence>
    <xs:element name="child"/>
  </xs:sequence>
  <xs:attribute name="attr1" type="xs:integer"/>
</xs:complexType>

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

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

Hope that helps,
Priscilla

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



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.