System.Xml.Schema.XmlSchemaSet.RemoveRecursive Method

Removes the specified XML Schema definition language (XSD) schema and all the schemas it imports from the System.Xml.Schema.XmlSchemaSet.

Syntax

public bool RemoveRecursive (XmlSchema schemaToRemove)

Parameters

schemaToRemove
The System.Xml.Schema.XmlSchema object to remove from the System.Xml.Schema.XmlSchemaSet.

Returns

true if the System.Xml.Schema.XmlSchema object and all its imports were successfully removed; otherwise, false.

Remarks

The XmlSchemaSet.RemoveRecursive method removes the specified schema and all the schemas it imports from the System.Xml.Schema.XmlSchemaSet, as long as there are no dependencies on the schema or its imported schemas. If there are dependencies on the schema or its imported schemas in the System.Xml.Schema.XmlSchemaSet, nothing is removed and XmlSchemaSet.RemoveRecursive(XmlSchema) returns false. If false is returned and a XmlSchemaSet.ValidationEventHandler is defined, a warning is sent to the event handler describing the dependencies.

If the specified schema imports other schemas and the specified schema was previously removed with the XmlSchemaSet.Remove(XmlSchema) method, the XmlSchemaSet.RemoveRecursive(XmlSchema) method will not remove the imported schemas and will return false. For example, if parentSchema imports childSchema1 and childSchema2 the following code will only remove parentSchema, but not the imported childSchema1 and childSchema2 schemas:

Example

XmlSchemaSet ss = new XmlSchemaSet();
XmlSchema xs = XmlSchema.Read(XmlReader.Create("parentSchema.xsd"), null);
ss.Add(xs);
ss.Compile();
ss.Remove(xs);
ss.Compile();
ss.RemoveRecursive(xs);
ss.Compile();

The following code will remove the parentSchema and the imported schemas:

Example

XmlSchemaSet ss = new XmlSchemaSet();
XmlSchema xs = XmlSchema.Read(XmlReader.Create("parentSchema.xsd"), null);
ss.Add(xs);
ss.Compile();
ss.RemoveRecursive(xs);
ss.Compile();

The XmlSchemaSet.RemoveRecursive(XmlSchema) method has no effect on the state of the XmlSchemaSet.IsCompiled property.

Requirements

Namespace: System.Xml.Schema
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0