Data Conformance Conditions on the XmlReader

The following section describes some of the possible conformance violations that can occur when working with the XmlReader class.

Conformance Conditions

The following sections describe possible conformance conditions that can occur and how each condition is handled by the reader. The conformance level setting on the reader (that is, the XmlReaderSettings.ConformanceLevel property setting when the reader was created) determines the reader behavior.

Text or a typed value occurs at the top level. That is, the text or typed value does not occur beneath an element or attribute node.

Document:   An XmlException is thrown.

Fragment:   This is not a violation for this level of conformance checking.

Auto:   Fragment conformance checking is applied.

Multiple elements at the top level, or no element at the top level.

Document:   An XmlException is thrown.

Fragment:   This is not a violation for this level of conformance checking.

Auto:   Fragment conformance checking is applied.

White space is the top-level item.

Document / Fragment / Auto:   This is not a violation for this level of conformance checking.

An attribute is the top-level item.

Document:   The attribute is recognized as a text node, and therefore an XmlException is thrown.

Fragment:   The attribute is recognized as a text node.

Auto:   The attribute is recognized as a text node. Fragment conformance checking is applied.

Multiple, contiguous text nodes are found.

Document / Fragment / Default:   The data is considered to be valid. In this case, it is the responsibility of the user to concatenate the text nodes.

The same namespace prefix is declared twice in an element. That is, two namespace declarations for the same prefix exist in the same local scope.

Document / Fragment / Auto:   An XmlException is thrown.

An element contains a prefix and namespace, but a corresponding namespace declaration does not exist within the scope, or the prefix is associated with a different namespace.

Document / Fragment / Auto:   An XmlException is thrown.

An attribute contains a prefix and namespace, but a corresponding namespace declaration does not exist within the scope.

Document / Fragment / Auto:   An XmlException is thrown when the violation is encountered.

The xml:space attribute does not contain a valid value.

Document / Fragment / Auto:   An XmlException is thrown.

An invalid name is encountered.

Document / Fragment / Auto:   An XmlException is thrown.

The xml prefix is not matched to the http://www.w3.org/XML/1998/namespace namespace URI.

Document / Fragment / Auto:   An XmlException is thrown.

See Also

Concepts

Reading XML with the XmlReader

Other Resources

Validating XML Data with XmlReader