IBM ShopIBM Support Download
HomeNewsProductsservicesSolutionsAbout IBM
Search 
IBM : developerWorks : XML : Library - papers

The XML Schema standard
A way to make XML datatype definitions more specific and flexible


George Lawton
Freelance technical writer
September 1999

     

Contents:
 Document Type
 Definition
 Datatypes and structures
 Combining elements
 Comments in context
 Conformance
 Status
 Resources
 About the author

The Schema standard-in-progress goes Document Type Definitions one better and gives you ways to define datatypes explicitly, to combine them in data structures, and to associate comments with datatypes. If, as Ashok Malhotra says, XML is the glue for mapping between databases and other data models, then Schema is the tool for spreading the glue exactly where you want it.

XML Schemas promise to greatly simplify the ability to integrate databases with a wide variety of other applications. The forthcoming Schema standard, now in draft form, will better define the datatypes and structure needed to create interoperable applications.

Two working groups are together developing the standard for the World Wide Web Consortium (W3) to provide the industry with the tools to ensure a smooth flow of data from application to application.

To date, the Schema standard draft includes datatype definitions, structures that combine datatypes, a standard for comments, and a conformance proposal.

The most obvious use for XML is to permit exchange of data from database to database and between databases and other applications; Schema standards are designed to make that work easier. Ashok Malhotra, Research Staff Member at IBM, and a representative on the Schema Working Group said, "I think the real issue is for connecting to databases, and that is how Schemas will evolve. People are starting to think of XML as a universal glue for mapping between databases and alternative representations of things."

Beyond the Document Type Definition
The XML Document Type Definition (DTD) tells the recipient of a document what to expect in the document, in a machine-readable form. The labeling and definitions make it possible for editing tools to look in XML documents for specific data elements, and they can prompt a user to input mandatory information into a document, such as "Please input the customer name to continue." Schema structures go several steps farther than the DTD.

One of the limitations of a DTD is that because it is not itself in the form of an XML document, it does not benefit from basic XML features, such as the ability to create styles and use search mechanisms on the documents. Noah Mendelsohn, Consulting Engineer at Lotus Development, said, "If we just turned the DTD into XML, you would get some of those benefits, but if that was all we wanted to do, we would not need a large committee with a lot of people. The fact is that this is just a starting point." The ability to support DTDs within XML is just a starting point for all of the other features that can be included in the Schema.

Taking the ability to support DTDs with XML as a starting point, the additional features of Schemas provide rich functionality. First, Schemas allow you to be more specific in describing the datatypes in the documents you are creating. For example, while DTDs can merely identify the variables in a document, a Schema can specify the types of numbers (floating, fixed, or dates)and valid ranges.

So, for example, if you were making a forms-construction tool to help handle an electrical supply chain, you could mandate that all wire gauges must be between 6 and 15, eliminating many potential clerical problems down the road.

Datatypes and structures
The Schema working groups are concentrating respectively on datatypes and structures.

The Schema: Datatype group is focussing on how the individual data elements are defined. As they are currently defined, the Schema: Datatypes allow you to define only single values, not an array or record of them.

The Schemas: Datatype work makes it possible to create user-defined datatypes. For example, you could specify that height be between 0 and 100 and infer that it refers to centimeters, but there are no measurement units directly associate with the data. Malhotra said, "People have asked us why we have not added units of measure. It is very hard. It is easy to start with inches and meters and pounds. But then people wanted to speak about meters/second and ergs/hour2. It started to become complex quite quickly."

A Schema can also be used to provide a map between an XML document and a database by automating the movement of information from XML fields into the appropriate relational database fields. This would allow companies to use XML as a glue to tie database applications together seamlessly, regardless of the platform that they run on.

Combining elements
The Schema: Structures group is focusing on how to combine individual data elements into entities, for example, combining a name, item from inventory, and other information to create a purchasing form.

DTDs alone can run into problems when you mix data elements from different sources. For example, suppose a book vendor creates an XML purchase order form for its Web site. It might be necessary to combine different elements with similar names, such as title for the customer (Mr., Mrs., Ms., Dr., and so on) and title for the book into the same document. Although a clever developer can always come up with unique names for every element, adopting elements already in wide use by various industry groups helps to maintain interoperability, which is the point of XML, after all.

Listing 1 shows how the different elements may be combined in the same document. The code illustrates the basic model for declaring XML Schema structures components. Note that when you create a new component, you declare that its name is associated with the specification for that component. As you define new components, you add new variables to the symbol space for that kind of component.

Listing 1. A model for declaring XML Schema structures components
<schema>
<datatype name='myDatatype'>
...
</datatype>
<archetype name='myArchetype'>
...
</archetype>
<elementType name='myElementType'>
...
</elementType>
<attrGroup name='myAttrGroup'>
...
</attrGroup>
<modelGroup name='myModelGroup'>
...
</modelGroup>
<notation name='myNotation' ... />
<textEntity name='myTextEntity'>
...
</textEntity>
<externalEntity name='myExternalEntity' ... />
<unparsedEntity name='myUnparsedEntity' ... />
</schema>

Comments in context
The structural recommendations also define standards for XML commenting. Today, developers simply put their comments into the document without rhyme or reason. A comment may describe the item above it, the item below, or what kind of pizza the programmer ordered for lunch that day. With standardized commenting, comments are associated with statements in the document. This allows XML editing tools to bring up the comments when questions arise relating to a given data element. This could also enhance version documentation.

Conformance
The final chapter of the Schema structural recommendation covers conformance. The group wants to develop a set of rules that are clear enough that Schema processors from different companies will interoperate. Mendelsohn said, "Because this technology is dispersed around the world, you want this information to be able to flow all over the place."

Status
The Schema working groups are shooting to have a proposed recommendation by the end of the year.

Resources
Read the drafts of the Schema standard:

Check out the notes of the Fourth Meeting of the W3C XML Schema Working Group

Find out more about the mission of the standards group: XML Schema Requirements, Ashok Malhotra and Murray Maloney, ed., W3C, 15 February 1999.

About the author
George Lawton is a freelance writer and consultant. He has written for JavaWorld, Knowledge Management, IEEE Computer, and Telephony, among others. You can reach him through
his Web site.

     
 
What do you think of this article?

Killer! Good stuff So-so; not bad Needs work Lame!

Comments?


 
     


PrivacyLegalContact---