MS Docs

Microsoft Docs

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

NameTypeDescription
MessagestringHuman‑readable description of the warning.
SourceUriUriLocation of the schema file that generated the warning.
LineNumberintLine number in the source file where the warning was detected.
LinePositionintColumn position in the line where the warning was detected.
SeverityXmlSchemaSeverityLevel 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})");
        }
    }
}
View in .NET Framework 4.8 View in .NET 8.0

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.