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

Re: XML Schemas: Best Practices

  • From: Eddie Robertsson <eddie@a...>
  • To: "Roger L. Costello" <costello@m...>
  • Date: Mon, 08 Jan 2001 17:20:52 +1100

xml best practices derive extension
> PublicationType - the base type:
>
>     <complexType name="PublicationType">
>         <sequence>
>             <element name="Title" type="string"/>
>             <element name="Author" type="string" maxOccurs="unbounded"/>
>             <element name="Date" type="year"/>
>         </sequence>
>     </complexType>
>
> BookType - extends PublicationType by adding two new elements, ISBN
> and Publisher:
>
>     <complexType name="BookType">
>         <complexContent>
>             <extension base="c:PublicationType" >
>                 <sequence>
>                     <element name="ISBN" type="string"/>
>                     <element name="Publisher" type="string"/>
>                 </sequence>
>             </extension>
>         </complexContent>
>     </complexType>
>
> MagazineType - restricts PublicationType by dropping the Author
> element:
>
>     <complexType name="MagazineType">
>         <complexContent>
>             <restriction base="c:PublicationType">
>                 <sequence>
>                     <element name="Title" type="string"/>
>                     <element name="Author" type="string"
>                              minOccurs="0" maxOccurs="0"/>
>                     <element name="Date" type="year"/>
>                 </sequence>
>             </restriction>
>         </complexContent>
>     </complexType>
>
> - Oftentimes the variable content section will contain elements that
>   are conceptually related but structurally vastly different. The base
>   type (the abstract element's type) should contain items common to all
>   the variable content elements.  To allow for elements that may be
>   very dissimilar the base type would need to have very little
>   structure. This defeats the purpose of inheritance.
>
> Question:
>
> - In the second disadvantage above I state: "This defeats the purpose
>   of inheritance."  This seems like a very weak statement.  Can you
>   provide a stronger statement telling why it is bad that the base
>   type has little structure?

I agree with Roger here. Sometimes the base type will have very little
structure but that doesn't mean you can't use extension if that suit your
purpose. I think it's better to have a small base type instead of having to
use the restriction functionality but maybe that's just me not being used to
derivation by restriction. I'm still very new to XSD and I haven't made up
my mind about restriction yet.
For example, in the above example I would much rather see that the Author
element is removed from the base type and then added in the BookType.

/Eddie


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.