Class DocumentBuilder
Class DomDestination
Class DynamicContext
Class DynamicError
Class EmptyEnumerator
Class ExtensionFunctionCall
Class InvalidityHandlerWrapper
Class NamespaceConstant
Class NullDestination
Class Processor
Class QName
Class SchemaManager
Class SchemaValidator
Class Serializer
Class StandardLogger
Class StaticContext
Class StaticError
Class TextWriterDestination
Class XPathCompiler
Class XPathExecutable
Class XPathSelector
Class XQueryCompiler
Class XQueryEvaluator
Class XQueryExecutable
Class XdmAnyFunctionType
Class XdmAnyItemType
Class XdmAnyNodeType
Class XdmAtomicType
Class XdmAtomicValue
Class XdmDestination
- Class TreeProtector
Class XdmEmptySequence
Class XdmFunctionItem
Class XdmItem
Class XdmItemType
Class XdmNode
Class XdmNodeKind
Class XdmSequenceType
Class XdmValue
Class XmlDestination
Class Xslt30Transformer
Class XsltCompiler
Class XsltExecutable
- Class ParameterDetails
Class XsltPackage
Class XsltTransformer
Enum RecoveryPolicy
Enum SchemaValidationMode
Enum TreeModel
Enum WhitespacePolicy
Enum XdmAxis
Interface IInvalidityHandler
Interface IMessageListener
Interface IQueryResolver
Interface IResultDocumentHandler
Interface IXdmEnumerator
Interface IXmlLocation
Interface SchemaResolver
public class SchemaValidator
A SchemaValidator
is an object that is used for validating instance documents
against a schema. The schema consists of the collection of schema components that
are
available within the schema cache maintained by the SchemaManager
, together with
any additional schema components located during the course of validation by means
of an
xsl:schemaLocation
or xsi:noNamespaceSchemaLocation
attribute within the
instance document.
If validation fails, an exception is thrown. If validation succeeds, the validated document can optionally be written to a specified destination. This will be a copy of the original document, augmented with default values for absent elements and attributes, and carrying type annotations derived from the schema processing. Saxon does not deliver the full PSVI as described in the XML schema specifications, only the subset of the PSVI properties featured in the XDM data model.
Property Summary | |
---|---|
bool |
IsLax The validation mode may be either strict or lax. The default is strict; this property is set to indicate that lax validation is required. With strict validation, validation fails if no element declaration can be located for the outermost element. With lax validation, the absence of an element declaration results in the content being considered valid. |
Boolean |
UseXsiSchemaLocation
This property defines whether the schema processor will recognize, and attempt to
dereference, any |
IList |
ErrorList List of errors. The caller may supply an empty list before calling Compile; the processor will then populate the list with error information obtained during the schema compilation. Each error will be included as an object of type StaticError. If no error list is supplied by the caller, error information will be written to the standard error stream. |
Method Summary | |
---|---|
void |
SetValidityReporting(XmlDestination destination) Setup Validation Reporting feature which saves the validation errors in an XML file |
void |
SetInvalidityHandler(IInvalidityHandler inHandler) Set the InvalidityHandler to be used when validating instance documents |
void |
AddSource(System.IO.Stream source, System.Uri baseUri) Add an instance document to the list of documents to be validated. |
void |
AddSource(System.Uri uri) Add an instance document to the list of documents to be validated |
void |
AddSource(System.Xml.XmlReader reader) Add an instance document to the list of documents to be validated |
void |
AddSource(XdmNode source) Add an instance document to the list of documents to be validated. |
void |
SetSource(System.IO.Stream source, System.Uri baseUri) Supply the instance document to be validated in the form of a Stream |
void |
SetSource(System.Uri uri) Supply the instance document to be validated in the form of a Uri reference |
void |
SetSource(System.Xml.XmlReader reader) Supply the instance document to be validated, in the form of an XmlReader. |
void |
SetSource(XdmNode source) Supply the instance document to be validated in the form of an XdmNode |
void |
SetDestination(XmlDestination destination) Supply the destination to hold the validated document. If no destination is supplied, the validated document is discarded. |
void |
Run() Run the validation of the supplied source document, optionally writing the validated document to the supplied destination. |
Property Detail |
---|
public bool IsLax {get; set; }
The validation mode may be either strict or lax. The default is strict; this property is set to indicate that lax validation is required. With strict validation, validation fails if no element declaration can be located for the outermost element. With lax validation, the absence of an element declaration results in the content being considered valid.
public Boolean UseXsiSchemaLocation {get; set; }
This property defines whether the schema processor will recognize, and attempt to
dereference, any xsi:schemaLocation
and xsi:noNamespaceSchemaLocation
attributes encountered in the instance document. The default value is true.
public IList ErrorList {get; set; }
List of errors. The caller may supply an empty list before calling Compile; the processor will then populate the list with error information obtained during the schema compilation. Each error will be included as an object of type StaticError. If no error list is supplied by the caller, error information will be written to the standard error stream.
By supplying a custom List with a user-written add() method, it is possible to intercept error conditions as they occur.
Note that this error list is used only for errors detected while using the schema to validate a source document. It is not used to report errors in the schema itself.
Method Detail |
---|
Set the InvalidityHandler to be used when validating instance documents
Parameters:inHandler
-
Add an instance document to the list of documents to be validated.
Parameters:source
-
baseUri
-
Add an instance document to the list of documents to be validated
Parameters:uri
-
Add an instance document to the list of documents to be validated
Parameters:reader
-
Add an instance document to the list of documents to be validated.
Parameters:source
-
Supply the instance document to be validated in the form of a Stream
Parameters:source
-
baseUri
-
xsi:schemaLocation
Supply the instance document to be validated in the form of a Uri reference
Parameters:uri
-
Supply the instance document to be validated, in the form of an XmlReader.
The XmlReader is responsible for parsing the document; this method validates it.
Parameters:reader
-
XmlReader
used to read and parse the instance
document being validated. This is used as supplied. For conformance, use of a
plain XmlTextReader
is discouraged, because it does not expand entity
references. This may cause validation failures.
Supply the instance document to be validated in the form of an XdmNode
The supplied node must be either a document node or an element node. If an element node is supplied, then the subtree rooted at this element is validated as if it were a complete document: that is, it must not only conform to the structure required of that element, but any referential constraints (keyref, IDREF) must be satisfied within that subtree.
Parameters:source
-
Supply the destination to hold the validated document. If no destination is supplied, the validated document is discarded.
The destination differs from the source in that (a) default values of missing elements and attributes are supplied, and (b) the typed values of elements and attributes are available. However, typed values can only be accessed if the result is represented using the XDM data model, that is, if the destination is supplied as an XdmDestination.
Parameters:destination
-
Run the validation of the supplied source document, optionally writing the validated document to the supplied destination.
Setup Validation Reporting feature which saves the validation errors in an XML file
Parameters:destination
-