SaxonC 12.4
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Friends | List of all members
SaxonProcessor Class Reference

#include <SaxonProcessor.h>

Public Member Functions

 SaxonProcessor ()
 A default constructor.
 
 SaxonProcessor (const char *configFile)
 constructor based upon a Saxon configuration file.
 
 SaxonProcessor (bool l)
 A constructor.
 
SaxonProcessoroperator= (const SaxonProcessor &other)
 The copy assignment= operator.
 
 SaxonProcessor (const SaxonProcessor &other)
 SaxonProcessor copy constructor.
 
 ~SaxonProcessor ()
 
const char * getErrorMessage ()
 Get any error message thrown by the processor.
 
DocumentBuildernewDocumentBuilder ()
 Create a DocumentBuilder.
 
Xslt30ProcessornewXslt30Processor ()
 Create an Xslt30Processor.
 
XQueryProcessornewXQueryProcessor ()
 Create an XQueryProcessor.
 
XPathProcessornewXPathProcessor ()
 
SchemaValidatornewSchemaValidator ()
 
XdmAtomicValuemakeStringValue (std::string str, const char *encoding=nullptr)
 
XdmAtomicValuemakeStringValue (const char *str, const char *encoding=nullptr)
 
XdmAtomicValuemakeIntegerValue (int i)
 
XdmAtomicValuemakeDoubleValue (double d)
 Factory method. make an XdmAtomicValue from a primitive double value.
 
XdmAtomicValuemakeFloatValue (float f)
 Factory method. make an XdmAtomicValue from a primitive float value.
 
XdmAtomicValuemakeLongValue (long l)
 
XdmAtomicValuemakeBooleanValue (bool b)
 Factory method: makes a XdmAtomicValue representing a boolean Value.
 
XdmAtomicValuemakeQNameValue (const char *str)
 Create an QName Xdm value from string representation in clark notation.
 
XdmAtomicValuemakeAtomicValue (const char *type, const char *value)
 Create an Xdm Atomic value from string representation.
 
XdmArraymakeArray (const char **input, int length)
 Make an XdmArray whose members are from string representation.
 
XdmArraymakeArray (short *input, int length)
 Make an XdmArray whose members are xs:short values.
 
XdmArraymakeArray (int *input, int length)
 Make an XdmArray whose members are xs:int values.
 
XdmArraymakeArray (long long *input, int length)
 Make an XdmArray whose members are xs:long values.
 
XdmArraymakeArray (bool *input, int length)
 
XdmArraymakeArray (XdmValue **values, int length)
 Make an XdmArray whose members are of type XdmValue.
 
XdmMapmakeMap (std::map< XdmAtomicValue *, XdmValue * > dataMap)
 Make an XdmMap whose argument is a map from the standard template library.
 
XdmMapmakeMap3 (XdmAtomicValue **keys, XdmValue **values, int len)
 Make an XdmMap from an array of keys and values.
 
const char * clarkNameToEQName (const char *name)
 Convert clark name string to EQName notation.
 
const char * EQNameToClarkName (const char *name)
 Convert EQName string to clark name notation.
 
const char * getStringValue (XdmItem *item)
 Get the string representation of the XdmValue.
 
XdmNodeparseXmlFromString (const char *source, const char *encoding=nullptr, SchemaValidator *validator=nullptr)
 
XdmNodeparseXmlFromFile (const char *source, SchemaValidator *validator=nullptr)
 Parse a source document file and return it as an XdmNode.
 
XdmNodeparseXmlFromUri (const char *source, SchemaValidator *validator=nullptr)
 Parse a source document available by URI and return it as an XdmNode.
 
XdmValueparseJsonFromString (const char *source, const char *encoding=NULL)
 
XdmValueparseJsonFromFile (const char *source)
 Parse a source JSON file and return it as an XdmValue.
 
int getNodeKind (int64_t obj)
 Get the kind of node.
 
bool isSchemaAwareProcessor ()
 Test whether this processor is schema-aware.
 
bool exceptionOccurred ()
 Checks for thrown exceptions.
 
void exceptionClear ()
 
