Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CheckValidity Method

XPathNavigator.CheckValidity Method

Verifies that the XML data in the XPathNavigator conforms to the XML Schema definition language (XSD) schema provided.

Namespace:  System.Xml.XPath
Assembly:  System.Xml (in System.Xml.dll)

public virtual bool CheckValidity(
	XmlSchemaSet schemas,
	ValidationEventHandler validationEventHandler
)

Parameters

schemas
Type: System.Xml.Schema.XmlSchemaSet
The XmlSchemaSet containing the schemas used to validate the XML data contained in the XPathNavigator.
validationEventHandler
Type: System.Xml.Schema.ValidationEventHandler
The ValidationEventHandler that receives information about schema validation warnings and errors.

Return Value

Type: System.Boolean
true if no schema validation errors occurred; otherwise, false.

ExceptionCondition
XmlSchemaValidationException

A schema validation error occurred, and no ValidationEventHandler was specified to handle validation errors.

InvalidOperationException

The XPathNavigator is positioned on a node that is not an element, attribute, or the root node or there is not type information to perform validation.

ArgumentException

The CheckValidity method was called with an XmlSchemaSet parameter when the XPathNavigator was not positioned on the root node of the XML data.

  • The CheckValidity method verifies that the XML data contained in the XPathNavigator conforms to a global type or declaration in the schema or schemas provided in the XmlSchemaSet.

  • The CheckValidity method does not perform infoset augmentation. This means that schema defaults are not applied, text values are not converted to atomic values, and no new type information is associated with information items.

  • Schema xsi:schemaLocation or xsi:noNamespaceSchemaLocation hints in the XML data of are ignored.

  • If the XPathNavigator is positioned on a document node, the validation process includes checking of uniqueness and reference constraints (xs:ID, xs:IDREF, xs:key, xs:keyref, and xs:unique). Otherwise, these checks are omitted.

  • If the XmlSchemaSet passed as a parameter is null and the XPathNavigator is positioned on an element node, the type information exposed by the SchemaInfo property's SchemaType property is used to check the node's validity. If the XmlSchemaSet passed as a parameter is null and the XPathNavigator is positioned on the root node, the SchemaInfo property of the document element (that is, the element child of the root node) is used. In both cases if the SchemaType property of the element's SchemaInfo property is null and the XmlSchemaSet passed as a parameter is null, an InvalidOperationException is thrown because there is no type information to use to perform validation.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2015 Microsoft