XmlSchemaIntegrityValidationWarning Class
The XmlSchemaIntegrityValidationWarning class represents a warning that occurs during integrity validation of an XML schema. It provides information about the nature of the warning, the affected schema component, and any relevant diagnostic messages.
Syntax
public sealed class XmlSchemaIntegrityValidationWarning : XmlSchemaObject
Properties
| Name | Type | Description |
|---|---|---|
Message |
string |
Gets the descriptive text of the warning. |
WarningCode |
XmlSchemaValidationWarningCode |
Gets the specific warning code identifying the type of issue. |
SourceObject |
XmlSchemaObject |
Gets the schema object that triggered the warning. |
Example
The following example demonstrates how to capture integrity validation warnings when loading an XML schema.
// C# example
using System;
using System.Xml.Schema;
class Program
{
static void Main()
{
var schemaSet = new XmlSchemaSet();
schemaSet.ValidationEventHandler += OnValidationEvent;
schemaSet.Add(null, "Schemas/Employee.xsd");
schemaSet.Compile();
Console.WriteLine("Schema compilation completed.");
}
static void OnValidationEvent(object sender, ValidationEventArgs e)
{
if (e.Severity == XmlSeverityType.Warning &&
e.Exception is XmlSchemaIntegrityValidationWarning warning)
{
Console.WriteLine($"Warning [{warning.WarningCode}]: {warning.Message}");
Console.WriteLine($"Source: {warning.SourceObject.GetType().Name}");
}
else
{
Console.WriteLine($"Error: {e.Message}");
}
}
}