|
Article Excerpt If it is important that your XML documents are correct, catching mistakes early is, of course, much less costly than catching them later. This should not be news to any XML developer.
But "correct" often means more than just a simple validity test at the end of the development process. Today, no one schema language covers all the bases. Different languages offer different possible measures of correctness. In combination, multiple schemas may provide the rich structure an application or organization needs for success.
The most common of the newer schema languages is W3C XML Schema (XSD). Classwell Learning Group, a division of textbook publisher Houghton Mifflin, has put XSD at the center of their content-driven applications since 2001. While XSD is far more powerful than DTD for defining structure and data types, limitations remain. Classwell found that a rules-based schema language, Schematron, could provide additional validation rules to ensure consistency between classes of documents and to enforce conventions in the XSD schemas themselves. It has become particularly evident that, given XSD's notorious complexity, consistent and thought-out design patterns are crucial for the effective use of XSD. Classwell has been working to establish their own set of best practices for XSD development that can be monitored by a combination of validation tools.
As a rules-based system, Schematron takes an approach to validation that's distinctly different from that of XSD. When the two are paired together, Schematron adds significant prescriptive flexibility that complements XSD's stronger expression of structure. Schematron came out of research by Rick Jelliffe at Academia Sinica, but is interesting from a practical perspective because it provides capabilities today that will only be available in XML Schema 1.1 or 2.0 in the future.
This article shows how to build a productive framework for multipass validation within Altova's popular XMLSPY environment. The example we use is drawn from Classwell's use of Schematron rules to enforce best practices in XSD design. In designing a new layer for an already complex development process, we felt the issue of productivity was important. To reduce the chance of error and speed up complex validation, we leveraged XMLSPY's rich scripting capabilities. The XMLSPY Scripting Environment enabled us to add UI elements that controlled a flexible and manageable multilanguage validation process with minimal effort.
Defining Rules for Best Practice
Our goal was to enforce a short list of practices that experience taught us should be required patterns. For this article we have selected a subset of Classwell's XSD rules that demonstrate the concept, while keeping the examples simple.
* Ensure the root element is an extension of a base rootType, guaranteeing a certain minimum tagging of the content. XSD does not define which element is intended to be the document root, but we can assume it will be the first global element defined.
* Schema must be versioned (XSD allows a version attribute for tracking--enforce its use).
* XSD files that define much of the common tagging must be consistently used--for our example here, para.xsd and root.xsd.
* Disallow the use of the xs:string data type (xs:string allows text formatting we do not want within...
|
|

More articles from XML Journal
XML Certification Quizzer: some interesting aspects of XML syntax. (Ce..., July 01, 2003
Looking for additional articles?
Search our database of over 3 million articles.
Looking for more in-depth information on this industry?
Search our complete database of Industry & Market reports by text, subject, publication
name or publication date.
About Goliath
Whether you're looking for sales prospects, competitive information, company
analysis or best practices in managing your organization,
Goliath can help you meet your business needs.
Our extensive business information databases empower business
professionals with both the breadth and depth of credible,
authoritative information they need to support their business
goals. Whether it be strategic planning, sales prospecting,
company research or defining management best practices -
Goliath is your leading source for accurate information.
|
|