XdmValue ** createXdmValueArray (int len)
 Utility method for working with SaxonC on Python.
 
void deleteXdmValueArray (XdmValue **arr, int len)
 Utility method for Python API - internal use only.
 
XdmAtomicValue ** createXdmAtomicValueArray (int len)
 Utility method for working with SaxonC on Python.
 
void deleteXdmAtomicValueArray (XdmAtomicValue **arr, int len)
 Utility method for Python API - internal use only.
 
void setcwd (const char *cwd)
 Set the current working directory.
 
const char * getcwd ()
 Get the current working directory.
 
const char * getResourcesDirectory ()
 Get saxon resources directory.
 
void setResourcesDirectory (const char *dir)
 set saxon resources directory
 
void setCatalog (const char *catalogFile)
 
void setCatalogFiles (const char **catalogFiles, int length)
 
void setConfigurationProperty (const char *name, const char *value)
 Set a configuration property specific to the processor in use.
 
void clearConfigurationProperties ()
 Clear configuration properties specific to the processor in use.
 
const char * version ()
 Get the Saxon version.
 
void createHeapDump (bool live)
 Internal method for diagnostics.
 

Static Public Member Functions

static XdmMapmakeMap2 (std::map< std::string, XdmValue * > dataMap)
 Make an XdmMap whose argument is a map from the standard template library.
 
static SaxonApiExceptioncheckForExceptionCPP ()
 
static void release ()
 
static void attachCurrentThread ()
 Attaches a current thread to the a Java VM.
 
static void detachCurrentThread ()
 Detach JVM from the current thread.
 
static void deleteString (const char *data)
 
static void getInfo ()
 

Public Attributes

std::string cwd
 

Static Public Attributes

static int jvmCreatedCPP = 0
 Add a native method.
 
static sxnc_environmentsxn_environ = 0
 

Protected Attributes

std::string cwdV
 
std::string versionStr
 
std::map< std::string, XdmValue * > parameters
 
std::map< std::string, std::string > configProperties
 
bool licensei
 
int64_t procRef
 
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.

Exceptions
SaxonApiException

◆ SaxonProcessor() [2/4]

SaxonProcessor::SaxonProcessor ( const char *  configFile)

constructor based upon a Saxon configuration file.

Create Saxon Processor.

Exceptions
SaxonApiException

◆ 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.
Exceptions
SaxonApiException

◆ SaxonProcessor() [4/4]

SaxonProcessor::SaxonProcessor ( const SaxonProcessor other)

SaxonProcessor copy constructor.

Parameters
other- SaxonProcessor

◆ ~SaxonProcessor()

SaxonProcessor::~SaxonProcessor ( )

Destructor method. At the end of the program call the release() method to clear the JVM.

Member Function Documentation

◆ checkForExceptionCPP()

SaxonApiException * SaxonProcessor::checkForExceptionCPP ( )
static

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

◆ clarkNameToEQName()

const char * SaxonProcessor::clarkNameToEQName ( const char *  name)

Convert clark name string to EQName notation.

The expanded name, as a string using the notation defined by the EQName production in XPath 3.0. If the name is in a namespace, the resulting string takes the form Q{uri}local. Otherwise, the value is the local part of the name.

Parameters
name- The URI in Clark notation: {uri}local if the name is in a namespace, or simply local if not.
Returns
the expanded name, as a string using the notation defined by the EQName production in XPath 3.0.

◆ deleteString()

static void SaxonProcessor::deleteString ( const char *  data)
inlinestatic

Utility method required for python and PHP extension to delete string created in the C++ code-base

◆ deleteXdmAtomicValueArray()

void SaxonProcessor::deleteXdmAtomicValueArray ( XdmAtomicValue **  arr,
int  len 
)

Utility method for Python API - internal use only.

This method deletes a XdmAtomicValue pointer array

Parameters
arr- XdmAtomicValue pointer array
len- length of the array

◆ deleteXdmValueArray()

void SaxonProcessor::deleteXdmValueArray ( XdmValue **  arr,
int  len 
)

Utility method for Python API - internal use only.

This method deletes a XdmValue pointer array

Parameters
arr- XdmValue pointer array
len- length of the array

