|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XML Schemas: Best Practices
> 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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








