XML Schemas Get the NodNow that XML Schemas have reached final recommendation status, they are more attractive than DTDs
By Solomon H. Simon Now let's look at the equivalent schema, shown in Listing 1, for a book. With some minor variations from the released standard, Microsoft Internet Explorer 5.0 can interpret XML and XML Schema files. (In this example, I've taken a few liberties for the sake of clarity.)
A schema is longer than the equivalent DTD, but it may also contain more information. The initial < Schema ...> tag contains ellipsis to indicate other "header" information, such as version numbers, path names for other information, and additional schemas that could be included. Note that all tags have a corresponding close tag. (I included the spaces and extra lines for readability only; they are not part of the schema standard.) The first thing to notice is the hierarchical or taxonomic format. XML and XML Schemas follow a hierarchical, tree-structure format. The elements (title, author, ISBN, and price) are all leaf nodes that belong to the book element. The elements, first and last, are leaf nodes that belong to the author element. For simplicity, I have defined all elements to be string types, but there are other types, such as decimal, and so on. The minOccurs attribute in the closing part of the author element states that there must be at least one author. The maxOccurs attribute states that there can be an infinite number of authors. THE BENEFITS OF SCHEMASXML provides an application independent way of sharing data. Independent groups of people can agree to use a common schema for interchanging data. Your application can use a standard schema or DTD to verify that data that you receive from the outside is valid. You can also use a schema or DTD to verify your own data. XML Schemas, like DTDs, can be used to specify the metadata of a particular class of documents. Unlike DTDs, however, XML Schemas use XML syntax. This is convenient because you don't have to learn a completely new syntax just to describe your grammar - although you do need to learn how to declare elements and attributes using XML Schemas. There are two other advantages to XML Schemas that do not come out in the example. First, schemas give the developer richer control over the data type declarations than is possible in DTDs. Second, schemas allow greater reuse of metadata by permitting the developer to include more external schemas than allowable with DTDs. The main reason to use schemas is to improve compatibility and consistency within an XML document or application. In isolation, it doesn't matter significantly if an XML document uses a DTD or a schema. However, the moment that a developer or user wants to modify the document, share the document, or combine multiple documents, the differences become more apparent. Because schemas follow the XML format, it is easier to design tools, such as extensible stylesheet language transformation scripts, that will modify them. A real concern about XML documents is that developers will use different vocabularies, which will minimize interoperability. To leverage the capabilities of XML, developers must be able to bend the syntax rules of a specific document without breaking the vocabulary. Although there are still obstacles to overcome, such as vocabulary, the W3C's recommendation of XML Schemas is a major step toward better data interchange between companies and, eventually, more sophisticated, widely used B2B e-commerce. SOLOMON H. SIMON [hank.simon@lmco.com] has more than 20 years of experience in IT. He has a Ph.D. in AI, has worked as a chemist, and is currently consulting and writing about XML, WAP, and Bluetooth Web technologies. He is also the author of XML, part of the McGraw-Hill Emerging Business Technology Series. RESOURCES Roger L. Costello's tutorial on XML Schemas Microsoft has a collection of Web sites related to a top-down description of XML Schemas, from what they are to how to build them: msdn.microsoft.com/xml/xmlguide/schema-intro.asp msdn.microsoft.com/xml/tutorial/author_schema.asp Oracle has a technical site at: technet.oracle.com/tech/xml/schema_java/ Related Article on IntelligentEnterprise.com: "XML Will Make It Easier," April 16, 2001
|
Most Popular This Week
IE Weekly Newsletter
Subscribe to the newsletter
|
| ||||||||||||||||||||||||||||||||









