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 Schemas: 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