SaxonC  11.6
Saxon Processor library for C/C++, PHP and Python
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Friends | List of all members
SaxonProcessor Class Reference

The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers. More...

#include <SaxonProcessor.h>

Public Member Functions

 SaxonProcessor ()
 A default constructor. More...
 
 SaxonProcessor (const char *configFile)
 constructor based upon a Saxon configuration file. More...
 
 SaxonProcessor (bool l)
 A constructor. More...
 
SaxonProcessoroperator= (const SaxonProcessor &other)
 The copy assignment= operator. More...
 
 SaxonProcessor (const SaxonProcessor &other)
 SaxonProcessor copy constructor. More...
 
 ~SaxonProcessor ()
 Destructor method. At the end of the program call the release() method to clear the JVM.
 
const char * getErrorMessage ()
 Get any error message thrown by the processor. More...
 
DocumentBuildernewDocumentBuilder ()
 Create a DocumentBuilder. More...
 
Xslt30ProcessornewXslt30Processor ()
 Create an Xslt30Processor. More...
 
XQueryProcessornewXQueryProcessor ()
 Create an XQueryProcessor. More...
 
XPathProcessornewXPathProcessor ()
 Create an XPathProcessor. An XPathProcessor is used to compile XPath expressions. More...
 
SchemaValidatornewSchemaValidator ()
 Create a SchemaValidator which can be used to validate instance documents against the schema held by this SchemaManager. More...
 
XdmAtomicValuemakeStringValue (std::string str)
 Factory method. Unlike the constructor, this avoids creating a new StringValue in the case. More...
 
XdmAtomicValuemakeStringValue (const char *str)
 Factory method. Unlike the constructor, this avoids creating a new StringValue in the case. More...
 
XdmAtomicValuemakeIntegerValue (int i)
 
XdmAtomicValuemakeDoubleValue (double d)
 Factory method. make an XdmAtomicValue from a primitive double value. More...
 
XdmAtomicValuemakeFloatValue (float f)
 Factory method. make an XdmAtomicValue from a primitive float value. More...
 
XdmAtomicValuemakeLongValue (long l)
 Factory method: makes either an Int64Value or a BigIntegerValue depending on the value supplied. More...
 
XdmAtomicValuemakeBooleanValue (bool b)
 Factory method: makes a XdmAtomicValue representing a boolean Value. More...
 
XdmAtomicValuemakeQNameValue (const char *str)
 Create an QName Xdm value from string representation in clark notation. More...
 
XdmAtomicValuemakeAtomicValue (const char *type, const char *value)
 Create an Xdm Atomic value from string representation. More...
 
XdmArraymakeArray (const char **input, int length)
 Make an XdmArray whose members are from string representation. More...
 
XdmArraymakeArray (short *input, int length)
 Make an XdmArray whose members are xs:short values. More...
 
XdmArraymakeArray (int *input, int length)
 Make an XdmArray whose members are xs:int values. More...
 
XdmArraymakeArray (long *input, int length)
 Make an XdmArray whose members are xs:long values. More...
 
XdmArraymakeArray (bool *input, int length)
 
XdmArraymakeArray (XdmValue **values, int length)
 Make an XdmArray whose members are of type XdmValue. More...
 
XdmMapmakeMap (std::map< XdmAtomicValue *, XdmValue * > dataMap)
 Make an XdmMap whose argument is a map from the standard template library. More...
 
XdmMapmakeMap3 (XdmAtomicValue **keys, XdmValue **values, int len)
 Make an XdmMap from an array of keys and values. More...
 
const char * getStringValue (XdmItem *item)
 Get the string representation of the XdmValue. More...
 
XdmNodeparseXmlFromString (const char *source, SchemaValidator *validator=nullptr)
 Parse a lexical representation of the source document and return it as an XdmNode. More...
 
XdmNodeparseXmlFromFile (const char *source, SchemaValidator *validator=nullptr)
 Parse a source document file and return it as an XdmNode. More...
 
XdmNodeparseXmlFromUri (const char *source, SchemaValidator *validator=nullptr)
 Parse a source document available by URI and return it as an XdmNode. More...
 
int getNodeKind (jobject obj)
 Get the kind of node. More...
 
bool isSchemaAwareProcessor ()
 Test whether this processor is schema-aware. More...
 
bool exceptionOccurred ()
 Checks for thrown exceptions. More...
 
void exceptionClear ()
 Clears any exception that is currently being thrown. If no exception is currently being thrown, this routine has no effect.
 
XdmValue ** createXdmValueArray (int len)
 Utility method for working with SaxonC on Python.
 
