XPathNavigator.CheckValidity(XmlSchemaSet, ValidationEventHandler) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Verifies that the XML data in the XPathNavigator conforms to the XML Schema definition language (XSD) schema provided.
public:
virtual bool CheckValidity(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::Schema::ValidationEventHandler ^ validationEventHandler);
public virtual bool CheckValidity (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.Schema.ValidationEventHandler validationEventHandler);
abstract member CheckValidity : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.ValidationEventHandler -> bool
override this.CheckValidity : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.ValidationEventHandler -> bool
Public Overridable Function CheckValidity (schemas As XmlSchemaSet, validationEventHandler As ValidationEventHandler) As Boolean
Parameters
- schemas
- XmlSchemaSet
The XmlSchemaSet containing the schemas used to validate the XML data contained in the XPathNavigator.
- validationEventHandler
- ValidationEventHandler
The ValidationEventHandler that receives information about schema validation warnings and errors.
Returns
true
if no schema validation errors occurred; otherwise, false
.
Exceptions
A schema validation error occurred, and no ValidationEventHandler was specified to handle validation errors.
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.
The CheckValidity(XmlSchemaSet, ValidationEventHandler) method was called with an XmlSchemaSet parameter when the XPathNavigator was not positioned on the root node of the XML data.
Remarks
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
orxsi: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
, andxs: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 isnull
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 isnull
and the XmlSchemaSet passed as a parameter isnull
, an InvalidOperationException is thrown because there is no type information to use to perform validation.