8 #ifndef SAXON_PROCESSOR_H
9 #define SAXON_PROCESSOR_H
12 #if defined __linux__ || defined __APPLE__
19 #define LoadLibrary(x) dlopen(x, RTLD_LAZY)
20 #define GetProcAddress(x, y) dlsym(x,y)
27 #define CVERSION "11.5"
28 #define CVERSION_API_NO 1150
40 #include "SaxonCGlue.h"
41 #include "SaxonCXPath.h"
42 #include "Xslt30Processor.h"
43 #include "XsltExecutable.h"
44 #include "DocumentBuilder.h"
45 #include "XQueryProcessor.h"
46 #include "XPathProcessor.h"
47 #include "SchemaValidator.h"
48 #include "SaxonApiException.h"
59 static std::vector<void*> myAlloc;
61 void* newImpl(std::size_t sz,
char const* file,
int line);
63 void*
operator new(std::size_t sz,
char const* file,
int line);
65 void*
operator new [](std::size_t sz,
char const* file,
int line);
67 void operator delete(
void* ptr) noexcept;
69 void operator delete(
void*, std::size_t) noexcept;
391 XdmMap *
makeMap(std::map<XdmAtomicValue *, XdmValue *> dataMap);
399 static XdmMap *
makeMap2(std::map<std::string, XdmValue *> dataMap);
527 void setCatalog(
const char *catalogFile,
bool isTracing);
561 JNINativeMethod method;
563 method.signature = signature;
564 method.fnPtr = fnPtr;
580 if (libName !=
nullptr) {
588 if (gMethods ==
nullptr) {
609 JNINativeMethod *gMethods,
int numMethods) {
611 clazz = env->FindClass(className);
612 if (clazz ==
nullptr) {
613 std::cerr <<
"Native registration unable to find class " << className << std::endl;
617 if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
670 void createException(
const char * message=
nullptr);
674 void applyConfigurationProperties();
678 createParameterJArray(std::map<std::string, XdmValue *>
parameters, std::map<std::string, std::string> properties,
int additions = 0);
684 static const char *checkException();
Definition: DocumentBuilder.h:33
Definition: SaxonApiException.h:19
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition: SaxonProcessor.h:119
void setcwd(const char *cwd)
Set the current working directory.
Definition: SaxonProcessor.cpp:755
const char * getResourcesDirectory()
Get saxon resources directory.
Definition: SaxonProcessor.cpp:766
XdmNode * parseXmlFromFile(const char *source, SchemaValidator *validator=nullptr)
Parse a source document file and return it as an XdmNode.
Definition: SaxonProcessor.cpp:885
XdmMap * makeMap3(XdmAtomicValue **keys, XdmValue **values, int len)
Make an XdmMap from an array of keys and values.
Definition: SaxonProcessor.cpp:1506
static void detachCurrentThread()
Detach JVM from the current thread.
Definition: SaxonProcessor.cpp:323
SaxonApiException * checkAndCreateException(jclass cppClass)
Check for exception thrown in the underlying JNI. Then create the SaxonApiException class which the u...
Definition: SaxonProcessor.cpp:94
XdmAtomicValue ** createXdmAtomicValueArray(int len)
Utility method for working with SaxonC on Python.
Definition: SaxonProcessor.h:479
std::string cwdV
Definition: SaxonProcessor.h:655
jclass versionClass
Definition: SaxonProcessor.h:652
static void release()
Clean up and destroy Java VM to release memory used. Method to be called at the end of the program.
Definition: SaxonProcessor.cpp:950
XdmAtomicValue * makeAtomicValue(const char *type, const char *value)
Create an Xdm Atomic value from string representation.
Definition: SaxonProcessor.cpp:1098
XdmNode * parseXmlFromUri(const char *source, SchemaValidator *validator=nullptr)
Parse a source document available by URI and return it as an XdmNode.
Definition: SaxonProcessor.cpp:910
static XdmAtomicValue * makeStringValue2(std::string str)
Factory method. Unlike the constructor, this avoids creating a new StringValue in the case.
Definition: SaxonProcessor.cpp:983
const char * getErrorMessage()
Get any error message thrown by the processor.
Definition: SaxonProcessor.cpp:106
void setResourcesDirectory(const char *dir)
set saxon resources directory
Definition: SaxonProcessor.cpp:771
void addNativeMethod(char *name, char *signature, void *fnPtr)
Add a native method.
Definition: SaxonProcessor.h:559
static sxnc_environment * sxn_environ
Definition: SaxonProcessor.h:636
static XdmMap * makeMap2(std::map< std::string, XdmValue * > dataMap)
Make an XdmMap whose argument is a map from the standard template library.
Definition: SaxonProcessor.cpp:1443
void clearConfigurationProperties()
Clear configuration properties specific to the processor in use.
Definition: SaxonProcessor.cpp:945
jclass xdmAtomicClass
Definition: SaxonProcessor.h:651
void exceptionClear()
Clears any exception that is currently being thrown. If no exception is currently being thrown,...
Definition: SaxonProcessor.cpp:116
XdmAtomicValue * makeBooleanValue(bool b)
Factory method: makes a XdmAtomicValue representing a boolean Value.
Definition: SaxonProcessor.cpp:1077
int getNodeKind(jobject obj)
Get the kind of node.
Definition: SaxonProcessor.cpp:849
SaxonProcessor()
A default constructor.
Definition: SaxonProcessor.cpp:247
const char * getStringValue(XdmItem *item)
Get the string representation of the XdmValue.
Definition: SaxonProcessor.cpp:1106
std::map< std::string, XdmValue * > parameters
Definition: SaxonProcessor.h:658
XdmAtomicValue * makeQNameValue(const char *str)
Create an QName Xdm value from string representation in clark notation.
Definition: SaxonProcessor.cpp:1090
SchemaValidator * newSchemaValidator()
Create a SchemaValidator which can be used to validate instance documents against the schema held by ...
Definition: SaxonProcessor.cpp:713
const char * getcwd()
Get the current working directory.
Definition: SaxonProcessor.cpp:761
XdmAtomicValue * makeDoubleValue(double d)
Factory method. make an XdmAtomicValue from a primitive double value.
Definition: SaxonProcessor.cpp:1038
XdmValue ** createXdmValueArray(int len)
Utility method for working with SaxonC on Python.
Definition: SaxonProcessor.h:474
XdmAtomicValue * makeIntegerValue(int i)
Definition: SaxonProcessor.cpp:1021
bool exceptionOccurred()
Checks for thrown exceptions.
Definition: SaxonProcessor.cpp:81
jclass procClass
Definition: SaxonProcessor.h:653
void setConfigurationProperty(const char *name, const char *value)
Set a configuration property specific to the processor in use.
Definition: SaxonProcessor.cpp:938
static bool registerNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *gMethods, int numMethods)
Register several native methods for one class.
Definition: SaxonProcessor.h:608
bool registerCPPFunction(char *libName, JNINativeMethod *gMethods=nullptr)
Register several native methods for one class.
Definition: SaxonProcessor.h:579
void setCatalog(const char *catalogFile, bool isTracing)
Definition: SaxonProcessor.cpp:783
JNINativeMethod * nativeMethods
Definition: SaxonProcessor.h:663
XQueryProcessor * newXQueryProcessor()
Create an XQueryProcessor.
Definition: SaxonProcessor.cpp:703
XdmNode * parseXmlFromString(const char *source, SchemaValidator *validator=nullptr)
Parse a lexical representation of the source document and return it as an XdmNode.
Definition: SaxonProcessor.cpp:813
const char * version()
Get the Saxon version.
Definition: SaxonProcessor.cpp:724
Xslt30Processor * newXslt30Processor()
Create an Xslt30Processor.
Definition: SaxonProcessor.cpp:698
std::string cwd
Definition: SaxonProcessor.h:637
static void attachCurrentThread()
Attaches a current thread to the a Java VM.
Definition: SaxonProcessor.cpp:307
std::string versionStr
Definition: SaxonProcessor.h:657
XdmAtomicValue * makeLongValue(long l)
Factory method: makes either an Int64Value or a BigIntegerValue depending on the value supplied.
Definition: SaxonProcessor.cpp:1064
bool licensei
Definition: SaxonProcessor.h:660
~SaxonProcessor()
Destructor method. At the end of the program call the release() method to clear the JVM.
Definition: SaxonProcessor.cpp:383
std::map< std::string, std::string > configProperties
Definition: SaxonProcessor.h:659
jclass saxonCAPIClass
Definition: SaxonProcessor.h:654
bool isSchemaAwareProcessor()
Test whether this processor is schema-aware.
Definition: SaxonProcessor.cpp:397
jobject proc
Definition: SaxonProcessor.h:638
SaxonProcessor & operator=(const SaxonProcessor &other)
The copy assignment= operator.
Definition: SaxonProcessor.cpp:632
static SaxonApiException * checkForExceptionCPP(JNIEnv *env, jclass callingClass, jobject callingObject)
Checks for pending exceptions and creates a SaxonApiException object, which handles one or more local...
Definition: SaxonProcessor.cpp:148
SaxonApiException * exception
Definition: SaxonProcessor.h:665
DocumentBuilder * newDocumentBuilder()
Create a DocumentBuilder.
Definition: SaxonProcessor.cpp:664
std::vector< JNINativeMethod > nativeMethodVect
Definition: SaxonProcessor.h:664
XdmMap * makeMap(std::map< XdmAtomicValue *, XdmValue * > dataMap)
Make an XdmMap whose argument is a map from the standard template library.
Definition: SaxonProcessor.cpp:1389
XdmArray * makeArray(const char **input, int length)
Make an XdmArray whose members are from string representation.
Definition: SaxonProcessor.cpp:1347
static int jvmCreatedCPP
Definition: SaxonProcessor.h:635
XPathProcessor * newXPathProcessor()
Create an XPathProcessor. An XPathProcessor is used to compile XPath expressions.
Definition: SaxonProcessor.cpp:708
XdmAtomicValue * makeStringValue(std::string str)
Factory method. Unlike the constructor, this avoids creating a new StringValue in the case.
Definition: SaxonProcessor.cpp:1003
XdmAtomicValue * makeFloatValue(float f)
Factory method. make an XdmAtomicValue from a primitive float value.
Definition: SaxonProcessor.cpp:1051
Definition: SchemaValidator.h:24
Definition: XPathProcessor.h:27
Definition: XQueryProcessor.h:26
Definition: XdmArray.h:25
XdmValue ** values()
Definition: XdmArray.cpp:225
Definition: XdmAtomicValue.h:26
Definition: XdmFunctionItem.h:23
jobject value
Definition: XdmItem.h:163
Definition: XdmValue.h:50
void initialize()
initialize this XdmValue with default values
Definition: XdmValue.h:193
Definition: Xslt30Processor.h:26
Definition: XsltExecutable.h:30
A struct object to represent parameters.
Definition: SaxonProcessor.h:105
jobjectArray stringArray
Definition: SaxonProcessor.h:106
jobjectArray objectArray
Definition: SaxonProcessor.h:107
Definition: SaxonCGlue.h:80