``An XML schema language is a formalization of the constraints, expressed as rules or a model of structure, that apply to a class of XML documents. In many ways, schemas serve as design tools, establishing a framework on which implementations can be built. Since formalization is a necessary ground for software designers, formalizing the constraints and structures of XML instance documents can lead to very diverse applications. Although new applications for schemas are being invented every day, most of them can be classified as validation, documentation, query, binding, or editing.''
Web Services most often depend on remote procedure calls where parameters have to be passed to remote methods where they are processed. These parameters emerge from programs written in computer languages which use variables that are assigned to specific data types, such as strings or integers. When such variables are encoded in an XML document, it is important that the information about the data type is not lost. XML Schema offers a variety of data types that can be used for encoding data so that the receiving Web Service can decode the transmitted parameters and hand them to the requested method.
XML Schema data types are separated into so-called ``simple types'' and ``complex types''. Simple types describe elements that contain only one value and no attribute, such as <value>36</value> and therefore represent basic data types like integers or strings12. Complex types describe elements that may contain other elements and/or attributes.
An overview of the most commonly used data types provided by XML Schema is depicted in figure 10.
Listing 3 shows a possible XML Schema for the XML Document in listing 1. Line 3 of the listing defines the complex element currency, which contains the three elements iso,name and change. Line 6, 7 and 8 define the data types for these elements and in line 10 and 11 the possible attributes for the element currency are defined.
In order to check the validity of an XML document it has to be linked to a corresponding XML Schema document. Listing 4 shows how the basic XML example in listing 1 has to be modified.
XML Schema is a powerful method of constraining the content of XML documents. Its flexibility and extensibility makes it possible to validate various kinds of XML documents. One problem of XML Schema is that constraining content with a complex structure results in even more complex XML Schema documents that can be difficult to read and maintain. In such cases a thorough design and accurate documentation of the schema is very important. An in-depth reading about XML Schema can be found in [VLI02].