Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

XmlSchemaSet.Compile Method

Compiles the XML Schema definition language (XSD) schemas added to the XmlSchemaSet into one logical schema.

Namespace:  System.Xml.Schema
Assembly:  System.Xml (in System.Xml.dll)
public void Compile()
ExceptionCondition
XmlSchemaException

An error occurred when validating and compiling the schemas in the XmlSchemaSet.

This method is called automatically when validation is needed and the XmlSchemaSet has not been previously compiled—for example, when an XmlSchemaSet is used as an input to create an XmlReader object in the Schemas property of an XmlReaderSettings object. If the XmlSchemaSet is already in the compiled state, this method will not recompile the schemas. If this method executes successfully, the IsCompiled property is set to true.

Schemas that have been previously compiled by an XmlSchemaSet are not recompiled. However, schemas that were compiled using the Compile method of the XmlSchemaCollection and the Compile of the XmlSchema will be recompiled.

NoteNote

You need to call the Reprocess method if you have changed a schema (or one of its includes/imports) after adding it to the XmlSchemaSet. The Reprocess method will check the schema for structural validity according to the rules of W3C XML Schema. However, it will not perform a full validation check. It will also resolve references to internal and external schema components. Any imported or included schemas that are successfully retrieved are also added to the XmlSchemaSet. Imported schemas are added as separate XmlSchema objects while included schemas are made part of the including XmlSchema. If the call to reprocess is successful, the IsCompiled property is set to false.

XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add("http://www.contoso.com/books", "http://www.contoso.com/books.xsd");
schemaSet.Compile();

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft. All rights reserved.