Class DocumentBuilder
Class DomDestination
Class DynamicContext
Class DynamicError
Class EmptyEnumerator
Class ExtensionFunctionCall
Class NullDestination
Class ParameterDetails
Class Processor
Class QName
Class SchemaManager
Class SchemaValidator
Class Serializer
Class StandardLogger
Class StaticContext
Class StaticError
Class TextWriterDestination
Class TreeProtector
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 XdmEmptySequence
Class XdmFunctionItem
Class XdmItem
Class XdmItemType
Class XdmNode
Class XdmNodeKind
Class XdmSequenceType
Class XdmValue
Class XmlDestination
Class Xslt30Transformer
Class XsltCompiler
Class XsltExecutable
Class XsltPackage
Class XsltTransformer
Enum RecoveryPolicy
Enum SchemaValidationMode
Enum TreeModel
Enum WhitespacePolicy
Enum XdmAxis
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 |
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 |
---|
public void SetSource(System.IO.Stream source, System.Uri baseUri)
Supply the instance document to be validated in the form of a Stream
Parameters:source
-
baseUri
-
xsi:schemaLocation
public void SetSource(System.Uri uri)
Supply the instance document to be validated in the form of a Uri reference
Parameters:uri
-
public void SetSource(System.Xml.XmlReader reader)
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.
public void SetSource(XdmNode source)
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
-
public void SetDestination(XmlDestination destination)
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
-
public void Run()
Run the validation of the supplied source document, optionally writing the validated document to the supplied destination.