In This Article

XmlValidator Class

Provides a class that can validate XML, using the schemas in an IXmlSchemaResolver if available.

public class XmlValidator : IXmlValidator
Inheritance:
System.Object Object
Implements:
IXmlValidator

Remarks

Instances of this object can be registered with an ISyntaxLanguage using the RegisterService(Object, Object) method. Once an instance is registered with the language for the IXmlValidator interface type, its features can be used by the language.

Constructors

XmlValidator()

public XmlValidator()

Properties

DtdPath

Gets or sets the path to the folder where DTDs are located.

public string DtdPath { get; set; }

Property Value

System.String:

The path to the folder where DTDs are located.

Remarks

This property is only used when the Mode property is set to Dtd or SchemaWithDtd. If this property is left null, no explicit base path will be set for DTD loading. If this property is set, it should be the path to the folder that contains the DTDs that may be referenced.

Mode

Gets or sets the validation mode used by the validator.

public XmlValidationMode Mode { get; set; }

Property Value

XmlValidationMode:

The validation mode used by the validator. The default value is Schema.

Methods

CreateXmlReader(TextReader, XmlReaderSettings, XmlParserContext)

Creates the System.Xml.XmlReader to use for validation purposes.

protected virtual XmlReader CreateXmlReader(TextReader reader, XmlReaderSettings settings, XmlParserContext context)
Parameter Type Description
reader System.IO.TextReader

The base System.IO.TextReader to use for reading text.

settings System.Xml.XmlReaderSettings

The System.Xml.XmlReaderSettings to use.

context System.Xml.XmlParserContext

The System.Xml.XmlParserContext to use.

Returns

System.Xml.XmlReader:

The System.Xml.XmlReader that was created.

Remarks

Override this method to customize the System.Xml.XmlReader used during XML validation.

IsValidationExceptionAllowed(ValidationEventArgs)

Returns whether the exception specified in the System.Xml.Schema.ValidationEventArgs should be reported.

protected virtual bool IsValidationExceptionAllowed(ValidationEventArgs e)
Parameter Type Description
e System.Xml.Schema.ValidationEventArgs

The System.Xml.Schema.ValidationEventArgs to examine.

Returns

System.Boolean:

true if the exception should be reported; otherwise, false.

Validate(IParseRequest, IAstNode)

Validates the XML that is being parsed.

public IEnumerable<IParseError> Validate(IParseRequest request, IAstNode ast)
Parameter Type Description
request IParseRequest

The IParseRequest that contains data about the requested parsing operation.

ast IAstNode

The root IAstNode of the parse result AST, if known.

Returns

System.Collections.Generic.IEnumerable<IParseError>:

The collection of validation errors that were found, if any.

Inherited Members

  • System.Object.ToString()
  • System.Object.Equals(System.Object)
  • System.Object.Equals(System.Object, System.Object)
  • System.Object.ReferenceEquals(System.Object, System.Object)
  • System.Object.GetHashCode()
  • System.Object.GetType()
  • System.Object.MemberwiseClone()