XdmAtomicValue ** createXdmAtomicValueArray (int len)
 Utility method for working with SaxonC on Python.
 
void setcwd (const char *cwd)
 Set the current working directory.
 
const char * getcwd ()
 Get the current working directory. More...
 
const char * getResourcesDirectory ()
 Get saxon resources directory. More...
 
void setResourcesDirectory (const char *dir)
 set saxon resources directory
 
void setCatalog (const char *catalogFile, bool isTracing)
 
void setConfigurationProperty (const char *name, const char *value)
 Set a configuration property specific to the processor in use. More...
 
void clearConfigurationProperties ()
 Clear configuration properties specific to the processor in use.
 
const char * version ()
 Get the Saxon version. More...
 
void addNativeMethod (char *name, char *signature, void *fnPtr)
 Add a native method. More...
 
bool registerCPPFunction (char *libName, JNINativeMethod *gMethods=nullptr)
 Register several native methods for one class. More...
 
SaxonApiExceptioncheckAndCreateException (jclass cppClass)
 Check for exception thrown in the underlying JNI. Then create the SaxonApiException class which the user can retrieve. More...
 

Static Public Member Functions

static XdmAtomicValuemakeStringValue2 (std::string str)
 Factory method. Unlike the constructor, this avoids creating a new StringValue in the case. More...
 
static XdmMapmakeMap2 (std::map< std::string, XdmValue * > dataMap)
 Make an XdmMap whose argument is a map from the standard template library. More...
 
static SaxonApiExceptioncheckForExceptionCPP (JNIEnv *env, jclass callingClass, jobject callingObject)
 Checks for pending exceptions and creates a SaxonApiException object, which handles one or more local exceptions objects. More...
 
static void release ()
 Clean up and destroy Java VM to release memory used. Method to be called at the end of the program.
 
static void attachCurrentThread ()
 Attaches a current thread to the a Java VM.
 
static void detachCurrentThread ()
 Detach JVM from the current thread.
 
static bool registerNativeMethods (JNIEnv *env, const char *className, JNINativeMethod *gMethods, int numMethods)
 Register several native methods for one class. More...
 
static void getInfo ()
 

Public Attributes

std::string cwd
 
jobject proc
 

Static Public Attributes

static int jvmCreatedCPP = 0
 
static sxnc_environmentsxn_environ = 0
 

Protected Attributes

jclass xdmAtomicClass
 
jclass versionClass
 
jclass procClass
 
jclass saxonCAPIClass
 
std::string cwdV
 
std::string versionStr
 
std::map< std::string, XdmValue * > parameters
 
std::map< std::string, std::string > configProperties
 
bool licensei
 
JNINativeMethod * nativeMethods
 
std::vector< JNINativeMethod > nativeMethodVect
 
SaxonApiExceptionexception
 

Friends

class DocumentBuilder
 
class Xslt30Processor
 
class XsltExecutable
 
class XQueryProcessor
 
class SchemaValidator
 
class XPathProcessor
 
class XdmValue
 
class XdmAtomicValue
 
class XdmFunctionItem
 
class XdmNode
 
class XdmMap
 
class XdmArray
 

Detailed Description

The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.

The SaxonProcessor class not only generates XQuery, XPath, Schema and XSLT Processors, but is used to create Xdm objects from primitive types.

Constructor & Destructor Documentation

◆ SaxonProcessor() [1/4]

SaxonProcessor::SaxonProcessor ( )

A default constructor.

Create Saxon Processor.

◆ SaxonProcessor() [2/4]

SaxonProcessor::SaxonProcessor ( const char *  configFile)

constructor based upon a Saxon configuration file.

Create Saxon Processor.

◆ SaxonProcessor() [3/4]

SaxonProcessor::SaxonProcessor ( bool  l)

A constructor.

Create Saxon Processor.

Parameters
l- Flag that a license is to be used. Default is false.

◆ SaxonProcessor() [4/4]

SaxonProcessor::SaxonProcessor ( const SaxonProcessor other)

SaxonProcessor copy constructor.

Parameters
other- SaxonProcessor

Member Function Documentation

◆ addNativeMethod()

void SaxonProcessor::addNativeMethod ( char *  name,
char *  signature,
void *  fnPtr 
)
inline

Add a native method.

Parameters
nameof the native method
signatureof the native method
fnPtrPointer to the native method

◆ checkAndCreateException()

SaxonApiException * SaxonProcessor::checkAndCreateException ( jclass  cppClass)

Check for exception thrown in the underlying JNI. Then create the SaxonApiException class which the user can retrieve.

Parameters
cppClass
Returns
The SaxonApiException with information about the exception thrown

