XmlSchemaValidator.AddSchema(XmlSchema) 方法

定义

将一个 XML 架构定义语言 (XSD) 架构添加到用于验证的架构集。Adds an XML Schema Definition Language (XSD) schema to the set of schemas used for validation.

public:
 void AddSchema(System::Xml::Schema::XmlSchema ^ schema);
public void AddSchema (System.Xml.Schema.XmlSchema schema);
member this.AddSchema : System.Xml.Schema.XmlSchema -> unit
Public Sub AddSchema (schema As XmlSchema)

参数

schema
XmlSchema

一个 XmlSchema 对象,要将其添加到用于验证的架构集。An XmlSchema object to add to the set of schemas used for validation.

例外

指定的 XmlSchema 参数为 nullThe XmlSchema parameter specified is null.

XmlSchema 参数的目标命名空间与 XmlSchemaValidator 对象已经遇到的任何元素或特性的目标命名空间匹配。The target namespace of the XmlSchema parameter matches that of any element or attribute already encountered by the XmlSchemaValidator object.

XmlSchema 参数无效。The XmlSchema parameter is invalid.

注解

以下是使用方法时要考虑的重要注意事项 AddSchemaThe following are important notes to consider when using the AddSchema method.

  • AddSchema方法可用于模拟在要验证的 xml 文档中遇到内联 xml 架构的效果。The AddSchema method can be used to simulate the effect of encountering an inline XML schema in the XML document being validated.

  • XmlSchema 参数的目标命名空间无法与 XmlSchemaValidator 对象已遇到的任何元素或属性的目标命名空间匹配。The target namespace of the XmlSchema parameter cannot match that of any element or attribute already encountered by the XmlSchemaValidator object.

  • 如果 ProcessInlineSchema 未设置验证选项,则 AddSchema 方法不执行任何操作。If the ProcessInlineSchema validation option is not set, the AddSchema method does nothing.

适用于

另请参阅