XmlValidator Class
Provides a class that can validate XML, using the schemas in an IXmlSchemaResolver if available.
public class XmlValidator : IXmlValidator
- Inheritance:
- 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()
Initializes an instance of the class.
public XmlValidator()
Properties
DtdPath
The path to the folder where DTDs are located.
public string? DtdPath { get; set; }
Property Value
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
The validation mode used by the validator.
public XmlValidationMode Mode { get; set; }
Property Value
- XmlValidationMode:
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 | TextReader | The base TextReader to use for reading text. |
| settings | XmlReaderSettings | The System.Xml.XmlReaderSettings to use. |
| context | XmlParserContext | The System.Xml.XmlParserContext to use. |
Returns
- 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 | ValidationEventArgs | The System.Xml.Schema.ValidationEventArgs to examine. |
Returns
- bool:
trueif the exception should be reported; otherwise,false.
Validate(IParseRequest, IAstNode?)
Provides the base requirements for a class that can validate XML.
public IEnumerable<IParseError>? Validate(IParseRequest request, IAstNode? ast)
| Parameter | Type | Description |
|---|---|---|
| request | IParseRequest | |
| ast | IAstNode |
Returns
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.
See Also
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()