ValidationFlags Enum
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Specifies flags that control the behavior of the XML Schema validation process.
Members
-
ReportValidation
Reports all validation errors. This is the default value.
-
ProcessSchemaLocation
Processes the
xsi:schemaLocation
andxsi:noNamespaceSchemaLocation
attributes. This is the default value. -
ProcessInlineSchema
Processes schema information found within the document itself (e.g., a
<schema>
element). -
ProcessSchemaImports
Processes schema imports (e.g.,
<xs:import>
,<xs:include>
,<xs:redefine>
). -
CheckCharacters
Checks for valid characters according to the W3C XML 1.0 Recommendation.
-
AllowEmptySchema
Allows schemas to be empty.
-
ValidateAttributeValueDataType
Validates the data type of attribute values.
-
ValidateElementValueDataType
Validates the data type of element values.
-
UseSchemaNamespaces
Uses schema namespaces during validation.
-
SkipValidation
Skips the validation process entirely. This is equivalent to not performing validation.
-
AutoValidate
Automatically validates the document if a schema is available.
Remarks
The ValidationFlags
enumeration is used with the XmlReaderSettings.ValidationFlags property to configure how XML schema validation is performed. Multiple flags can be combined using the bitwise OR operator (|
).
Example Usage
The following code snippet demonstrates how to set validation flags on an XmlReaderSettings
object:
using System.Xml;
// Create XmlReaderSettings
XmlReaderSettings settings = new XmlReaderSettings();
// Configure validation behavior
settings.ValidationType = ValidationType.Schema;
settings.ValidationFlags =
ValidationFlags.ProcessSchemaLocation |
ValidationFlags.ReportValidation |
ValidationFlags.CheckCharacters;
// Create an XmlReader with the specified settings
using (XmlReader reader = XmlReader.Create("myDocument.xml", settings))
{
while (reader.Read())
{
// Process the XML content
}
}