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

XmlSchemaSet.RemoveRecursive Method

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

Namespace:  System.Xml.Schema
Assembly:  System.Xml (in System.Xml.dll)
member RemoveRecursive : 
        schemaToRemove:XmlSchema -> bool

Parameters

schemaToRemove
Type: System.Xml.Schema.XmlSchema

The XmlSchema object to remove from the XmlSchemaSet.

Return Value

Type: System.Boolean
true if the XmlSchema object and all its imports were successfully removed; otherwise, false.
ExceptionCondition
ArgumentNullException

The XmlSchema passed as a parameter is a null reference (Nothing in Visual Basic).

The RemoveRecursive method removes the specified schema and all the schemas it imports from the 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 XmlSchemaSet, nothing is removed and RemoveRecursive returns false. If false is returned and a 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 Remove method, the RemoveRecursive 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:

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:

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

The RemoveRecursive method has no effect on the state of the IsCompiled property.

The following code example illustrates adding multiple schemas to an XmlSchemaSet, then removing one of the schemas and all the schemas it imports using the RemoveRecursive method.

No code example is currently available or this language may not be supported.

.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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.