XmlSchemaValidationFlags 枚举

定义

指定由 XmlSchemaValidatorXmlReader 类使用的架构验证选项。Specifies schema validation options used by the XmlSchemaValidator and XmlReader classes.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class XmlSchemaValidationFlags
[System.Flags]
public enum XmlSchemaValidationFlags
type XmlSchemaValidationFlags = 
Public Enum XmlSchemaValidationFlags
继承
XmlSchemaValidationFlags
属性

字段

AllowXmlAttributes 16

即使架构中未定义 xml:* 特性,也允许这些特性。Allow xml:* attributes even if they are not defined in the schema. 将根据这些特性的数据类型对它们进行验证。The attributes will be validated based on their data type.

None 0

不要处理标识约束、内联架构、架构位置提示或报告架构验证警告。Do not process identity constraints, inline schemas, schema location hints, or report schema validation warnings.

ProcessIdentityConstraints 8

处理验证过程中遇到的标识约束(xs:IDxs:IDREFxs:keyxs:keyrefxs:unique)。Process identity constraints (xs:ID, xs:IDREF, xs:key, xs:keyref, xs:unique) encountered during validation.

ProcessInlineSchema 1

处理在验证过程中遇到的内联架构。Process inline schemas encountered during validation.

ProcessSchemaLocation 2

处理验证过程中遇到的架构位置提示(xsi:schemaLocationxsi:noNamespaceSchemaLocation)。Process schema location hints (xsi:schemaLocation, xsi:noNamespaceSchemaLocation) encountered during validation.

ReportValidationWarnings 4

报告在验证过程中遇到的架构验证警告。Report schema validation warnings encountered during validation.

示例

有关使用XmlSchemaValidationFlags枚举的示例, XmlSchemaValidator请参阅类。For an example that uses the XmlSchemaValidationFlags enumeration, see the XmlSchemaValidator class.

注解

当与XmlReader一起使用时XmlSchemaValidationFlags , values 定义验证选项, 这些选项用于XmlReader验证架构时执行 XML 验证。When used with the XmlReader, XmlSchemaValidationFlags values define validation options used by a schema validating XmlReader to perform XML validation against a schema. XmlSchemaValidationFlags验证XmlReader的值是XmlReaderSettings.ValidationFlags使用属性指定的。XmlSchemaValidationFlags values for a validating XmlReader are specified using the XmlReaderSettings.ValidationFlags property.

