Verifies that the XML data in the System.Xml.XPath.XPathNavigator conforms to the XML Schema definition language (XSD) schema provided.
- schemas
- The System.Xml.Schema.XmlSchemaSet containing the schemas used to validate the XML data contained in the System.Xml.XPath.XPathNavigator.
- validationEventHandler
- The System.Xml.Schema.ValidationEventHandler that receives information about schema validation warnings and errors.
true if no schema validation errors occurred; otherwise, false.
The XPathNavigator.CheckValidity(System.Xml.Schema.XmlSchemaSet, System.Xml.Schema.ValidationEventHandler) method verifies that the XML data contained in the System.Xml.XPath.XPathNavigator conforms to a global type or declaration in the schema or schemas provided in the System.Xml.Schema.XmlSchemaSet.
The XPathNavigator.CheckValidity(System.Xml.Schema.XmlSchemaSet, System.Xml.Schema.ValidationEventHandler) 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 System.Xml.XPath.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 System.Xml.Schema.XmlSchemaSet passed as a parameter is null and the System.Xml.XPath.XPathNavigator is positioned on an element node, the type information exposed by the XPathNavigator.SchemaInfo property's System.Xml.Schema.IXmlSchemaInfo.SchemaType property is used to check the node's validity. If the System.Xml.Schema.XmlSchemaSet passed as a parameter is null and the System.Xml.XPath.XPathNavigator is positioned on the root node, the XPathNavigator.SchemaInfo property of the document element (that is, the element child of the root node) is used. In both cases if the System.Xml.Schema.IXmlSchemaInfo.SchemaType property of the element's XPathNavigator.SchemaInfo property is null and the System.Xml.Schema.XmlSchemaSet passed as a parameter is null, an InvalidOperationException is thrown because there is no type information to use to perform validation.