Saxon/C  1.0.1
Saxon Processor library for C/C++
 All Classes Functions Variables
Public Member Functions | List of all members
SchemaValidator Class Reference

#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)
void setOutputFile (const char *outputFile)
void validate (const char *sourceFile=NULL)
XdmNodevalidateToNode (const char *sourceFile=NULL)
 Validate an instance document supplied as a Source object. More...
void setSourceNode (XdmNode *source)
 Set the source node for validation. More...
XdmNodegetValidationReport ()
 Get the Validation report. More...
void setParameter (const char *name, XdmValue *value)
bool removeParameter (const char *name)
void setProperty (const char *name, const char *value)
void clearParameters (bool deleteValues=false)
void clearProperties ()
std::map< std::string,
XdmValue * > & 
getParameters ()
std::map< std::string,
std::string > & 
getProperties ()
bool exceptionOccurred ()
const char * checkException ()
 Check for exception thrown. More...
void exceptionClear ()
 Clear any exception thrown.
int exceptionCount ()
 Get number of errors during validation of the source against the schema. More...
const char * getErrorMessage (int i)
 Get the ith error message if there are any validation errors. More...
const char * getErrorCode (int i)
 Get the i'th error code if there are any error. More...

Detailed Description

An SchemaValidator represents factory for validating instance documents against a schema.

Constructor & Destructor Documentation

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.

cwd- set the current working directory

Member Function Documentation

const char * SchemaValidator::checkException ( )

Check for exception thrown.

char*. Returns the main exception message if thrown otherwise return NULL
void SchemaValidator::clearParameters ( bool  deleteValues = false)

Clear parameter values set

deleteValues.Individual pointers to XdmValue objects have to be deleted in the calling program Default behaviour (false) is to leave XdmValues in memory true then XdmValues are deleted
void SchemaValidator::clearProperties ( )

Clear property values set

int SchemaValidator::exceptionCount ( )

Get number of errors during validation of the source against the schema.

int - Count of the exceptions reported during validation
bool SchemaValidator::exceptionOccurred ( )

Checks for pending exceptions without creating a local reference to the exception object

bool - true when there is a pending exception; otherwise return false
const char * SchemaValidator::getErrorCode ( int  i)

Get the i'th error code if there are any error.

Validation error are reported as exceptions. All errors can be retrieved.

char* - The error code of the i'th exception.
const char * SchemaValidator::getErrorMessage ( int  i)

Get the ith error message if there are any validation errors.

May have a number of validation errors reported against it the source.

char* - The message of the i'th exception
std::map< std::string, XdmValue * > & SchemaValidator::getParameters ( )

Get all parameters as a std::map

std::map< std::string, std::string > & SchemaValidator::getProperties ( )

Get all properties as a std::map

XdmNode * SchemaValidator::getValidationReport ( )

Get the Validation report.

The valdiation-report option must have been set to true in the properties to use this feature.

XdmNode - Pointer to XdmNode. Return NULL if validation reporting feature has not been enabled
void SchemaValidator::registerSchemaFromFile ( const char *  xsd)

Register the schema from file name.

Set the current working directory for the Schema Validator

xsd- File name of the schema relative to the cwd
bool SchemaValidator::removeParameter ( const char *  name)

Remove a parameter (name, value) pair

nameof the parameter
bool - outcome of the romoval
void SchemaValidator::setcwd ( const char *  cwd)

Set the Current working Directory.

Set the current working directory for the Schema Validator

cwdSupplied working directory which replaces any set cwd. Ignore if cwd is NULL.
void SchemaValidator::setOutputFile ( const char *  outputFile)

Set the name of the file where output from the validator will be sent.

outputFilethe output file name for later use
void SchemaValidator::setParameter ( const char *  name,
XdmValue value 

Set a parameter value used in the validator s

nameof the parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name"
valueof the query parameter, or null to clear a previously set value
void SchemaValidator::setProperty ( const char *  name,
const char *  value 

Set a property.

nameof the property
valueof the property
void SchemaValidator::setSourceNode ( XdmNode source)

Set the source node for validation.

sourcepointer to the XdmNode object
void SchemaValidator::validate ( const char *  sourceFile = NULL)

Validate an instance document by a registered schema.

sourceFileName of the file to be validated. Allow null when source document is supplied with other method
XdmNode * SchemaValidator::validateToNode ( const char *  sourceFile = NULL)

Validate an instance document supplied as a Source object.

sourceFileThe name of the fiel to be validated. Default is NULL
XdmNode - the validated document returned to the calling program

The documentation for this class was generated from the following files: