MSDN Documentation

XmlSchemaIntegrityValidationWarning Class

The XmlSchemaIntegrityValidationWarning class represents a warning generated during integrity validation of an XML schema. It provides details about the warning, including a message, line number, and the location within the source file.

Namespace

System.Xml

Assembly

System.Xml.dll

Inheritance

Object → XmlSchemaIntegrityValidationWarning

Constructors

SignatureDescription
XmlSchemaIntegrityValidationWarning(string message)Initializes a new instance with a warning message.
XmlSchemaIntegrityValidationWarning(string message, int lineNumber, int linePosition)Initializes a new instance with a message and location information.

Properties

NameTypeDescription
MessageStringThe warning description.
LineNumberInt32The line number where the warning occurred.
LinePositionInt32The position within the line where the warning occurred.
SourceUriStringThe URI of the source XML schema.

Methods

Example

using System;
using System.Xml;
using System.Xml.Schema;

class Program
{
    static void Main()
    {
        var settings = new XmlReaderSettings();
        settings.ValidationType = ValidationType.Schema;
        settings.ValidationEventHandler += OnValidation;

        using (XmlReader reader = XmlReader.Create("example.xsd", settings))
        {
            while (reader.Read()) { }
        }
    }

    static void OnValidation(object sender, ValidationEventArgs e)
    {
        if (e.Severity == XmlSeverityType.Warning)
        {
            var warning = new XmlSchemaIntegrityValidationWarning(e.Message, 
                ((XmlSchemaException)e.Exception).LineNumber,
                ((XmlSchemaException)e.Exception).LinePosition);
            Console.WriteLine(warning);
        }
    }
}

See Also