Class SchematronProcessor
SchematronProcessor is the centerpiece of Schematron4Net: it is used to load Schematron rules and to validate XML documents against these rules.
Inheritance
Implements
Inherited Members
Namespace: Schematron4Net
Assembly: Schematron4Net.dll
Syntax
public class SchematronProcessor : IDisposable
Methods
Dispose()
Performs tasks associated with freeing, releasing, or resetting resources.
Declaration
public void Dispose()
LoadFile(String)
Creates a SchematronProcessor that is based on Schematron rules from a file.
Declaration
public static SchematronProcessor LoadFile(string schematronFilepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | schematronFilepath | File path for the file containing the primary Schematron. Includes will be resolved relative to this path. |
Returns
Type | Description |
---|---|
SchematronProcessor | An instance of SchematronProcessor that is ready to perform a validation. |
Remarks
Using either a zip file or a zip stream are the preferred ways to handle non-self-contained Schematrons (i.e. using includes or doc() references).
LoadZipFile(String, String)
Creates a SchematronProcessor that is based on Schematron rules from a zip archive that is stored as a file.
Declaration
public static SchematronProcessor LoadZipFile(string zipFilepath, string schematronPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | zipFilepath | File path for the file containing a zip archive with the Schematron rules. |
System.String | schematronPath | Path to the primary Schematron (relative to the root of the zip archive). |
Returns
Type | Description |
---|---|
SchematronProcessor | An instance of SchematronProcessor that is ready to perform a validation. |
Remarks
Using either a zip file or a zip stream are the preferred ways to handle non-self-contained Schematrons (i.e. that are using includes or doc() references). This method will fail when running under older Mono versions due to a bug in Mono's implementation of System.IO.Compression, in this case use LoadZipFileMono(String, String) instead.
LoadZipFileMono(String, String)
Creates a SchematronProcessor that is based on Schematron rules from a zip archive that is stored as a file - special implementation for older Mono versions.
Declaration
public static SchematronProcessor LoadZipFileMono(string zipFilepath, string schematronPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | zipFilepath | File path for the file containing a zip archive with the Schematron rules. |
System.String | schematronPath | Path to the primary Schematron (relative to the root of the zip archive). |
Returns
Type | Description |
---|---|
SchematronProcessor | An instance of SchematronProcessor that is ready to perform a validation. |
Remarks
Using either a zip file or a zip stream are the preferred ways to handle non-self-contained Schematrons (i.e. that are using includes or doc() references). This method is slower than the method LoadZipFile(String, String), so use it only when you are planning to run with older Mono versions.
LoadZipStream(Stream, String)
Creates a SchematronProcessor that is based on Schematron rules from a zip stream.
Declaration
public static SchematronProcessor LoadZipStream(Stream zipStream, string schematronPath)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | zipStream | Stream for reading the zip archive. This can be a read-only stream. |
System.String | schematronPath | Path to the primary Schematron (relative to the root of the zip archive). |
Returns
Type | Description |
---|---|
SchematronProcessor | An instance of SchematronProcessor that is ready to perform a validation. |
Remarks
Using either a zip file or a zip stream are the preferred ways to handle non-self-contained Schematrons (i.e. that are using includes or doc() references). You can embed a Schematron package in the calling program and provide a ZIP stream via GetManifestResourceStream() to this method. This method will fail when running under older Mono versions due to a bug in Mono's implementation of System.IO.Compression, in this case use LoadZipStreamMono(Stream, String) instead.
LoadZipStreamMono(Stream, String)
Creates a SchematronProcessor that is based on Schematron rules from a zip stream - special implementation for older Mono versions.
Declaration
public static SchematronProcessor LoadZipStreamMono(Stream zipStream, string schematronPath)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | zipStream | Stream for reading the zip archive. This can be a read-only stream. |
System.String | schematronPath | Path to the primary Schematron (relative to the root of the zip archive). |
Returns
Type | Description |
---|---|
SchematronProcessor | An instance of SchematronProcessor that is ready to perform a validation. |
Remarks
Using either a zip file or a zip stream are the preferred ways to handle non-self-contained Schematrons (i.e. that are using includes or doc() references). You can embed a Schematron package in the calling program and provide a ZIP stream via GetManifestResourceStream() to this method. This method is slower than the method LoadZipStream(Stream, String), so use it only when you are planning to run with older Mono versions.
Validate(XDocument, ValidationOptions)
Validates a XML document against previously loaded Schematron rules and returns a validation result (but no validation report).
Declaration
public ValidationResult Validate(XDocument xmlDocument, ValidationOptions validationOptions = null)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.Linq.XDocument | xmlDocument | The XML document that is to be validated. |
ValidationOptions | validationOptions | Options to control the validation process. If not specified, default validation options will be used. |
Returns
Type | Description |
---|---|
ValidationResult | The result of this validation. |
See Also
Validate(XDocument, out XDocument, ValidationOptions)
Validates a XML document against previously loaded Schematron rules and returns a validation result as well as a validation report (SVRL).
Declaration
public ValidationResult Validate(XDocument xmlDocument, out XDocument validationReport, ValidationOptions validationOptions = null)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.Linq.XDocument | xmlDocument | The XML document that is to be validated. |
System.Xml.Linq.XDocument | validationReport | The validation report. |
ValidationOptions | validationOptions | Options to control the validation process. If not specified, default validation options will be used. |
Returns
Type | Description |
---|---|
ValidationResult | The result of this validation. |