text: .NET and XML: XSD Schemas
  This series of articles takes it as a given that you are familiar with XML itself. The sample XML document used throughout the articles is a list of employees, which must have for each employee the first name, last name, phone number, and e-mail address and can also provide the job title and a Web address.
  <.
  The restrictions element allows a number of restrictions to apply. The list above shows the most common XSD elements for defining simple types. For a complete list, please refer to the XSD standard. A complex type defines a new type that has elements and attributes declared in it.
  This now enables you to define any number of simple and complex types and use them. Again, the list above shows the most common XSD elements. For a complete list, please refer to the XSD standard. Here are a few other very useful XSD elements:
  These few XSD elements and attributes allow you to create very comprehensive XSD schemas. These schemas can describe the expected format of the XML document in any detail. In your XML document, you reference the XSD schema (see below) so you can use the XML parser or tools like Visual Studio .NET 2003 to validate your XML document.
  Sometimes, you have conflicting declarations of elements and attributes or definitions of simple or complex data types. In this case, you place each conflicting definition into a separate namespace. Namespaces are nothing other than a way to logically group declarations of elements and attributes and definitions of types together. Namespaces are identified with a "namespancename:" prefix. Each namespace you use needs to be declared with an "xmlns:namespacename" attribute in the schema element. When you create your XSD schema, you add to the "schema" element the following four attributes (see example above):
  In the XML document itself, you add a reference to the XSD schema with the "xmlns" attribute using the URI of the XSD schema to the root element. Here is an example:
  <?xml version="1.0" encoding="utf-8"?>
  <Employees xmlns="">
  ...
  </Employees>
  You can use Visual Studio .NET 2003 to create a XSD schema out of an existing XML document. Load the XML into Visual Studio and then select the "XML | Create Schema" menu. But, the generated schema is fairly loose, as there is only so much you can infer from an XML document. You, for example, cannot know from an XML document whether the minOccurs and maxOccurs should be set to certain values, and so forth. If you have a XML document but no XSD schema, this is a good approach to start with the creation of the schema. But, it is essential to edit the XSD schema manually until it comprehensively documents the valid XML formats.
  Summary
  It has become common practice to use XML to describe and exchange data. Exchanging these XML documents between two or more applications can pose a challenge because you want to make sure each application expects the XML in the same format. This is where XSD schemas come into play. Development teams should base the XML data exchanges on published XSD schemas. These schemas define the valid formats of the XML documents. And, only XML documents that validate successfully should be processed. Very often, it makes sense to validate the received XML document against the XSD schema you used to build the data exchange. If the XML cannot be validated successfully, you should return an error stating this to be an invalid XML document.
  The creation and use of XSD schemas can avoid a lot of problems resulting from invalid XML documents. This article provides a good overview of the XSD syntax. With a small number of XSD elements and attributes, you are able to build comprehensive XSD schemas. The next article in this series will explain the fundamentals of XSL Transformations. If you have comments to this article, please contact me @ klaus_salchner@hotmail.com. I want to hear if you learned something new..or.
  