Export (0) Print
Expand All

Assigning Schemas to XML Files

Visual Studio .NET 2003

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

  1. Load an XML file into the XML Designer.
  2. Change to XML view by clicking the XML tab on the bottom of the designer.
  3. In the Properties window select DOCUMENT from the drop-down list.
  4. 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

  1. Load the XML file into the XML Designer.
  2. Change to XML view by clicking the XML tab at the bottom of the designer.
  3. In the Properties window, select DOCUMENT from the drop-down list.
  4. Clear the contents of the targetSchema property.

Next Steps

Now that you have associated a schema to an XML file, you may want to:

See Also

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

Show:
© 2014 Microsoft