SaxonC
11.6
Saxon Processor library for C/C++, PHP and Python
|
#include <SchemaValidator.h>
Public Member Functions | |
SchemaValidator () | |
Default constructor. More... | |
SchemaValidator (SaxonProcessor *proc, std::string cwd="") | |
A constructor with a SaxonProcessor. More... | |
void | setcwd (const char *cwd) |
Set the Current working Directory. More... | |
void | registerSchemaFromFile (const char *xsd) |
Register the schema from file name. More... | |
void | registerSchemaFromString (const char *schemaStr) |
Register the schema supplied as a string. More... | |
void | exportSchema (const char *fileName) |
Export a precompiled Schema Component Model containing all the components (except built-in components) that have been loaded by using the register methods. More... | |
void | setOutputFile (const char *outputFile) |
Set the name of the output file that will be used by the validator. More... | |
void | validate (const char *sourceFile=nullptr) |
Validate an instance document by a registered schema. More... | |
XdmNode * | validateToNode (const char *sourceFile=nullptr) |
Validate an instance document supplied as a Source object. More... | |
void | setSourceNode (XdmNode *source) |
Set the source node for validation. More... | |
XdmNode * | getValidationReport () |
Get the Validation report. More... | |
void | setParameter (const char *name, XdmValue *value) |
Set a parameter value used in the validator. More... | |
bool | removeParameter (const char *name) |
Remove a parameter (name, value) pair. More... | |
void | setProperty (const char *name, const char *value) |
Set a property. More... | |
void | clearParameters (bool deleteValues=false) |
Clear parameter values set. More... | |
void | clearProperties () |
Clear property values set. | |
std::map< std::string, XdmValue * > & | getParameters () |
Get all parameters as a std::map. | |
std::map< std::string, std::string > & | getProperties () |
Get all properties as a std::map. | |
bool | exceptionOccurred () |
Checks for pending exceptions without creating a local reference to the exception object. More... | |
const char * | checkException () |
Check for exception thrown. More... | |
void | exceptionClear () |
Clear any exception thrown. | |
const char * | getErrorMessage (int i) |
Get number of errors during validation of the source against the schema. More... | |
const char * | getErrorCode (int i) |
Get the i'th error code if errors are reported. More... | |
void | setLax (bool l) |
The validation mode may be either strict or lax. More... | |
jobject | getUnderlyingValidator () |
Get the underlying java object of the C++ schema validator. | |
The SchemaValidator
represents factory for validating instance documents against a schema.
SchemaValidator::SchemaValidator | ( | ) |
Default constructor.
Creates Schema Validator
SchemaValidator::SchemaValidator | ( | SaxonProcessor * | proc, |
std::string | cwd = "" |
||
) |
A constructor with a SaxonProcessor.
The supplied processor should have license flag set to true for the Schema Validator to operate.
proc | - the SaxonProcessor |
cwd | - set the current working directory |
const char * SchemaValidator::checkException | ( | ) |
Check for exception thrown.
void SchemaValidator::clearParameters | ( | bool | deleteValues = false | ) |
Clear parameter values set.
Default behaviour (false) is to leave XdmValues in memory. Individual pointers to XdmValue objects have to be deleted in the calling program.
deleteValues | - if true then XdmValues are deleted |
bool SchemaValidator::exceptionOccurred | ( | ) |
Checks for pending exceptions without creating a local reference to the exception object.
void SchemaValidator::exportSchema | ( | const char * | fileName | ) |
Export a precompiled Schema Component Model containing all the components (except built-in components) that have been loaded by using the register methods.
fileName | - The file name where the exported schema will be stored |
const char * SchemaValidator::getErrorCode | ( | int | i | ) |
Get the i'th error code if errors are reported.
Validation error are reported as exceptions. All errors can be retrieved.
const char * SchemaValidator::getErrorMessage | ( | int | i | ) |
Get number of errors during validation of the source against the schema.
XdmNode * SchemaValidator::getValidationReport | ( | ) |
void SchemaValidator::registerSchemaFromFile | ( | const char * | xsd | ) |
Register the schema from file name.
The schema components derived from this schema document are added to the cache of schema components maintained by this SchemaManager
xsd | - File name of the schema relative to the cwd or full path if cwd is null. The document may be either a schema document in source XSD format, or a compiled schema in Saxon-defined SCM format (as produced using the method exportSchema) |
void SchemaValidator::registerSchemaFromString | ( | const char * | schemaStr | ) |
Register the schema supplied as a string.
schemaStr | - The schema document supplied as a string |
bool SchemaValidator::removeParameter | ( | const char * | name | ) |
Remove a parameter (name, value) pair.
name | of the parameter |
void SchemaValidator::setcwd | ( | const char * | cwd | ) |
Set the Current working Directory.
Set the current working directory for the Schema Validator
cwd | - Supplied working directory which replaces any set cwd. Ignore if cwd is NULL. |
|
inline |
The validation mode may be either strict or lax.
The default is strict; this method may be called 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.
l | - true if validation is to be lax, false if it is to be strict |
void SchemaValidator::setOutputFile | ( | const char * | outputFile | ) |
Set the name of the output file that will be used by the validator.
outputFile | the output file name for later use |
void SchemaValidator::setParameter | ( | const char * | name, |
XdmValue * | value | ||
) |
Set a parameter value used in the validator.
name | of the parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name" |
value | of the query parameter, or nullptr to clear a previously set value |
void SchemaValidator::setProperty | ( | const char * | name, |
const char * | value | ||
) |
Set a property.
name | of the property |
value | of the property |
void SchemaValidator::setSourceNode | ( | XdmNode * | source | ) |
Set the source node for validation.
source | - The source document supplied as an XdmNode, which will be used to validate against the schema using the validate methods. |
void SchemaValidator::validate | ( | const char * | sourceFile = nullptr | ) |
Validate an instance document by a registered schema.
sourceFile | Name of the file to be validated. Allow nullptr when source document is supplied with other method |
XdmNode * SchemaValidator::validateToNode | ( | const char * | sourceFile = nullptr | ) |
Validate an instance document supplied as a Source object.
sourceFile | The name of the file to be validated. Default is nullptr |