◆ checkForExceptionCPP()

SaxonApiException * SaxonProcessor::checkForExceptionCPP ( JNIEnv *  env,
jclass  callingClass,
jobject  callingObject 
)
static

Checks for pending exceptions and creates a SaxonApiException object, which handles one or more local exceptions objects.

Parameters
env
callingClass
callingObject

◆ exceptionOccurred()

bool SaxonProcessor::exceptionOccurred ( )

Checks for thrown exceptions.

Returns
bool - true when there is a pending exception; otherwise return false

◆ getcwd()

const char * SaxonProcessor::getcwd ( )

Get the current working directory.

Returns
string value of the cwd

◆ getErrorMessage()

const char * SaxonProcessor::getErrorMessage ( )

Get any error message thrown by the processor.

Returns
string value of the error message. JNI exceptions thrown by this processor are handled internally and can be retrived by this method.

◆ getInfo()

static void SaxonProcessor::getInfo ( )
static

Get info on objects allocated and still in memory

◆ getNodeKind()

int SaxonProcessor::getNodeKind ( jobject  obj)

Get the kind of node.

Parameters
obj- The Java object representation of the XdmNode
Returns
the kind of node, for example ELEMENT or ATTRIBUTE

◆ getResourcesDirectory()

const char * SaxonProcessor::getResourcesDirectory ( )

Get saxon resources directory.

Returns
string value of the resource directory

◆ getStringValue()

const char * SaxonProcessor::getStringValue ( XdmItem item)

Get the string representation of the XdmValue.

Parameters
item- The XdmItem
Returns
string value as char array

◆ isSchemaAwareProcessor()

bool SaxonProcessor::isSchemaAwareProcessor ( )

Test whether this processor is schema-aware.

Returns
true if this this processor is licensed for schema processing, false otherwise

◆ makeArray() [1/6]

XdmArray * SaxonProcessor::makeArray ( bool *  input,
int  length 
)

Make an XdmArray whose members are xs:boolean values

Parameters
input- the input array of boolean values
length- the number of items in the array
Returns
an XdmArray whose members are xs:boolean values corresponding one-to-one with the input

◆ makeArray() [2/6]

XdmArray * SaxonProcessor::makeArray ( const char **  input,
int  length 
)

Make an XdmArray whose members are from string representation.

Parameters
inputthe input array of booleans
length- the number of items in the array
Returns
an XdmArray whose members are xs:boolean values corresponding one-to-one with the input

◆ makeArray() [3/6]

XdmArray * SaxonProcessor::makeArray ( int *  input,
int  length 
)

Make an XdmArray whose members are xs:int values.

Parameters
input- the input array of int values
length- the number of items in the array
Returns
an XdmArray whose members are xs:boolean values corresponding one-to-one with the input

◆ makeArray() [4/6]

XdmArray * SaxonProcessor::makeArray ( long *  input,
int  length 
)

Make an XdmArray whose members are xs:long values.

Parameters
input- the input array of long values
length- the number of items in the array
Returns
an XdmArray whose members are xs:boolean values corresponding one-to-one with the input

◆ makeArray() [5/6]

XdmArray * SaxonProcessor::makeArray ( short *  input,
int  length 
)

Make an XdmArray whose members are xs:short values.

Parameters
input- the input array of short values
length- the number of items in the array
Returns
an XdmArray whose members are xs:boolean values corresponding one-to-one with the input

◆ makeArray() [6/6]

XdmArray * SaxonProcessor::makeArray ( XdmValue **  values,
int  length 
)

Make an XdmArray whose members are of type XdmValue.

Parameters
valuesthe input array of XdmValue pointers
length- the number of items in the array
Returns
an XdmArray whose members are XdmValue values corresponding one-to-one with the input

◆ makeAtomicValue()

XdmAtomicValue * SaxonProcessor::makeAtomicValue ( const char *  type,
const char *  value 
)

Create an Xdm Atomic value from string representation.

Parameters
type- Local name of a type in the XML Schema namespace.
value- The value given in a string form. In the case of a QName the value supplied must be in clark notation. {uri}local
Returns
XdmValue - value

◆ makeBooleanValue()

XdmAtomicValue * SaxonProcessor::makeBooleanValue ( bool  b)

Factory method: makes a XdmAtomicValue representing a boolean Value.

Parameters
btrue or false, to determine which boolean value is required
Returns
the XdmAtomicValue requested

◆ makeDoubleValue()

XdmAtomicValue * SaxonProcessor::makeDoubleValue ( double  d)

Factory method. make an XdmAtomicValue from a primitive double value.

