XmlSchemaValidationFlags 列舉

定義

指定 XmlSchemaValidatorXmlReader 類別 (Class) 所使用的結構描述驗證選項。Specifies schema validation options used by the XmlSchemaValidator and XmlReader classes.

此列舉具有 FlagsAttribute 個屬性允許以位元方式合併其成員值。

public enum class XmlSchemaValidationFlags
public enum 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 值會定義架構驗證 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. 驗證 XmlReaderXmlSchemaValidationFlags 值是使用 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. 當架構定義使用 = "required" 的 xml: * 屬性時。When a schema defines an xml:* attribute with use="required".

    1. AllowXmlAttributes 設定為 truefalse時,就會套用下列各項。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. 當架構定義具有 use = "禁止" 的 xml: * 屬性時。When a schema defines an xml:* attribute with use="prohibited".

    1. AllowXmlAttributes 設定為 truefalse時,就會套用下列各項。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.

適用於

另請參閱