Whatever happened to XML schemas?
by Ronald Schmelzer, Senior Analyst, ZapThink, LLC
Early in the growth of XML as a data format, even before the widespread adoption of Web services, one of the most popular and heated debates was on how best to represent the structure and syntax of data in an XML document. Commonly known as XML schemas, a wide range of proposals emerged for how to best indicate which elements were required in an XML document, as well as the nature, repetition, and hierarchy of those elements. The goal of these formats was simple: provide an easy way of defining the requirements of an XML document, and then validating those documents against those requirements so that two unrelated parties can reliably exchange and process XML documents.
Most of the XML schema proposals hinged on the general assessment that the traditional way of detailing schema, the Document Type Definition (DTD), was too arcane, limiting, and cumbersome to use. After much hassle, it seemed that the W3C XML Schema (informally called WXS) was the approach that won out. But since the declaration of WXS as the winning standard, the conversation about the importance of XML schemas has died down, begging the question of the importance of XML schemas or even their necessity in system-to-system interchange. Basically, why are people not talking about XML schemas as much anymore? Is it because schemas are no longer important, or is it simply that we've moved on to more complex issues now?
Validating the XML payload: Is it necessary?
There are really two parts to answering the question about the relevance of XML schemas: their importance to the data that companies exchange and care about (the message payload), and their relevance to the interfaces to access the data (specifically, Web services). Remarkably, each application of XML schemas is leading to different patterns of adoption and value to enterprise users.
When applying XML schemas to message payloads, companies use XML schemas as a way of verifying that incoming XML documents are valid enough to be processed by their automated systems. Clearly, such validation is important because systems aren't capable of coping with data that are not properly structured or that they can't easily parse and understand. The XML syntax of schema languages like those specified in the WXS is meant for machines to easily consume, parse, and transform messages that follow that syntax, by using standard XML technologies.
Yet, the XML basis of these schema languages are also their downfall, because XML is verbose: it consumes considerable processing power, bandwidth, and storage space. In addition, developing an XML schema in an XML language is an incredibly complex proposition. While other formats, such as the REgular LAnguage description for XML Next Generation (RELAX NG) Compact Syntax, emerged to solve the development difficulties of WXS, creating and debugging XML schema documents still requires significant experience and training.
However, as we detailed in an earlier ZapFlash, evidence shows that most companies are not even making use of the basic validation benefits of XML schemas. Instead, companies that are using schemas at all are using them only during the testing and debugging phases of their projects, and turning off runtime validation during the production phase. Why? Because validating XML documents every time they are parsed eats up too much processing power, developing XML schemas is too complex for iterative, cross-organization implementations, and many validity issues (such as whether or not a requested item is in a given database) can't be resolved within a single document anyway. Given these serious implementation challenges, it's not entirely clear that XML schemas are even necessary for handling basic document validity issues. That role might more clearly fall to the service providing the XML document itself. Given that, how can XML schemas be used not just to validate the payload, but provide added value to a service interface?
XML Schemas: Necessary for the service contract
If XML schemas are not being used by most companies to make sure that data are provided in a format that their systems can handle, what will be the mechanism companies will use to guarantee validity, interoperability, and semantic integration? How about the service interface itself, specified in a Web Services Description Format (WSDL) document, and all the other pieces of Web services technology that define the service contract?
The creators of WSDL smartly realized that they needed to provide a way to represent what services can expect as inputs and outputs (what you might call the contract semantics) in a way that systems could automatically process. However, it is difficult to make any strict data typing assumptions in the service interface without jeopardizing the loose coupling of the interface. To put it simply, if one service provider demands that a given input be a string of a certain size, and therefore all service consumers comply with that demand, when the service interface changes, all the consumers break. Such behavior is clearly not loosely coupled. Thus, the developers of WSDL perceived XML schemas as a way to share service semantics without tightly coupling the requirements into the service implementations.
As a result, WSDL does not introduce a new type definition language, but rather supports WXS as its canonical type system. The WSDL creators also aimed to dodge the bullet of recommending a single XML schema format, thus allowing for the use of other type definition languages via the extensibility of XML. Through the use of XML schemas, WSDL can allow services to utilize a wide range of primitive types (such as strings, integers, and other data types) as well as complex structures such as enumerations and regular expressions, lists, unions, extension and restriction of complex types, and more. Since the validation of the interface happens only upon service discovery and binding, there is little overhead in the actual transactions themselves. Validation thus happens upon service negotiation, and as long as the service requester complies with the requirements of the service interface, there is no need to validate every single message that flows through the interface.
However, there is a more important reason to consider the use of XML schemas at the service interface. Too many developers are thinking about building services from the bottom-up. As ZapThink has discussed numerous times, to gain all the advantages of a Service-Oriented Architecture, namely loose coupling, coarse granularity, and asynchrony, you must conceive of services separate from the technologies that implement them. Basically, you can't be thinking of Java's data types when you create a service interface. Instead, there must be some data typing system that exists separate from the implementations that underlie the services.
XML schemas are the answer to this loose coupling need. By thinking of service interfaces in terms of schema data types, you can escape the pitfall of only including those data types that a given implementation can support. Many features of XML schema, such as lists, unions, disjunctions and restricted complex types are not present in many programming languages, but might be a requirement of a given service. If IT shouldn't be an impediment to meeting the needs of business requirements, why should the data types of some arcane language? Starting from the WSDL service definition, service producers and consumers can share and enforce the same vision of message content, using the robust typing of XML schema.
Validation at the service interface
Increasingly, ZapThink is seeing that the service interface is performing a greater number of functions. At first, this interface simply provided the details that service requesters can use to identify and bind to service functionality. Now, however, the service contract takes on a wider variety of functions. Validation of the business payload is one of those functions that the service interface can handle. Likewise, security, management, process, and quality-of-service decisions and actions can also happen at the service interface. But, in order to handle all these needs, users need a means to specify the requirements of the service interface in an application-neutral language. And so, while XML schemas may no longer be the center of our daily discussion, they still remains the center of how we can achieve the basic goals of loosely coupled, asynchronous, and coarse-grained integration.
Copyright 2003. Originally published by ZapThink LLC, reprinted with permission. ZapThink LLC provides quality, high-value, focused research, analysis, and insight on emerging technologies that will have a high impact on the way business will be run in the future. To register for a free e-mail subscription to ZapFlash, click here.
For more information:
- Looking for free research? Browse our comprehensive White Papers section by topic, author or keyword.
- Are you tired of technospeak? The Web services Advisor column uses plain talk and avoids the hype.
- For insightful opinion and commentary from today's industry leaders, read our Guest Commentary columns.
- Hey Codeheads! Start benefiting from these time-saving XML Developer Tips and .NET Developer Tips.
- Visit our huge Best Web Links for Web services collection for the freshest editor-selected resources.
- Visit Ask the Experts for answers to your Web services, SOAP, WSDL, XML, .NET, Java and EAI questions.
- Couldn't attend one of our Webcasts? Don't miss out. Visit our archive to watch at your own convenience.
- Choking on the alphabet soup of industry acronyms? Visit our helpful Glossary for the latest lingo.
- Discuss this article, voice your opinion or talk with your peers in the SearchWebServices Discussion Forums.