Parameters
dthe value of the double
Returns
a new XdmAtomicValue

◆ makeFloatValue()

XdmAtomicValue * SaxonProcessor::makeFloatValue ( float  f)

Factory method. make an XdmAtomicValue from a primitive float value.

Parameters
fthe value of the float
Returns
a new XdmAtomicValue

◆ makeIntegerValue()

XdmAtomicValue * SaxonProcessor::makeIntegerValue ( int  i)

Factory method: makes either an Int64Value or a BigIntegerValue depending on the value supplied

Parameters
ithe supplied primitive integer value
Returns
the value as a XdmAtomicValue which is a BigIntegerValue or Int64Value as appropriate

◆ makeLongValue()

XdmAtomicValue * SaxonProcessor::makeLongValue ( long  l)

Factory method: makes either an Int64Value or a BigIntegerValue depending on the value supplied.

Parameters
lthe supplied primitive long value
Returns
the value as a XdmAtomicValue which is a BigIntegerValue or Int64Value as appropriate

◆ makeMap()

XdmMap * SaxonProcessor::makeMap ( std::map< XdmAtomicValue *, XdmValue * >  dataMap)

Make an XdmMap whose argument is a map from the standard template library.

Parameters
dataMapis std::map, which consists of keys as XdmAtomicValue and value is XdmValue.
Returns
an XdmMap whose members are key, value pair given as (XdmAtomicValue, XdmValue)

◆ makeMap2()

XdmMap * SaxonProcessor::makeMap2 ( std::map< std::string, XdmValue * >  dataMap)
static

Make an XdmMap whose argument is a map from the standard template library.

Parameters
dataMapis std::map, which consists of keys as std::string and value is XdmValue. Keys are converted to XdmAtomicValue objects
Returns
an XdmMap whose members are key, value pair given as (XdmAtomicValue, XdmValue)

◆ makeMap3()

XdmMap * SaxonProcessor::makeMap3 ( XdmAtomicValue **  keys,
XdmValue **  values,
int  len 
)

Make an XdmMap from an array of keys and values.

Parameters
keys- The keys are given as a pointer array of XdmAtomicValue
values- The values are given as a pointer array of XdmValue
len- The length of the arrays given as argument
Returns
an XdmMap whose members are key, value pair given as (XdmAtomicValue, XdmValue)

◆ makeQNameValue()

XdmAtomicValue * SaxonProcessor::makeQNameValue ( const char *  str)

Create an QName Xdm value from string representation in clark notation.

Parameters
str- The value given in a string form in clark notation. {uri}local
Returns
XdmAtomicValue - value

◆ makeStringValue() [1/2]

XdmAtomicValue * SaxonProcessor::makeStringValue ( const char *  str)

Factory method. Unlike the constructor, this avoids creating a new StringValue in the case.

of a zero-length string (and potentially other strings, in future)

Parameters
strthe char pointer array. nullptr is taken as equivalent to "".
Returns
the corresponding StringValue

◆ makeStringValue() [2/2]

XdmAtomicValue * SaxonProcessor::makeStringValue ( std::string  str)

Factory method. Unlike the constructor, this avoids creating a new StringValue in the case.

of a zero-length string (and potentially other strings, in future)

Parameters
strthe String value. NULL is taken as equivalent to "".
Returns
the corresponding StringValue

◆ makeStringValue2()

XdmAtomicValue * SaxonProcessor::makeStringValue2 ( std::string  str)
static

Factory method. Unlike the constructor, this avoids creating a new StringValue in the case.

of a zero-length string (and potentially other strings, in future)

Parameters
strthe std:string
Returns
the corresponding StringValue

◆ newDocumentBuilder()

DocumentBuilder * SaxonProcessor::newDocumentBuilder ( )

Create a DocumentBuilder.

A DocumentBuilder is used to load source XML documents.

Returns
a newly created DocumentBuilder

◆ newSchemaValidator()

SchemaValidator * SaxonProcessor::newSchemaValidator ( )

Create a SchemaValidator which can be used to validate instance documents against the schema held by this SchemaManager.

Returns
a new SchemaValidator

◆ newXPathProcessor()

XPathProcessor * SaxonProcessor::newXPathProcessor ( )

Create an XPathProcessor. An XPathProcessor is used to compile XPath expressions.

Returns
a newly created XPathProcessor

◆ newXQueryProcessor()

XQueryProcessor * SaxonProcessor::newXQueryProcessor ( )

Create an XQueryProcessor.

An XQueryProcessor is used to compile XQuery queries.

Returns
a newly created XQueryProcessor

◆ newXslt30Processor()

