ConformanceLevel ConformanceLevel ConformanceLevel ConformanceLevel Enum

定義

指定 XmlReaderXmlWriter 物件所執行的輸入或輸出檢查數量。Specifies the amount of input or output checking that XmlReader and XmlWriter objects perform.

public enum class ConformanceLevel
public enum ConformanceLevel
type ConformanceLevel = 
Public Enum ConformanceLevel
繼承
ConformanceLevelConformanceLevelConformanceLevelConformanceLevel

欄位

Auto Auto Auto Auto 0

XmlReaderXmlWriter 物件會自動偵測是否應執行文件或片段檢查,並進行適當的檢查。The XmlReader or XmlWriter object automatically detects whether document-level or fragment-level checking should be performed, and does the appropriate checking. 如果您包裝其他 XmlReaderXmlWriter 物件,則外部物件不會執行任何其他的一致性檢查。If you're wrapping another XmlReader or XmlWriter object, the outer object doesn't do any additional conformance checking. 必須由基礎物件來進行一致性檢查。Conformance checking is left up to the underlying object.

請參閱 ConformanceLevelConformanceLevel 屬性,以取得如何判定合規性層級的詳細資料。See the ConformanceLevel and ConformanceLevel properties for details on how the compliance level is determined.

Document Document Document Document 2

XML 資料使用語式正確的 XML 1.0 文件規則編譯,如 W3C 所定義。The XML data complies with the rules for a well-formed XML 1.0 document, as defined by the W3C. 此檢查層級可確保任何處理器都可使用讀寫的資料流作為 XML 1.0 文件This level of checking ensures that the stream being read or written can be consumed by any processor as an XML 1.0 document.

Fragment Fragment Fragment Fragment 1

XML 資料是語式正確的 XML 片段,如 W3C 所定義。The XML data is a well-formed XML fragment, as defined by the W3C. 此一致性層級表示 XML 文件可能沒有根項目,但卻是語式正確。This conformance level represents an XML document that might not have a root element but is otherwise well-formed. 此檢查層級可確保任何處理器都可使用讀寫的資料流作為 XML 1.0 外部剖析實體]This level of checking ensures that the stream being read or written can be consumed by any processor as an XML 1.0 external parsed entity].

備註

當您建立 XML 讀取器或寫入器執行個體時,您可以使用XmlReaderSettingsXmlWriterSettings類別,以指定您想要支援的新執行個體的功能。When you create an XML reader or writer instance, you can use the XmlReaderSettings or XmlWriterSettings class to specify the features that you want the new instance to support. 您可以設定的功能之一是一致性的您想要強制執行 XML 資料層級。One of the features that you can configure is the level of conformance you want to enforce on the XML data.

建立符合規範的讀取器或寫入器,可以保證正在處理的 XML 資料符合指定的一致性層級。Creating a compliant reader or writer guarantees that the XML data being processed complies with the specified conformance level. 如果一致性層級不符合正在讀取或寫入資料流,則會擲回例外狀況。If the stream being read or written doesn't comply with the conformance level, an exception is thrown.

文件層級檢查ConformanceLevel.Document列舉成員會強制執行片段層級檢查 (ConformanceLevel.Fragment成員),也請確認下列事項:Document-level checks with the ConformanceLevel.Document enumeration member enforce fragment-level checks (the ConformanceLevel.Fragment member) and also ensure the following:

  • 最上層項目沒有 XML 宣告、 DTD、 元素、 註解、 泛空白字元或處理指示以外的任何節點。The top-level item doesn't have any nodes other than the XML declaration, DTD, element, comment, white space, or processing instruction.

  • XML 資料都只能有一個最上層項目節點。The XML data has one and only one top-level element node.

適用於

另請參閱