System.Xml.Schema.XmlSchemaCollection.Add Method

Adds the schema contained in the System.Xml.XmlReader to the schema collection. The specified System.Xml.XmlResolver is used to resolve any external resources.

Syntax

public XmlSchema Add (string ns, System.Xml.XmlReader reader, System.Xml.XmlResolver resolver)

Parameters

ns
The namespace URI associated with the schema. For XML Schemas, this will typically be the targetNamespace.
reader
System.Xml.XmlReader containing the schema to add.
resolver
The System.Xml.XmlResolver used to resolve namespaces referenced in include and import elements or x-schema attribute (XDR schemas). If this is null, external references are not resolved.

Returns

The System.Xml.Schema.XmlSchema added to the schema collection; null if the schema being added is an XDR schema or if there are compilation errors in the schema.

Remarks

If ns has already been associated with another schema in the collection, the schema being added replaces the original schema in the collection.

If ns is null and the schema being added is an XML Schema, the Add method uses the targetNamespace attribute defined in the XML Schema to identify the schema in the collection.

If the schema being added contains references to other namespaces (through include and import elements or the x-schema attribute), the schemas for these other namespaces are loaded for validation purposes only. Unlike the original schema, these other schemas are not explicitly added to the schema collection. As a result, they are not accessible using any of the collection methods or properties.

Note:

The System.Xml.Schema.XmlSchemaCollection class is obsolete in the .NET Framework versionĀ 2.0 and has been replaced by the System.Xml.Schema.XmlSchemaSet class.

Requirements

Namespace: System.Xml.Schema
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0