XPathNavigator.CheckValidity(XmlSchemaSet, ValidationEventHandler) Method
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
- 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.
true
if no schema validation errors occurred; otherwise, false
.
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.
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.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: