Using XML in the .NET Framework "  Chapter 4 125 Figure 4.10  Continued type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="Name" type="xs:string" use="required"/> </xs:complexType> What Figure 4.10 shows is a very basic XML schema that a developer could write to guarantee that his or her XML data is in the correct format.The only problem with this text-based schema is that its very complicated and difficult to learn and write. Luckily for those of us who do not necessarily want to spend a lot of our precious time writing these schemas, Microsoft has created a number of tools for us to use to automate this process.These tools include the visual XSD designers available when you add a DataSet or XMLSchema item to your project.These two tools are invaluable if you need to visually design your own schema.The other major tool Microsoft has provided in the .NET framework is the System.Xml.Schema classes. The System.Xml.Schema classes are used to represent an XML schema in an object-oriented, class-based approach.The classes in this namespace can be used both to represent an existing XML schema, and to create a new schema program- matically. Everything that can be done by writing an XML schema by hand can be programmatically created and read using the classes in this namespace. Lets discuss a few of the more basic classes in this namespace. Like the System.Xml classes, the System.Xml.Schema classes that are used to represent a schema are all descendants of the XmlSchemaAnnoted class (which is itself a subclass of the XmlSchemaObject class).The next level in the XmlSchema hierarchy is the XmlSchema class.The XmlSchema class contains the definition for the schema and corresponds to the schema element in the XSD document. All schema elements are added either directly to your Schema object or to a descen- dant of the Schema object.The XmlSchema class contains Write an XSD docu- ment and compile the Schema Object Model (SOM) into schema information for validation. The XmlSchemaAttribute class is used to describe an attribute in your XSD document.You can set the name and schema type of the attribute using public properties on the class.You can also set its default or fixed value depending on how your attribute is meant to work.The XmlSchemaSimpleType and XmlSchemaComplexType  classes are used to represent simple and complex types, www.syngress.com 155_xml_net_pd_C04.qk  3/6/02  1:57 PM  Page 125