XmlSchemaIntegrityValidationWarning Enum
Namespace
System.Xml.Schema
Assembly
System.Xml.dll
Summary
Specifies the type of warning that can be raised when validating the integrity of an XML schema. These warnings do not prevent a schema from being loaded but indicate potential issues that may affect validation behavior.
Declaration
public enum XmlSchemaIntegrityValidationWarning
Members
| Name | Value | Description |
|---|---|---|
| None | 0 | No warning. |
| DuplicateAnnotation | 1 | Multiple <annotation> elements were found for the same component. |
| MissingTargetNamespace | 2 | The schema does not specify a targetNamespace. |
| RedundantImport | 3 | An <import> is redundant because the namespace is already included. |
| UnsupportedExtension | 4 | The schema uses an extension that is not recognized by the current runtime. |
| ConflictingVersion | 5 | Different versions of the same schema are referenced. |
Example
using System;
using System.Xml.Schema;
class Program
{
static void Main()
{
var schemaSet = new XmlSchemaSet();
schemaSet.ValidationEventHandler += (sender, e) =>
{
if (e.Severity == XmlSeverityType.Warning)
Console.WriteLine($""Warning: {e.Message}"");
};
schemaSet.Add(@"http://example.com/schema", "example.xsd");
schemaSet.Compile();
}
}
Remarks
When a warning of this type is encountered, the XmlSchemaSet.ValidationEventHandler is invoked with XmlSeverityType.Warning. You can decide whether to treat warnings as errors by throwing an exception within the handler.