Chapter 5. Creating XML Schemas

For the previous two chapters, we've been working with DTDs. Over time, many people have complained to the W3C about the complexity of DTDs and have asked for something simpler. W3C listened, assigned a committee to work on the problem, and came up with a solution that is much more complex than DTDs ever were: XML schemas.

On the other hand, schemas are also far more powerful and precise than DTDs ever were. With schemas, not only can you specify the syntax of a document as you would with a DTD, but you also can do the following: specify the actual data types of each element's content, inherit syntax from other schemas, annotate schemas, use schemas with multiple namespaces, create simple and complex data types, specify the minimum and maximum number of times that an element can occur, create list types, create attribute groups, restrict the ranges of values that elements can hold, restrict what other schemas can inherit from yours, merge fragments of multiple schemas together, require that attribute or element values be unique, and much more.

Currently, the specification for XML schemas is in the working draft stage, which means that it will probably change before becoming a recommendation. You can find the specification in these three documents:

The schema working group expressly set out to tackle a few issues: using namespaces when validating documents, providing for data typing and restrictions, allowing and restricting inheritance between schemas, and creating primitive data types, among others.

Some software is available for modern schema support. W3C had an early schema checker at http://cgi.w3.org/cgi-bin/xmlschema-check, but that page now points to an alpha version of a new schema checker at what looks like a temporary location: http://www.w3.org/2000/06/webdata/xsv. Apache's Xerces XML parser now contains some support for schemas—see http://xml.apache.org/xerces-j/. Oracle also has some support—see http://technet.oracle.com/tech/xml/schema_java/index.htm. XML Spy has support at http://new.xmlspy.com/features_schema.html. You can find additional software implementations (including a tool to convert from DTDs to schemas) at http://www.w3.org/XML/Schema.html.

One of the original proponents of XML schemas was Microsoft. Microsoft's documentation on XML frequently decried DTDs as being too complex and said that schemas would fix the problem. That's not the way it turned out. In fact, the Microsoft implementation of XML schemas in Internet Explorer was promptly outdated not long after it was introduced.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.31.26