Class XmlDocumentValidator
A validator class that makes easier to validate XML documents against XML schemas.
Inheritance
Implements
Inherited Members
Namespace: Juhta.Net.Validation
Assembly: Juhta.Net.Validation.dll
Syntax
public class XmlDocumentValidator : IValidator<XmlDocument>
Constructors
| Improve this Doc View SourceXmlDocumentValidator()
Initializes a new instance.
Declaration
public XmlDocumentValidator()
Methods
| Improve this Doc View SourceAddSchema(String)
Adds an XML schema to this validator instance.
Declaration
public void AddSchema(string schema)
Parameters
Type | Name | Description |
---|---|---|
System.String | schema | Specifies an XML schema string. |
AddSchema(Uri)
Adds an XML schema to this validator instance.
Declaration
public void AddSchema(Uri schemaUri)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | schemaUri | Specifies the URI of a schema to be added to the instance. |
AddSchema(XmlSchema)
Adds an XML schema to this validator instance.
Declaration
public void AddSchema(XmlSchema schema)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.Schema.XmlSchema | schema | Specifies an XmlSchema object. |
Validate(XmlDocument)
Validates a specified XML document.
Declaration
public void Validate(XmlDocument document)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | document | Specifies an System.Xml.XmlDocument object. |
Remarks
If the XML document contains validation errors, the method collects the corresponding exceptions to an exception chain of the type System.Xml.Schema.XmlSchemaValidationException. This exception chain will be thrown as an inner exception of ValidationException after the validation process is finished.
Validate(XmlDocument, String)
Validates a specified XML document against a specified XML schema.
Declaration
public static void Validate(XmlDocument document, string schema)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | document | Specifies an XmlDocument object. |
System.String | schema | Specifies an XML schema as a string. |
Remarks
If the XML document contains validation errors, the function collects the corresponding exceptions to an exception chain of the type XmlSchemaValidationException. This exception chain will be thrown after the validation process is finished.
Validate(XmlDocument, XmlSchema)
Validates a specified XML document against a specified XML schema.
Declaration
public static void Validate(XmlDocument document, XmlSchema schema)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | document | Specifies an XmlDocument object. |
System.Xml.Schema.XmlSchema | schema | Specifies an XmlSchema object. |
Remarks
If the XML document contains validation errors, the function collects the corresponding exceptions to an exception chain of the type XmlSchemaValidationException. This exception chain will be thrown after the validation process is finished.