 |
|
| |
| XML: Leading the March to Web Services (cont.)
|
Step 2: The Need for Data Types and Schema
Until recently, relational databases had one huge advantage over XML, which is that they store strongly typed data. If you look at the sample XML document shown above, you'll see that it consists of text items, numeric items, and date items, all stored as quoted strings. When you retrieve an item from a database, you almost always know its data type.
| Schemas are like a contract, because they both codify the format of documents that systems on either end of a transaction can use and guarantee that the documents themselves adhere to a specific format and content. |
|
From its progenitor, the Standard Generalized Markup Language (SGML), XML inherited the concept of creating an associated document that defines the rules for tags in other documents, called a Document Type Definition, or DTD. The concept was powerful, but DTDs were difficult to parse (because they weren't XML documents) and had some other weaknesses. A W3C-recommended replacement technology, called XML Schema, maintained the DTD concept that one document can define the content of other documents but changed the defining document's format to XML. With XML Schema, a standard parser could read both the defining document, or schema, and the data document itself.
XML Schema documents define a common set of data type names, such as string, integer, and date, so you can create a schema to accompany your XML document that defines the data types that each tag or attribute can hold. By reading the schema first, parsers can then cast data values to the correct types as they read the data in associated documents.
| W3C-recommended replacement technology, called XML Schema, maintained the DTD concept that one document can define the content of other documents but changed the defining document's format to XML. With XML Schema, a standard parser could read both the defining document, or schema, and the data document itself. |
|
In addition, schema documents define boundaries for the order and arrangement of tags within conforming XML documents, the range or set of valid values for attributes, and the minimum/maximum occurrence of tags and attributes. Parsers that can read XML schema and compare the content of XML documents with a schema are called "validating" parsers; an XML document that conforms to the rules of its schema is called a "valid" document.
In other words, after you have the schema for an XML document you can ensure not only that the document is well-formed, but also that it is valid. That's extremely important, because it means that programs using validating XML parsers can pinpoint bad data in XML documentswithout the program knowing anything specific about the document in advance. Validation capabilities can reduce or sometimes even eliminate the need to write custom validation code.
Schemas were the second step in the evolution of Web services. Schemas are like a contract, because they both codify the format of documents that systems on either end of a transaction can use, and guarantee that the documents themselves adhere to a specific format and content. Perhaps most important, schemas provide a way for machines to perform codification and validation processes generically and without human intervention.
|
|
|
FEATURE SOFTWARE:
dtSearch Web
Add power searching to your web site. Buy Now!
Encrypt It
Encrypt and Decrypt Data, Passwords and Files within your application. Buy Now!
|
|
|