XmlSchemaIntegrityValidationWarningResult Class
The XmlSchemaIntegrityValidationWarningResult class represents a warning generated during an integrity validation operation on an XML schema. Warnings are non‑critical issues that do not prevent the validation process from completing successfully but may indicate potential problems in the schema.
Namespace
System.Xml
Assembly
System.Xml.dll
Inheritance
System.Object → System.Xml.XmlSchemaIntegrityValidationWarningResult
Properties
| Name | Type | Description |
|---|---|---|
| Message | string | Human‑readable description of the warning. |
| SourceUri | Uri | Location of the schema file that generated the warning. |
| LineNumber | int | Line number in the source file where the warning was detected. |
| LinePosition | int | Column position in the line where the warning was detected. |
| Severity | XmlSchemaSeverity | Level of severity (always Warning for this class). |
Example
using System;
using System.Xml;
using System.Xml.Schema;
class Program
{
static void Main()
{
XmlSchemaSet set = new XmlSchemaSet();
set.ValidationEventHandler += ValidationCallback;
// Load a schema that may produce warnings
set.Add(null, "Schemas/Customer.xsd");
set.Compile();
}
static void ValidationCallback(object sender, ValidationEventArgs e)
{
if (e.Severity == XmlSeverityType.Warning)
{
var warning = (XmlSchemaIntegrityValidationWarningResult)e.Exception;
Console.WriteLine($"Warning: {warning.Message}");
Console.WriteLine($"Location: {warning.SourceUri} (Line {warning.LineNumber}, Position {warning.LinePosition})");
}
}
}
Remarks
The warning result can be cast from the ValidationEventArgs.Exception object when the Severity is XmlSeverityType.Warning. It provides detailed context about why the schema may be questionable, such as deprecated constructs, missing documentation, or non‑standard usage.