Xslt30Processor * SaxonProcessor::newXslt30Processor ( )

Create an Xslt30Processor.

An Xslt30Processor is used to compile XSLT30 stylesheets.

Returns
a newly created Xslt30Processor

◆ operator=()

SaxonProcessor & SaxonProcessor::operator= ( const SaxonProcessor other)

The copy assignment= operator.

Create a copy of the Saxon Processor.

Parameters
other- SaxonProcessor object

◆ parseXmlFromFile()

XdmNode * SaxonProcessor::parseXmlFromFile ( const char *  source,
SchemaValidator validator = nullptr 
)

Parse a source document file and return it as an XdmNode.

Parameters
sourcethe filename of the source document
validator
Returns
an XdmNode

◆ parseXmlFromString()

XdmNode * SaxonProcessor::parseXmlFromString ( const char *  source,
SchemaValidator validator = nullptr 
)

Parse a lexical representation of the source document and return it as an XdmNode.

Parameters
source
validator
Returns
an XdmNode

◆ parseXmlFromUri()

XdmNode * SaxonProcessor::parseXmlFromUri ( const char *  source,
SchemaValidator validator = nullptr 
)

Parse a source document available by URI and return it as an XdmNode.

Parameters
source
validator
Returns
an XdmNode

◆ registerCPPFunction()

bool SaxonProcessor::registerCPPFunction ( char *  libName,
JNINativeMethod *  gMethods = nullptr 
)
inline

Register several native methods for one class.

Parameters
libNamename of the library which contains the function(s). Loads the library
gMethodsRegister native methods. Default is nullptr, also nullptr allowed in which cause assumption is made the user has added native methods using the method addNativeMethod .
Returns
bool success of registered native method

◆ registerNativeMethods()

static bool SaxonProcessor::registerNativeMethods ( JNIEnv *  env,
const char *  className,
JNINativeMethod *  gMethods,
int  numMethods 
)
inlinestatic

Register several native methods for one class.

Parameters
env
className
gMethods
numMethods
Returns
bool success of registered native method

◆ setCatalog()

void SaxonProcessor::setCatalog ( const char *  catalogFile,
bool  isTracing 
)

set catalog to be used in Saxon

◆ setConfigurationProperty()

void SaxonProcessor::setConfigurationProperty ( const char *  name,
const char *  value 
)

Set a configuration property specific to the processor in use.

Properties specified here are common across all the processors. Example 'l':enable line number has the value 'on' or 'off'

Parameters
nameof the property
valueof the property

Set a configuration property.

◆ version()

const char * SaxonProcessor::version ( )

Get the Saxon version.

Returns
char array

Member Data Documentation

◆ configProperties

std::map<std::string, std::string> SaxonProcessor::configProperties
protected

map of properties used for the transformation as (string, string) pairs

◆ cwd

std::string SaxonProcessor::cwd

current working directory

◆ cwdV

std::string SaxonProcessor::cwdV
protected

current working directory

◆ exception

SaxonApiException* SaxonProcessor::exception
protected

SaxonApiException object to capture exceptions thrown from the underlying Java code via JNI

◆ jvmCreatedCPP

int SaxonProcessor::jvmCreatedCPP = 0
static

Flag to indicate jvm created - used in memory management

◆ licensei

bool SaxonProcessor::licensei
protected

indicates whether the Processor requires a Saxon that needs a license file (i.e. Saxon-EE) other a Saxon-HE Processor is created

◆ nativeMethods

JNINativeMethod* SaxonProcessor::nativeMethods
protected

native methods variable used in extension methods

◆ nativeMethodVect

std::vector<JNINativeMethod> SaxonProcessor::nativeMethodVect
protected

Vector of native methods defined by user

◆ parameters

std::map<std::string, XdmValue *> SaxonProcessor::parameters
protected

map of parameters used for the transformation as (string, value) pairs

◆ proc

jobject SaxonProcessor::proc

Java Processor object

◆ procClass

jclass SaxonProcessor::procClass
protected

The SAxon Processor instance

◆ saxonCAPIClass

jclass SaxonProcessor::saxonCAPIClass
protected

The SaxonCAPI instance

◆ sxn_environ

sxnc_environment * SaxonProcessor::sxn_environ = 0
static

Environment to captures the jni, JVM and handler to the cross compiled SaxonC library.

◆ versionClass

jclass SaxonProcessor::versionClass
protected

The Version instance

◆ versionStr

std::string SaxonProcessor::versionStr
protected

The Saxon version string

◆ xdmAtomicClass

jclass SaxonProcessor::xdmAtomicClass
protected

The XdmAtomicValue instance


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