8 #ifndef SAXON_PROCESSOR_H 9 #define SAXON_PROCESSOR_H 11 #if defined __linux__ || defined __APPLE__ 17 #define LoadLibrary(x) dlopen(x, RTLD_LAZY) 18 #define GetProcAddress(x,y) dlsym(x,y) 24 #define CVERSION "1.2.1" 25 #define CVERSION_API_NO 121 33 #include "SaxonCGlue.h" 34 #include "SaxonCXPath.h" 35 #include "XsltProcessor.h" 36 #include "Xslt30Processor.h" 37 #include "XQueryProcessor.h" 38 #include "XPathProcessor.h" 39 #include "SchemaValidator.h" 62 std::string errorCode;
63 std::string errorMessage;
72 jobjectArray stringArray;
73 jobjectArray objectArray;
89 exceptions = std::vector<MyException>(0);
97 exceptions = ex.exceptions;
106 exceptions = std::vector<MyException>(0);
109 newEx.errorCode = std::string(ec);
111 newEx.errorCode =
"Unknown";
114 newEx.errorMessage = std::string(exM);
116 newEx.errorMessage=
"Unkown";
118 newEx.isType =
false;
119 newEx.isStatic =
false;
120 newEx.isGlobal =
false;
121 newEx.linenumber = 0;
122 exceptions.push_back(newEx);
134 SaxonApiException(
const char * ec,
const char * exM,
bool typeErr,
bool stat,
bool glob,
int l){
135 exceptions = std::vector<MyException>(20);
138 newEx.errorCode = std::string(ec);
140 newEx.errorCode =
"ERROR1";
143 newEx.errorMessage = std::string(exM);
145 newEx.errorMessage=
"ERROR2";
147 newEx.isType = typeErr;
148 newEx.isStatic = stat;
149 newEx.isGlobal = glob;
150 newEx.linenumber = l;
151 exceptions.push_back(newEx);
163 void add(
const char * ec,
const char * exM,
bool typeErr,
bool stat,
bool glob,
int l){
166 newEx.errorCode = std::string(ec);
168 newEx.errorCode =
"ERROR1";
171 newEx.errorMessage = std::string(exM);
173 newEx.errorMessage=
"ERROR2";
175 newEx.isType = typeErr;
176 newEx.isStatic = stat;
177 newEx.isGlobal = glob;
178 newEx.linenumber = l;
179 exceptions.push_back(newEx);
196 if((
size_t)i <= exceptions.size()){
197 return exceptions[i].errorCode.c_str();
203 int getLineNumber(
int i){
204 if((
size_t)i <= exceptions.size()){
205 return exceptions[i].linenumber;
210 bool isGlobalError(
int i){
211 if((
size_t)i <= exceptions.size()){
212 return exceptions[i].isGlobal;
217 bool isStaticError(
int i){
218 if((
size_t)i <= exceptions.size()){
219 return exceptions[i].isStatic;
224 bool isTypeError(
int i){
225 if((
size_t) i <= exceptions.size()){
226 return exceptions[i].isType;
232 for(
size_t i =0; i< exceptions.size();i++) {
233 exceptions[i].errorCode.clear();
234 exceptions[i].errorMessage.clear();
240 return (
int)exceptions.size();
250 if((
size_t)i <= exceptions.size()){
251 return exceptions[i].errorMessage.c_str();
256 const char * getErrorMessages(){
258 for(
size_t i = 0;i<exceptions.size();i++) {
261 if(result.empty()) {
return NULL;}
262 return result.c_str();
271 if((
size_t)i <= exceptions.size()){
272 return exceptions[i];
280 std::vector<MyException> exceptions;
478 int getNodeKind(jobject);
480 bool isSchemaAwareProcessor();
510 static void release();
532 void setCatalog(
const char* catalogFile,
bool isTracing);
566 void addNativeMethod(
char *name,
char* signature,
void * fnPtr){
568 JNINativeMethod method;
570 method.signature = signature;
571 method.fnPtr = fnPtr;
585 bool registerCPPFunction(
char * libName, JNINativeMethod * gMethods=NULL){
586 if(libName != NULL) {
594 if(gMethods == NULL) {
598 return registerNativeMethods(sxn_environ->env,
"com/saxonica/functions/extfn/CppCall$PhpFunctionCall",
599 gMethods,
sizeof(gMethods) /
sizeof(gMethods[0]));
610 static bool registerNativeMethods(JNIEnv* env,
const char* className,
611 JNINativeMethod* gMethods,
int numMethods)
614 clazz = env->FindClass(className);
616 std::cerr<<
"Native registration unable to find class "<< className<<std::endl;
620 if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
629 const char* checkException(jobject cpp);
632 void checkAndCreateException(jclass cppClass);
641 static int jvmCreatedCPP;
653 jclass xdmAtomicClass;
656 jclass saxonCAPIClass;
666 JNINativeMethod * nativeMethods;
675 void applyConfigurationProperties();
677 static JParameters createParameterJArray(std::map<std::string,XdmValue*>
parameters, std::map<std::string,std::string> properties);
678 static jobjectArray createJArray(
XdmValue ** values,
int length);
XdmAtomicValue * makeFloatValue(float)
Definition: SaxonProcessor.cpp:740
void exceptionClear(bool clearCPPException=true)
Definition: SaxonProcessor.cpp:65
XdmAtomicValue * makeBooleanValue(bool b)
Definition: SaxonProcessor.cpp:758
MyException getException(int i)
Definition: SaxonProcessor.h:270
std::vector< JNINativeMethod > nativeMethodVect
Definition: SaxonProcessor.h:667
Definition: XQueryProcessor.h:26
void setcwd(const char *cwd)
Definition: SaxonProcessor.cpp:502
std::map< std::string, XdmValue * > parameters
Definition: SaxonProcessor.h:660
XdmAtomicValue * makeDoubleValue(double d)
Definition: SaxonProcessor.cpp:731
SaxonApiException * checkForExceptionCPP(JNIEnv *env, jclass callingClass, jobject callingObject)
Definition: SaxonProcessor.cpp:83
std::string cwd
Definition: SaxonProcessor.h:644
SaxonApiException(const char *ec, const char *exM, bool typeErr, bool stat, bool glob, int l)
Definition: SaxonProcessor.h:134
Definition: XdmAtomicValue.h:20
Definition: SaxonCGlue.h:80
Definition: Xslt30Processor.h:24
std::map< std::string, std::string > configProperties
Definition: SaxonProcessor.h:661
const char * getStringValue(XdmItem *item)
Definition: SaxonProcessor.cpp:781
void clearConfigurationProperties()
Definition: SaxonProcessor.cpp:675
SaxonApiException()
Definition: SaxonProcessor.h:88
void setCatalog(const char *catalogFile, bool isTracing)
Definition: SaxonProcessor.cpp:522
~SaxonProcessor()
Definition: SaxonProcessor.cpp:268
SaxonApiException(const SaxonApiException &ex)
Definition: SaxonProcessor.h:96
const char * getcwd()
Definition: SaxonProcessor.cpp:506
jobject proc
Definition: SaxonProcessor.h:645
XdmAtomicValue * makeLongValue(long l)
Definition: SaxonProcessor.cpp:749
Definition: SaxonProcessor.h:81
Definition: SchemaValidator.h:26
XPathProcessor * newXPathProcessor()
Definition: SaxonProcessor.cpp:466
const char * getErrorMessage(int i)
Definition: SaxonProcessor.h:249
Definition: XdmValue.h:46
const char * getResourcesDirectory()
Definition: SaxonProcessor.cpp:559
XdmNode * parseXmlFromUri(const char *source)
Definition: SaxonProcessor.cpp:644
SaxonApiException(const char *ec, const char *exM)
Definition: SaxonProcessor.h:105
Definition: XsltProcessor.h:24
XdmNode * parseXmlFromFile(const char *source)
Definition: SaxonProcessor.cpp:622
XdmAtomicValue * makeAtomicValue(const char *type, const char *value)
Definition: SaxonProcessor.cpp:774
SchemaValidator * newSchemaValidator()
Definition: SaxonProcessor.cpp:471
Definition: SaxonProcessor.h:296
Xslt30Processor * newXslt30Processor()
Definition: SaxonProcessor.cpp:456
XdmAtomicValue * makeIntegerValue(int i)
Definition: SaxonProcessor.cpp:720
const char * version()
Definition: SaxonProcessor.cpp:483
void setConfigurationProperty(const char *name, const char *value)
Definition: SaxonProcessor.cpp:669
XdmAtomicValue * makeStringValue(std::string str)
Definition: SaxonProcessor.cpp:711
Definition: SaxonProcessor.h:61
XdmNode * parseXmlFromString(const char *source)
Definition: SaxonProcessor.cpp:564
const char * getErrorCode(int i)
Definition: SaxonProcessor.h:195
Definition: SaxonProcessor.h:70
void setResourcesDirectory(const char *dir)
Definition: SaxonProcessor.cpp:510
SaxonApiException * exception
Definition: SaxonProcessor.h:664
Definition: XPathProcessor.h:26
bool licensei
Definition: SaxonProcessor.h:662
bool exceptionOccurred()
Definition: SaxonProcessor.cpp:29
XdmAtomicValue * makeQNameValue(const char *str)
Definition: SaxonProcessor.cpp:767
XsltProcessor * newXsltProcessor()
Get the Processor object. Method used in Python.
Definition: SaxonProcessor.cpp:451
~SaxonApiException()
Definition: SaxonProcessor.h:186
SaxonProcessor()
A default constructor.
Definition: SaxonProcessor.cpp:76
XQueryProcessor * newXQueryProcessor()
Definition: SaxonProcessor.cpp:461
std::string cwdV
Definition: SaxonProcessor.h:657
void add(const char *ec, const char *exM, bool typeErr, bool stat, bool glob, int l)
Definition: SaxonProcessor.h:163