XmlSchemaValidationFlags 列舉

定義

指定 XmlSchemaValidatorXmlReader 類別 (Class) 所使用的結構描述驗證選項。

此列舉支援其成員值的位元組合。

public enum class XmlSchemaValidationFlags
[System.Flags]
public enum XmlSchemaValidationFlags
[<System.Flags>]
type XmlSchemaValidationFlags = 
Public Enum XmlSchemaValidationFlags
繼承
XmlSchemaValidationFlags
屬性

欄位

AllowXmlAttributes 16

允許 xml:* 屬性,即使未在結構描述中定義它們也是如此。 對屬性的驗證會依據其資料型別進行。

None 0

請勿處理識別條件約束、內嵌結構描述、結構描述位置提示,或報告結構描述驗證警告。

ProcessIdentityConstraints 8

處理驗證期間遇到的識別條件約束 (xs:IDxs:IDREFxs:keyxs:keyrefxs:unique)。

ProcessInlineSchema 1

處理驗證期間遇到的內嵌結構描述。

ProcessSchemaLocation 2

處理驗證期間遇到的結構描述位置提示 (xsi:schemalocationxsi:noNamespaceSchemaLocation)。

ReportValidationWarnings 4

報告驗證期間遇到的結構描述驗證警告。

範例

如需使用 列舉的 XmlSchemaValidationFlags 範例,請參閱 XmlSchemaValidator 類別。

備註

搭配 使用 XmlReader 時, XmlSchemaValidationFlags 值會定義驗證 XmlReader 架構用來對架構執行 XML 驗證的驗證選項。 XmlSchemaValidationFlags 驗證 XmlReader 的值是使用 屬性來 XmlReaderSettings.ValidationFlags 指定。

使用 AllowXmlAttributes 值時:

  1. 當架構未匯入 Xml 命名空間時。

    1. 如果 AllowXmlAttributes 設定為 true (預設) ,而實例檔包含 Xml 屬性,驗證引擎將會載入預設 Xml 命名空間架構的快照集,並將其用於驗證。 如果在預設架構中找不到實例檔中使用的 Xml 屬性,檔將不會驗證。

    2. 如果 AllowXmlAttributes 設定為 false ,而實例檔包含 Xml 屬性,驗證引擎將會報告錯誤。

  2. 當架構匯入沒有位置的 Xml 命名空間時。

    1. 如果 AllowXmlAttributes 設定為 true (預設) ,而實例檔包含 Xml 屬性,則驗證引擎會使用預設的 Xml 命名空間架構進行驗證。 如果在預設架構中找不到實例檔中使用的 Xml 屬性,檔將不會驗證。

    2. 如果 AllowXmlAttributes 設定為 false ,而實例檔包含架構未明確允許的 Xml 屬性,驗證引擎將會報告錯誤。

    3. 如果 AllowXmlAttributes 設定 false 為 ,而實例檔包含架構明確允許的 Xml 屬性,則驗證引擎會使用預設的 Xml 命名空間架構來驗證其他屬性的方式驗證屬性。

  3. 當架構使用自訂 schemaLocation 匯入自訂 Xml 命名空間架構時。

    1. 如果 AllowXmlAttributes 設定為 true (預設) ,而實例檔包含 Xml 屬性,則驗證引擎會使用自訂 Xml 命名空間架構進行驗證。 如果在指定的架構中找不到實例檔中使用的 Xml 屬性,檔將不會驗證。

    2. 如果 AllowXmlAttributes 設定為 false ,而實例檔包含架構未明確允許的 Xml 屬性,驗證引擎將會報告錯誤。

    3. 如果 AllowXmlAttributes 設定 false 為 ,而實例檔包含架構明確允許的 Xml 屬性,則驗證引擎會使用指定的 Xml 命名空間架構來驗證其他屬性的方式驗證屬性。

  4. 當架構使用 use=「required」 定義 xml:* 屬性時。

    1. 當 設定為 truefalseAllowXmlAttributes ,適用下列專案。 必要的 xml:* 屬性應該視為其他屬性,並使用指定的 Xml 命名空間架構進行驗證。
  5. 當架構使用 use=「prohibited」 定義 xml:* 屬性時。

    1. 當 設定為 truefalseAllowXmlAttributes ,適用下列專案。 如果實例檔包含架構明確禁止的 xml:* 屬性,驗證引擎將會報告錯誤。
  6. 當架構指定屬性萬用字元時。

    1. 如果實例檔包含 Xml 屬性,且架構會指定具有 processContents 的屬性萬用字元,或設定為 「strict」,驗證引擎將會使用 中 XmlSchemaSet 存在的 Xml 命名空間架構。 如果未指定 Xml 命名空間架構,驗證引擎的行為會如下所示。

    2. 如果 AllowXmlAttributes 設定為 true ,驗證引擎會使用預設的 Xml 命名空間架構來執行驗證。

    3. 如果 AllowXmlAttributes 設定為 false ,驗證引擎將會報告錯誤。

    4. 如果實例檔包含 Xml 屬性,且架構會指定具有 processContents 設定為 「skip」 的屬性萬用字元,驗證引擎將會略過屬性驗證。

    5. 如果實例檔包含 Xml 屬性,且架構會指定具有 processContents 設定為 「lax」 的屬性萬用字元,驗證引擎將會使用 中 XmlSchemaSet 存在的 Xml 命名空間架構。 如果未指定 Xml 命名空間架構,驗證引擎的行為會如下所示。

    6. 如果 AllowXmlAttributes 設定為 true ,驗證引擎會使用預設的 Xml 命名空間架構來執行驗證。

    7. 如果 AllowXmlAttributes 設定為 false ,則不會執行屬性驗證。

  7. 驗證簡單類型時。

    1. AllowXmlAttributes 設定為 true (預設) 時,簡單類型的元素將允許 Xml 屬性。

適用於

另請參閱