使用AllowXmlAttributes值时:When using the AllowXmlAttributes value:

  1. 当架构未导入 Xml 命名空间时。When a schema doesn't import the Xml namespace.

    1. 如果AllowXmlAttributes设置为true (默认值), 并且实例文档包含 Xml 特性, 则验证引擎将加载默认 Xml 命名空间架构的快照, 并将其用于验证。If AllowXmlAttributes is set to true (default) and the instance document contains Xml attributes, the validation engine will load a snapshot of the default Xml namespace schema and use it for validation. 如果在默认架构中找不到实例文档中使用的 Xml 特性, 则该文档将不会进行验证。If Xml attributes used in the instance document are not found in the default schema, the document will not validate.

    2. 如果AllowXmlAttributes将设置为false , 并且实例文档包含 Xml 特性, 则验证引擎将报告错误。If AllowXmlAttributes is set to false and the instance document contains Xml attributes, the validation engine will report an error.

  2. 当架构导入不带位置的 Xml 命名空间时。When a schema imports the Xml namespace without a location.

    1. 如果AllowXmlAttributes设置为true (默认值), 并且实例文档包含 Xml 特性, 则验证引擎将使用默认的 xml 命名空间架构进行验证。If AllowXmlAttributes is set to true (default) and the instance document contains Xml attributes, the validation engine will use the default Xml namespace schema for validation. 如果在默认架构中找不到实例文档中使用的 Xml 特性, 则该文档将不会进行验证。If Xml attributes used in the instance document are not found in the default schema, the document will not validate.

    2. 如果AllowXmlAttributes设置为false , 并且实例文档包含架构未显式允许的 Xml 特性, 则验证引擎将报告错误。If AllowXmlAttributes is set to false and the instance document contains Xml attributes that are not explicitly allowed by the schema, the validation engine will report an error.

    3. 如果AllowXmlAttributes将设置为false , 并且实例文档包含架构显式允许的 Xml 特性, 验证引擎将使用默认的 Xml 命名空间验证特性的方式与验证其他特性的方式相同。模式.If AllowXmlAttributes is set to false and the instance document contains Xml attributes that are explicitly allowed by the schema, the validation engine will validate the attributes the same way it validates other attributes using the default Xml namespace schema.

  3. 当架构导入具有自定义 schemaLocation 的自定义 Xml 命名空间架构时。When a schema imports a custom Xml namespace schema with a custom schemaLocation.

    1. 如果AllowXmlAttributes设置为true (默认值), 并且实例文档包含 Xml 特性, 则验证引擎将使用自定义 xml 命名空间架构进行验证。If AllowXmlAttributes is set to true (default) and the instance document contains Xml attributes, the validation engine will use the custom Xml namespace schema for validation. 如果在指定的架构中找不到实例文档中使用的 Xml 特性, 则该文档将不会进行验证。If Xml attributes used in the instance document are not found in the specified schema, the document will not validate.

    2. 如果AllowXmlAttributes设置为false , 并且实例文档包含架构未显式允许的 Xml 特性, 则验证引擎将报告错误。If AllowXmlAttributes is set to false and the instance document contains Xml attributes that are not explicitly allowed by the schema, the validation engine will report an error.

    3. 如果AllowXmlAttributes将设置为false , 并且实例文档包含架构显式允许的 Xml 特性, 则验证引擎将使用指定的 Xml 命名空间验证特性的方式与验证其他特性的方式相同。模式.If AllowXmlAttributes is set to false and the instance document contains Xml attributes that are explicitly allowed by the schema, the validation engine will validate the attributes the same way it validates other attributes using specified Xml namespace schema.

  4. 当架构定义 xml: * attribute 并使用 = "required" 时。When a schema defines an xml:* attribute with use="required".

    1. 当设置为trueAllowXmlAttributes false时, 将应用以下内容。The following applies when AllowXmlAttributes is set to true and false. 必需的 xml: * 特性应视为其他特性, 并使用指定的 Xml 命名空间架构进行验证。Required xml:* attributes should be treated as other attributes and validated using the specified Xml namespace schema.
  5. 当架构定义使用 = "禁止" 的 xml: * 属性时。When a schema defines an xml:* attribute with use="prohibited".

    1. 当设置为trueAllowXmlAttributes false时, 将应用以下内容。The following applies when AllowXmlAttributes is set to true and false. 如果实例文档包含架构显式禁止的 xml: * 特性, 验证引擎将报告错误。If an instance document contains xml:* attributes that are explicitly prohibited by the schema, the validation engine will report an error.
  6. 如果架构指定了一个属性通配符。When a schema specifies an attribute wildcard.

    1. 如果实例文档包含 Xml 特性, 并且架构指定了 processContents 省略或设置为 "strict" 的属性通配符, 则验证引擎将使用中XmlSchemaSet提供的 Xml 命名空间架构。If an instance document contains an Xml attribute and the schema specifies an attribute wildcard with processContents either omitted or set to "strict", the validation engine will use the Xml namespace schema present in the XmlSchemaSet. 如果未指定 Xml 命名空间架构, 验证引擎的行为将如下所示。If no Xml namespace schema is specified, the validation engine will behave as follows.

    2. 如果AllowXmlAttributes设置为true, 验证引擎将使用默认的 Xml 命名空间架构来执行验证。If AllowXmlAttributes is set to true, the validation engine will use the default Xml namespace schema to perform validation.

    3. 如果AllowXmlAttributes设置为false, 验证引擎将报告错误。If AllowXmlAttributes is set to false, the validation engine will report an error.

    4. 如果实例文档包含 Xml 特性, 并且架构指定了 processContents 设置为 "skip" 的特性通配符, 则验证引擎将跳过属性验证。If an instance document contains an Xml attribute and the schema specifies an attribute wildcard with processContents set to "skip", the validation engine will skip attribute validation.

    5. 如果实例文档包含 Xml 特性, 并且架构指定了 processContents 设置为 "宽松" 的特性通配符, 则验证引擎将使用中XmlSchemaSet提供的 Xml 命名空间架构。If an instance document contains an Xml attribute and the schema specifies an attribute wildcard with processContents set to "lax", the validation engine will use the Xml namespace schema present in the XmlSchemaSet. 如果未指定 Xml 命名空间架构, 验证引擎的行为将如下所示。If no Xml namespace schema is specified, the validation engine will behave as follows.

    6. 如果AllowXmlAttributes设置为true, 验证引擎将使用默认的 Xml 命名空间架构来执行验证。If AllowXmlAttributes is set to true, the validation engine will use the default Xml namespace schema to perform validation.

    7. 如果AllowXmlAttributes设置为false, 将不执行属性验证。If AllowXmlAttributes is set to false, attribute validation will not be performed.

  7. 验证简单类型时。When validating simple types.

    1. AllowXmlAttributes设置为true (默认值) 时, 将允许对简单类型的元素使用 Xml 特性。When AllowXmlAttributes is set to true (default), Xml attributes will be allowed on elements of simple types.

适用于

另请参阅