XmlSchemaSet.RemoveRecursive(XmlSchema) 메서드

정의

지정된 XSD(XML 스키마 정의 언어) 스키마와 해당 스키마에 가져온 모든 스키마를 XmlSchemaSet에서 제거합니다.

public:
 bool RemoveRecursive(System::Xml::Schema::XmlSchema ^ schemaToRemove);
public bool RemoveRecursive (System.Xml.Schema.XmlSchema schemaToRemove);
member this.RemoveRecursive : System.Xml.Schema.XmlSchema -> bool
Public Function RemoveRecursive (schemaToRemove As XmlSchema) As Boolean

매개 변수

schemaToRemove
XmlSchema

XmlSchema에서 제거할 XmlSchemaSet 개체입니다.

반환

XmlSchema 개체와 해당 개체에 가져온 모든 항목이 제거되었으면 true이고, 그렇지 않으면 false입니다.

예외

매개 변수로 전달된 XmlSchemanull인 경우

예제

다음 코드 예제에서는 에 여러 스키마를 추가한 XmlSchemaSet다음, 메서드를 사용하여 RemoveRecursive 가져오는 스키마와 모든 스키마 중 하나를 제거하는 방법을 보여 줍니다.

Dim schemaSet As XmlSchemaSet = New XmlSchemaSet()
schemaSet.Add("http://www.contoso.com/retail", "http://www.contoso.com/retail.xsd")
schemaSet.Add("http://www.contoso.com/books", "http://www.contoso.com/books.xsd")
schemaSet.Add("http://www.contoso.com/music", "http://www.contoso.com/music.xsd")

Dim schema As XmlSchema

For Each schema In schemaSet.Schemas()

    If schema.TargetNamespace = "http://www.contoso.com/music" Then
        schemaSet.RemoveRecursive(schema)
    End If

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

foreach (XmlSchema schema in schemaSet.Schemas())
{
    if (schema.TargetNamespace == "http://www.contoso.com/music")
    {
        schemaSet.RemoveRecursive(schema);
    }
}

설명

메서드는 RemoveRecursive 스키마 또는 가져온 스키마에 대한 종속성이 없는 한 지정된 스키마와 에서 가져오는 XmlSchemaSet모든 스키마를 제거합니다. 에 스키마 또는 가져온 스키마에 대한 종속성이 있는 XmlSchemaSet경우 아무것도 제거되지 않으며 RemoveRecursive 를 반환합니다 false. 가 반환되고 ValidationEventHandler 이 정의되면 false 종속성을 설명하는 경고가 이벤트 처리기에 전송됩니다.

지정된 스키마가 다른 스키마를 가져오고 지정된 스키마가 이전에 메서드 RemoveRecursiveRemove 사용하여 제거된 경우 메서드는 가져온 스키마를 제거하지 않고 를 반환false합니다. 예를 들어 가져오기 parentSchemachildSchema1childSchema2 다음 코드에서 만 제거하지만 가져온 childSchema1 스키마와 childSchema2 스키마는 제거parentSchema하지 않습니다.

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();

다음 코드는 및 가져온 스키마를 제거 parentSchema 합니다.

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

메서드는 RemoveRecursive 속성의 IsCompiled 상태에 영향을 주지 않습니다.

적용 대상