◆ EQNameToClarkName()

const char * SaxonProcessor::EQNameToClarkName ( const char *  name)

Convert EQName string to clark name notation.

Parameters
name- The URI in EQName notation: Q{uri}local if the name is in a namespace. For a name in no namespace, either of the forms Q{}local or simply local are accepted.
Returns
the URI in the clark notation

◆ exceptionClear()

void SaxonProcessor::exceptionClear ( )

Clears any exception that is currently being thrown. If no exception is currently being thrown, this routine has no effect.

◆ 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 retrieved by this method.

◆ getInfo()

static void SaxonProcessor::getInfo ( )
static

Get info on objects allocated and still in memory

◆ getNodeKind()

int SaxonProcessor::getNodeKind ( int64_t  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 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,
const char *  encoding = nullptr 
)

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
str- the char pointer array. nullptr is taken as equivalent to "".
encoding- the encoding of the string. If not specified then the platform default encoding is used.
Returns
the corresponding StringValue

◆ makeStringValue() [2/2]

XdmAtomicValue * SaxonProcessor::makeStringValue ( std::string  str,
const char *  encoding = nullptr 
)

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 "".
encoding- the encoding of the string. If not specified then the platform default encoding is used.
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

◆ parseJsonFromFile()

XdmValue * SaxonProcessor::parseJsonFromFile ( const char *  source)

Parse a source JSON file and return it as an XdmValue.

Parameters
sourcethe filename of the JSON. This is a full path filename or a URI
Returns
an XdmValue
Exceptions
SaxonApiExceptionif there ia a failure in the parsing of the XML file

◆ parseJsonFromString()

XdmValue * SaxonProcessor::parseJsonFromString ( const char *  source,
const char *  encoding = NULL 
)

Parse a lexical representation of the JSON and return it as an XdmValue

Parameters
sourcethe JSON as a lexical string
encodingthe encoding of the source argument. Argument can be omitted and NULL accepted to use the default platform encoding
Returns
an XdmValue
Exceptions
SaxonApiExceptionif there is a failure in the parsing of the JSON

◆ 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
validatorcan be used to supply a SchemaValidator to validate the document. Default is null
Returns
an XdmNode
Exceptions
SaxonApiExceptionif there ia a failure in the parsing of the XML file

◆ parseXmlFromString()

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

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

Parameters
sourcethe source document as a lexical string
encodingthe encoding used to decode the source string. If not specified then platform default encoding is used
validatorcan be used to supply a SchemaValidator to validate the document. Default is null
Returns
an XdmNode
Exceptions
SaxonApiExceptionif there is a failure in the parsing of the XML document

◆ parseXmlFromUri()

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

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

Parameters
sourcethe URI of the source document
validatorcan be used to supply a SchemaValidator to validate the document. Default is null
Returns
an XdmNode
Exceptions
SaxonApiExceptionif there ia failure in the parsing of the XML file

◆ release()

void SaxonProcessor::release ( )
static

Clean up and destroy Java VM to release memory used. Method to be called at the end of the program

◆ setCatalog()

void SaxonProcessor::setCatalog ( const char *  catalogFile)

set catalog to be used in Saxon

Parameters
catalogFilefile name to the catalog
Exceptions
SaxonApiExceptionif fail to set the catalog file
Deprecated:

◆ setCatalogFiles()

void SaxonProcessor::setCatalogFiles ( const char **  catalogFiles,
int  length 
)

set catalog files to be used in Saxon

Parameters
catalogFiles- the catalog file names array to the catalog
length- number of catalog files in the array argument
Exceptions
SaxonApiExceptionif fail to set the catalog file

◆ 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

Add a native method.

Parameters
nameof the native method
signatureof the native method
fnPtrPointer to the native method Register several native methods for one class.
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 Register several native methods for one class.
Parameters
env
className
gMethods
numMethods
Returns
bool success of registered native method 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 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

◆ parameters

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

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

◆ sxn_environ

sxnc_environment * SaxonProcessor::sxn_environ = 0
static

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

◆ versionStr

std::string SaxonProcessor::versionStr
protected

The Saxon version string


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