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

Re: XML Schemas: Best Practices

  • From: "Roger L. Costello" <costello@m...>
  • To: xml-dev@l...
  • Date: Thu, 11 Jan 2001 16:59:49 -0500

xml schema best practices
Hi Folks,

Here is the next issue that I would like to take up on XML Schema
Best Practices.

Issue: Public versus Private Schemas - When should a schema be made 
publicly accessible versus when should it be kept private?  Are
there guidelines on what should be in a public schema?

I would like to kick off this discussion with some thoughts
that I have on this topic: I think that as a quick and dirty
general rule types (complexTypes and simpleTypes) should go in 
public schemas and global element declarations should go in private 
schemas.

Example.  Consider these schema components:

    <complexType name="PublicationType" abstract="true">
        <sequence>
            <element name="Title" type="string"/>
            <element name="Author" type="string" maxOccurs="unbounded"/>
            <element name="Date" type="year"/>
        </sequence>
    </complexType>
    <complexType name="BookType">
        <complexContent>
            <extension base="c:PublicationType" >
                <sequence>
                    <element name="ISBN" type="string"/>
                    <element name="Publisher" type="string"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <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>
    <element name="Catalogue">
        <complexType>
            <sequence>
                <element name="Publication" type="c:PublicationType" 
                         minOccurs="0" maxOccurs="unbounded"/>
            </sequence>
        </complexType>
    </element>

There are 3 type definitions - Publication, BookType, and MagazineType.
There is one global element declaration - Catalogue.

As a first pass, I would put the 3 type definitions into a schema and
make that schema publicly accessible.  I would put the global element
declaration into a second, private schema. 

Here's my reasoning for this method of partitioning schema components
into public versus private schemas:

- Types are by definition reusable components.  So, immediately I
  think "public".

- Element declarations get instantiated in instance documents.  They
  are domain specific components, i.e., not general purpose.  So,
  immediately I think "private".

Okay, those are some of my quick, probably-not-well-thought-out 
thoughts on this topic.  What are your thoughts? Can you think of a 
more refined methodology for partitioning components among public
versus private schemas?  What is your decision process for deciding
if a component should be made publicly accessible?  What is your
definition of a "Public Schema"?  What is your definition of a 
"Private Schema"?

My hope is that we can have broader participation in discussing this
issue.  These Best Practices are to be a "collective effort", so now
is your chance to voice your thoughts.  /Roger


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.