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

按 W3C 定义,XML 数据符合格式良好的 XML 1.0 documentThe 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

按 W3C 定义,XML 数据是格式良好的 XML 片段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.

适用于

另请参阅