Authoring and Using Custom Schemas Backgrounder
To add and support a new value for the targetSchema property, you need to create a new markup language schema (.xsd) file. It might be useful to copy an existing .xsd file from one of the default folders for schemas available to all Visual Studio .NET projects:
...\Common7\Packages\schemas\html ...\Common7\Packages\schemas\xml
To configure a new markup language schema, add an .xsd file to your active project and open it for editing in the Schema Designer. Insert vs: schema annotations as needed to define how the Visual Studio Integrated Development Environment (IDE) will automatically complete and validate the markup for an element. For more information about creating .xsd schema files, see the following topics:
- Visual Studio .NET Schema Annotations
- Creating XML Schemas: High-Level Process
- Creating XML Schemas and Datasets
- Creating XML Views Using Annotated XDR Schemas
- XML Schemas and the XML Designer
In this new schema, you will define each element and property of the markup language, and describe valid markup structures; that is, the possible combinations of elements and attributes that are permitted within this version of the language. For more information about designing markup language schemas, see the following topics:
- Creating Element Groups in XML Schemas
- Creating Elements in XML Schemas
- Creating Attributes in XML Schemas
- Complex Types in XML Schemas
- XML Schema Tab, Toolbox
- XML Schema Syntax
- XML Schema Reference (XSD)
You will need to store your custom schema document in a location where Visual Studio .NET can find it. Save the .xsd schema file in your active project folder (for use by that one project), or in the Visual Studio .NET default folder for schemas (for use by any project). To use your new schema, open an HTML or XML document for editing and set its targetSchema property to the name of your new schema.
Note ThetargetSchemaproperty specifies thetargetNamespaceURI of the schema. In an HTML or Web Form document, this adds a<meta>element. In an XML file, setting this property adds anxmlnsattribute to the root element. In an ASP .NET user control, this adds atargetSchemaattribute to the directive. For more information, see targetSchema Property and Setting the targetSchema Property of an HTML Document.
For further background on schemas, see:
- Introduction to XML Schemas
- MSDN Online XML Developer Center (http://msdn.microsoft.com/xml)
- World Wide Web Consortium (W3C) Web site (http://www.w3.org/)
For more information on using schemas, see the following topics:
- Creating XML Schemas from XML Files
- Assigning Schemas to XML Files
- Validation of XML with Schemas
- Validation and the Schema Object Model
- XML Schema (XSD) Validation with Multiple Schemas
- Validation against XML Schema (XSD) with the XmlValidatingReader
Visual Studio .NET may include additional HTML and XML schemas in future releases. For more information, select Check for Updates from the Visual Studio .NET Help menu.
See Also
HTML and XML Schema Extensibility | Creating Scripts and Editing Event Handlers in HTML Designer