Assigning Schemas to XML Files
You assign a schema to an XML file when you want to verify that the content of an XML file is made of the proper data types and is presented in the proper structure. In order to validate an XML file with a schema, you must create a link between the schema file and the XML file. This link is defined in the targetSchema property of the .xml file and when set is added as a namespace reference within the contents of the XML document.
To create the association between schemas and XML documents
- Load an XML file into the XML Designer.
- Change to XML view by clicking the XML tab on the bottom of the designer.
- In the Properties window select DOCUMENT from the drop-down list.
- Set the targetSchema property to the schema to be associated with the XML document.
Note If the XML Schema is a file in your project it will be available in the targetSchema property drop-down list. If it is not in your project, type the Uniform Resource Identifier (URI) of the schema that will be used to validate your XML document.
To remove the association between an XML Schema and an XML document
- Load the XML file into the XML Designer.
- Change to XML view by clicking the XML tab at the bottom of the designer.
- In the Properties window, select DOCUMENT from the drop-down list.
- Clear the contents of the targetSchema property.
Now that you have associated a schema to an XML file, you may want to:
- Validate your XML file. For more information, see Checking for Well-Formed and Valid XML.
- Create a dataset from the schema that is associated with the XML file. For more information, see Creating ADO.NET Typed DataSets from Schemas.
XML Files | Creating New XML Files | Checking for Well-Formed and Valid XML | Creating XML Schemas from XML Files | Relational Data in XML Schemas | Creating XML Schemas and Datasets | Introduction to Data Access with ADO.NET | Introduction to Datasets