Project

Profile

Help

How to connect?
Download (20.3 KB) Statistics
| Branch: | Tag: | Revision:

he / latest9.6 / hec / Saxon.C.API / SaxonProcessor.cpp @ 4e3fba42

1
#ifndef __linux__ 
2
#ifndef __APPLE__
3
        #include "stdafx.h"
4
        #include <Tchar.h>
5
#endif
6
#endif
7

    
8

    
9
//#include "stdafx.h"
10
#include "SaxonProcessor.h"
11
#include "XdmValue.h"
12
#include "XdmItem.h"
13
#include "XdmNode.h"
14
#include "XdmAtomicValue.h"
15

    
16
#ifndef CPP_ONLY
17
/*#include "XsltProcessor.cpp"
18
#include "XQueryProcessor.cpp"
19
#include "XdmValue.cpp"*/
20
//#include "php_saxon.cpp"
21
#endif
22
//#define DEBUG
23
#ifdef DEBUG
24
#include <signal.h>
25
#endif
26
#include <stdio.h>
27

    
28

    
29
//jobject cpp;
30
const char * failure;
31
sxnc_environment * SaxonProcessor::sxn_environ = 0;
32
int SaxonProcessor::refCount = 0;
33
int SaxonProcessor::jvmCreatedCPP=0;
34

    
35
bool SaxonProcessor::exceptionOccurred(){
36
        return SaxonProcessor::sxn_environ->env->ExceptionCheck();
37
}
38

    
39
void SaxonProcessor::exceptionClear(){
40
        SaxonProcessor::sxn_environ->env->ExceptionClear();
41
}
42

    
43
SaxonApiException * SaxonProcessor::getException(){
44
        return exception;
45
}
46

    
47
SaxonProcessor::SaxonProcessor() {
48
    licensei = false;
49
    SaxonProcessor(licensei);
50
}
51

    
52

    
53

    
54
SaxonApiException * SaxonProcessor::checkForExceptionCPP(JNIEnv* env, jclass callingClass,  jobject callingObject){
55

    
56
    if (env->ExceptionCheck()) {
57
        string result1 = "";
58
        string errorCode = "";
59
        jthrowable exc = env->ExceptionOccurred();
60
       //env->ExceptionDescribe();
61
#ifdef DEBUG        
62
        env->ExceptionDescribe();
63
#endif
64
         jclass exccls(env->GetObjectClass(exc));
65
        jclass clscls(env->FindClass("java/lang/Class"));
66

    
67
        jmethodID getName(env->GetMethodID(clscls, "getName", "()Ljava/lang/String;"));
68
        jstring name(static_cast<jstring>(env->CallObjectMethod(exccls, getName)));
69
        char const* utfName(env->GetStringUTFChars(name, 0));
70
        result1 = (string(utfName));
71
        //env->ReleaseStringUTFChars(name, utfName);
72

    
73
         jmethodID  getMessage(env->GetMethodID(exccls, "getMessage", "()Ljava/lang/String;"));
74
        if(getMessage) {
75

    
76
                jstring message(static_cast<jstring>(env->CallObjectMethod(exc, getMessage)));
77
                char const* utfMessage = NULL;                
78
                if(!message) {
79
                        utfMessage = "";
80
                        return NULL;
81
                } else {
82
                        utfMessage = (env->GetStringUTFChars(message, 0));
83
                }
84
                if(utfMessage != NULL) {
85
                        result1 = (result1 + " : ") + utfMessage;
86
                } 
87
                
88
                //env->ReleaseStringUTFChars(message,utfMessage);
89
                if(callingObject != NULL && result1.compare(0,36, "net.sf.saxon.option.cpp.SaxonCException", 36) == 0){
90
                        jmethodID  getErrorCodeID(env->GetMethodID(callingClass, "getExceptions", "()[Lnet/sf/saxon/option/cpp/SaxonCException;"));
91
                        jclass saxonExceptionClass(env->FindClass("net/sf/saxon/option/cpp/SaxonCException"));
92
                                if(getErrorCodeID){        
93
                                        jobjectArray saxonExceptionObject((jobjectArray)(env->CallObjectMethod(callingObject, getErrorCodeID)));
94
                                        if(saxonExceptionObject) {
95
                                                jmethodID lineNumID = env->GetMethodID(saxonExceptionClass, "getLinenumber", "()I");
96
                                                jmethodID ecID = env->GetMethodID(saxonExceptionClass, "getErrorCode", "()Ljava/lang/String;");
97
                                                jmethodID emID = env->GetMethodID(saxonExceptionClass, "getErrorMessage", "()Ljava/lang/String;");
98
                                                jmethodID typeID = env->GetMethodID(saxonExceptionClass, "isTypeError", "()Z");
99
                                                jmethodID staticID = env->GetMethodID(saxonExceptionClass, "isStaticError", "()Z");
100
                                                jmethodID globalID = env->GetMethodID(saxonExceptionClass, "isGlobalError", "()Z");
101

    
102

    
103
                                                int exLength = (int)env->GetArrayLength(saxonExceptionObject);
104
                                                SaxonApiException * saxonExceptions = new SaxonApiException();
105
                                                for(int i=0; i<exLength;i++){
106
                                                        jobject exObj = env->GetObjectArrayElement(saxonExceptionObject, i);
107

    
108
                                                        jstring errCode = (jstring)(env->CallObjectMethod(exObj, ecID));
109
                                                        jstring errMessage = (jstring)(env->CallObjectMethod(exObj, emID));
110
                                                        jboolean isType = (env->CallBooleanMethod(exObj, typeID));
111
                                                        jboolean isStatic = (env->CallBooleanMethod(exObj, staticID));
112
                                                        jboolean isGlobal = (env->CallBooleanMethod(exObj, globalID));
113
                                                        saxonExceptions->add((errCode ? env->GetStringUTFChars(errCode,0) : NULL )  ,(errMessage ? env->GetStringUTFChars(errMessage,0) : NULL),(int)(env->CallIntMethod(exObj, lineNumID)), (bool)isType, (bool)isStatic, (bool)isGlobal);
114
                                                        //env->ExceptionDescribe();
115
                                                }
116
                                                //env->ExceptionDescribe();
117
                                                env->ExceptionClear();
118
                                                return saxonExceptions;
119
                                        }
120
                                }
121
                }
122
        }
123
        SaxonApiException * saxonExceptions = new SaxonApiException(NULL, result1.c_str());
124
        //env->ExceptionDescribe();
125
        env->ExceptionClear();
126
        return saxonExceptions;
127
     }
128
        return NULL;
129

    
130
}
131

    
132

    
133

    
134
SaxonProcessor::SaxonProcessor(bool l){
135

    
136
    cwd="";
137
    licensei = l;
138
    versionStr = NULL;
139
    refCount++;
140

    
141

    
142
     if(jvmCreatedCPP == 0){
143
        jvmCreatedCPP=1;
144
    SaxonProcessor::sxn_environ= new sxnc_environment;//(sxnc_environment *)malloc(sizeof(sxnc_environment));
145

    
146

    
147
    /*
148
     * First of all, load required component.
149
     * By the time of JET initialization, all components should be loaded.
150
     */
151

    
152
    SaxonProcessor::sxn_environ->myDllHandle = loadDefaultDll ();
153

    
154
    /*
155
     * Initialize JET run-time.
156
     * The handle of loaded component is used to retrieve Invocation API.
157
     */
158
    initDefaultJavaRT (&SaxonProcessor::sxn_environ); 
159
    } else {
160
#ifdef DEBUG
161
     std::cerr<<"SaxonProc constructor: jvm exists!"<<std::endl;
162
#endif
163

    
164
}
165

    
166
 
167
    versionClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/Version");
168
    procClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/Processor");
169
    saxonCAPIClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/option/cpp/SaxonCAPI");
170
    
171
    proc = createSaxonProcessor (SaxonProcessor::sxn_environ->env, procClass, "(Z)V", NULL, licensei);
172
        if(!proc) {
173
                std::cout<<"proc is NULL in SaxonProcessor constructor"<<std::endl;
174
        }
175

    
176
    xdmAtomicClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
177
}
178

    
179
SaxonProcessor::SaxonProcessor(const char * configFile){
180
    cwd="";
181
    versionStr = NULL;
182
    refCount++;
183

    
184
    if(jvmCreatedCPP == 0){
185
        jvmCreatedCPP=1;
186
    //SaxonProcessor::sxn_environ= new sxnc_environment;
187
        SaxonProcessor::sxn_environ= (sxnc_environment *)malloc(sizeof(sxnc_environment));
188

    
189
    /*
190
     * First of all, load required component.
191
     * By the time of JET initialization, all components should be loaded.
192
     */
193

    
194
    SaxonProcessor::sxn_environ->myDllHandle = loadDefaultDll ();
195

    
196
    /*
197
     * Initialize JET run-time.
198
     * The handle of loaded component is used to retrieve Invocation API.
199
     */
200
    initDefaultJavaRT (&SaxonProcessor::sxn_environ); 
201
    }
202
 
203
    versionClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/Version");
204

    
205
    procClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/Processor");
206
    saxonCAPIClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/option/cpp/SaxonCAPI");
207

    
208
     static jmethodID mIDcreateProc = (jmethodID)SaxonProcessor::sxn_environ->env->GetStaticMethodID(saxonCAPIClass,"createSaxonProcessor",
209
                                        "(Ljava/lang/String;)Lnet/sf/saxon/s9api/Processor;");
210
                if (!mIDcreateProc) {
211
                        std::cerr << "Error: SaxonDll." << "getPrimitiveTypeName"
212
                                << " not found\n" << std::endl;
213
                        return ;
214
                }
215
        proc = SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, mIDcreateProc,SaxonProcessor::sxn_environ->env->NewStringUTF(configFile));
216
                
217
        if(!proc) {
218
                std::cerr << "Error: SaxonDll." << "processor is NULL in constructor(configFile)"<< std::endl;
219
                return ;        
220
        }
221
        
222
   
223
#ifdef DEBUG
224

    
225
     std::cerr<<"SaxonProc constructor(configFile)"<<std::endl;
226
#endif
227
    xdmAtomicClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
228
}
229

    
230
    SaxonProcessor::~SaxonProcessor(){
231
        clearConfigurationProperties();
232
        if(versionStr != NULL) {
233
                delete versionStr;
234
        }
235
        refCount--;        //This might be redundant due to the bug fix 2670
236
   }
237

    
238

    
239

    
240
void SaxonProcessor::applyConfigurationProperties(){
241
        if(configProperties.size()>0) {
242
                int size = configProperties.size();
243
                jclass stringClass = lookForClass(SaxonProcessor::sxn_environ->env, "java/lang/String");
244
                jobjectArray stringArray1 = SaxonProcessor::sxn_environ->env->NewObjectArray( (jint)size, stringClass, 0 );
245
                jobjectArray stringArray2 = SaxonProcessor::sxn_environ->env->NewObjectArray( (jint)size, stringClass, 0 );
246
                static jmethodID mIDappConfig = NULL;
247
                if(mIDappConfig == NULL) {
248
                        mIDappConfig = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(saxonCAPIClass,"applyToConfiguration",
249
                                        "(Lnet/sf/saxon/s9api/Processor;[Ljava/lang/String;[Ljava/lang/String;)V");
250
                        if (!mIDappConfig) {
251
                                std::cerr << "Error: SaxonDll." << "applyToConfiguration"
252
                                << " not found\n" << std::endl;
253
                                return;
254
                        }
255
                }
256
                int i=0;
257
                for(map<std::string, std::string >::iterator iter=configProperties.begin(); iter!=configProperties.end(); ++iter, i++) {
258
                             SaxonProcessor::sxn_environ->env->SetObjectArrayElement( stringArray1, i, SaxonProcessor::sxn_environ->env->NewStringUTF( (iter->first).c_str()  ));
259
                             SaxonProcessor::sxn_environ->env->SetObjectArrayElement( stringArray2, i, SaxonProcessor::sxn_environ->env->NewStringUTF((iter->second).c_str()) );
260
           }
261
                
262
                SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, mIDappConfig,proc, stringArray1,stringArray2);
263
                if (exceptionOccurred()) {
264
                           exception= checkForExceptionCPP(SaxonProcessor::sxn_environ->env, saxonCAPIClass, NULL);
265
                        exceptionClear();
266
                       }
267
   
268
           SaxonProcessor::sxn_environ->env->DeleteLocalRef(stringArray1);
269
          SaxonProcessor::sxn_environ->env->DeleteLocalRef(stringArray2);
270
                
271
        }
272
}
273

    
274

    
275
SaxonProcessor& SaxonProcessor::operator=( const SaxonProcessor& other ){
276
        versionClass = other.versionClass;
277
        procClass = other.procClass;
278
        saxonCAPIClass = other.saxonCAPIClass;
279
        cwd = other.cwd;
280
        proc = other.proc;
281
        //SaxonProcessor::sxn_environ= other.environ;
282
        parameters = other.parameters;
283
        configProperties = other.configProperties;
284
        licensei = other.licensei;
285
        exception = other.exception;
286
        return *this;
287
}
288

    
289
XsltProcessor * SaxonProcessor::newXsltProcessor(){
290
    applyConfigurationProperties();
291
    return (new XsltProcessor(this, cwd));
292
}
293

    
294
XQueryProcessor * SaxonProcessor::newXQueryProcessor(){
295
    applyConfigurationProperties();
296
    return (new XQueryProcessor(this,cwd));
297
}
298

    
299
XPathProcessor * SaxonProcessor::newXPathProcessor(){
300
    applyConfigurationProperties();
301
    return (new XPathProcessor(this, cwd));
302
}
303

    
304
SchemaValidator * SaxonProcessor::newSchemaValidator(){
305
        if(licensei) {
306
                 applyConfigurationProperties();
307
                return (new SchemaValidator(this, cwd));
308
        } else {
309
                std::cerr<<"\nError: Processor is not licensed for schema processing!"<<std::endl;
310
                return NULL;
311
        }
312
}
313

    
314

    
315

    
316
const char * SaxonProcessor::version() {
317

    
318
     if(versionStr == NULL) {
319
             static jmethodID MID_version = (jmethodID)SaxonProcessor::sxn_environ->env->GetStaticMethodID(saxonCAPIClass, "getProductVersion", "(Lnet/sf/saxon/s9api/Processor;)Ljava/lang/String;");
320
            if (!MID_version) {
321
                std::cerr<<"\nError: MyClassInDll "<<"SaxonCAPI.getProductVersion()"<<" not found"<<std::endl;
322
                return NULL;
323
            }
324

    
325
            jstring jstr = (jstring)(SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, MID_version, proc));
326
            versionStr = SaxonProcessor::sxn_environ->env->GetStringUTFChars(jstr, NULL);
327
    }
328
    return versionStr;
329
}
330

    
331
void SaxonProcessor::setcwd(const char* dir){
332
    cwd = std::string(dir);
333
}
334

    
335
void SaxonProcessor::setResourcesDirectory(const char* dir){
336
        memset(&resources_dir[0], 0, sizeof(resources_dir));
337
        strncat(resources_dir, dir, strlen(dir));
338
}
339

    
340
const char * SaxonProcessor::getResourcesDirectory(){
341
        return getResourceDirectory();
342
}
343

    
344

    
345
XdmNode * SaxonProcessor::parseXmlFromString(const char* source){
346
        
347
    jmethodID mID = (jmethodID)SaxonProcessor::sxn_environ->env->GetStaticMethodID(saxonCAPIClass, "parseXmlString", "(Lnet/sf/saxon/s9api/Processor;Lnet/sf/saxon/s9api/SchemaValidator;Ljava/lang/String;)Lnet/sf/saxon/s9api/XdmNode;");
348
    if (!mID) {
349
        cerr<<"\nError: MyClassInDll "<<"parseXmlString()"<<" not found"<<endl;
350
        return NULL;
351
    }
352
//TODO SchemaValidator
353

    
354
   jobject xdmNodei = SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, NULL, SaxonProcessor::sxn_environ->env->NewStringUTF(source));
355
        if(xdmNodei) {
356
                XdmNode * value = new XdmNode(xdmNodei);
357
                value->setProcessor(this);
358
                return value;
359
        }   else if (exceptionOccurred()) {
360
           exception= checkForExceptionCPP(SaxonProcessor::sxn_environ->env, saxonCAPIClass, NULL);
361
                exceptionClear();
362
       }
363
   
364
#ifdef DEBUG
365
        SaxonProcessor::sxn_environ->env->ExceptionDescribe();
366
#endif
367
 
368
   return NULL;
369
}
370

    
371
int SaxonProcessor::getNodeKind(jobject obj){
372
        jclass xdmNodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "Lnet/sf/saxon/s9api/XdmNode;");
373
        static jmethodID nodeKindMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(xdmNodeClass,"getNodeKind", "()Lnet/sf/saxon/s9api/XdmNodeKind;");
374
        if (!nodeKindMID) {
375
                cerr << "Error: MyClassInDll." << "getNodeKind" << " not found\n"
376
                                << endl;
377
                return 0;
378
        } 
379

    
380
        jobject nodeKindObj = (SaxonProcessor::sxn_environ->env->CallObjectMethod(obj, nodeKindMID));
381
        if(!nodeKindObj) {
382
                std::cout<<"saxonProc nodeKind error"<<std::endl;
383
                return 0;
384
        }
385
        jclass xdmUtilsClass = lookForClass(SaxonProcessor::sxn_environ->env, "Lnet/sf/saxon/option/cpp/XdmUtils;");
386

    
387

    
388
        jmethodID mID2 = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(xdmUtilsClass,"convertNodeKindType", "(Lnet/sf/saxon/s9api/XdmNodeKind;)I");
389

    
390
        if (!mID2) {
391
                cerr << "Error: MyClassInDll." << "convertNodeKindType" << " not found\n"
392
                                << endl;
393
                return 0;
394
        } 
395
        if(!nodeKindObj){
396
                return 0;        
397
        }
398
        int nodeKind = (long)(SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(xdmUtilsClass, mID2, nodeKindObj));
399

    
400
        return nodeKind;
401
}
402

    
403
XdmNode * SaxonProcessor::parseXmlFromFile(const char* source){
404

    
405
    jmethodID mID = (jmethodID)SaxonProcessor::sxn_environ->env->GetStaticMethodID(saxonCAPIClass, "parseXmlFile", "(Lnet/sf/saxon/s9api/Processor;Ljava/lang/String;Lnet/sf/saxon/s9api/SchemaValidator;Ljava/lang/String;)Lnet/sf/saxon/s9api/XdmNode;");
406
    if (!mID) {
407
        cerr<<"\nError: MyClassInDll "<<"parseXmlFile()"<<" not found"<<endl;
408
        return NULL;
409
    }
410
//TODO SchemaValidator
411
   jobject xdmNodei = SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, SaxonProcessor::sxn_environ->env->NewStringUTF(cwd.c_str()),  NULL, SaxonProcessor::sxn_environ->env->NewStringUTF(source));
412
     if(exceptionOccurred()) {
413
           exception= checkForExceptionCPP(SaxonProcessor::sxn_environ->env, saxonCAPIClass, NULL);
414
           exceptionClear();
415
                           
416
     } else {
417

    
418
        XdmNode * value = new XdmNode(xdmNodei);
419
        value->setProcessor(this);
420
        return value;
421
   }
422
   return NULL;
423
}
424

    
425
XdmNode * SaxonProcessor::parseXmlFromUri(const char* source){
426

    
427
    jmethodID mID = (jmethodID)SaxonProcessor::sxn_environ->env->GetStaticMethodID(saxonCAPIClass, "parseXmlFile", "(Lnet/sf/saxon/s9api/Processor;Ljava/lang/String;Ljava/lang/String;)Lnet/sf/saxon/s9api/XdmNode;");
428
    if (!mID) {
429
        cerr<<"\nError: MyClassInDll "<<"parseXmlFromUri()"<<" not found"<<endl;
430
        return NULL;
431
    }
432
   jobject xdmNodei = SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, SaxonProcessor::sxn_environ->env->NewStringUTF(""), SaxonProcessor::sxn_environ->env->NewStringUTF(source));
433
     if(exceptionOccurred()) {
434
           exception= checkForExceptionCPP(SaxonProcessor::sxn_environ->env, saxonCAPIClass, NULL);
435
     } else {
436
        XdmNode * value = new XdmNode(xdmNodei);
437
        value->setProcessor(this);
438
        return value;
439
   }
440
   return NULL;
441
}
442

    
443

    
444
  /**
445
     * Set a configuration property.
446
     *
447
     * @param name of the property
448
     * @param value of the property
449
     */
450
    void SaxonProcessor::setConfigurationProperty(const char * name, const char * value){
451
        configProperties.insert(std::pair<std::string, std::string>(std::string(name), std::string(value)));
452
    }
453

    
454
   void SaxonProcessor::clearConfigurationProperties(){
455
        configProperties.clear();
456
   }
457

    
458

    
459

    
460
void SaxonProcessor::release(){
461
        if(jvmCreatedCPP!=0) {
462
                jvmCreatedCPP =0;
463

    
464
                 finalizeJavaRT (SaxonProcessor::sxn_environ->jvm);
465

    
466
                //delete SaxonProcessor::sxn_environ;
467
        /*clearParameters();
468
        clearProperties();*/
469
} else {
470
#ifdef DEBUG
471
     std::cerr<<"SaxonProc: JVM finalize not called!"<<std::endl;
472
#endif
473
}
474
}
475

    
476

    
477

    
478

    
479
/* ========= Factory method for Xdm ======== */
480

    
481
    XdmAtomicValue * SaxonProcessor::makeStringValue(std::string str){
482
        jobject obj = getJavaStringValue(*SaxonProcessor::sxn_environ, str.c_str());
483
        jmethodID mID_atomic = (jmethodID)(SaxonProcessor::sxn_environ->env->GetMethodID (xdmAtomicClass, "<init>", "(Ljava/lang/String;)V"));
484
        jobject obj2 = (jobject)(SaxonProcessor::sxn_environ->env->NewObject(xdmAtomicClass, mID_atomic, obj));
485
        XdmAtomicValue * value = new XdmAtomicValue(obj2, "xs:string");
486
        value->setProcessor(this);
487
        return value;
488
    }
489

    
490
    XdmAtomicValue * SaxonProcessor::makeStringValue(const char * str){
491
        jobject obj = getJavaStringValue(*SaxonProcessor::sxn_environ, str);
492
        jmethodID mID_atomic = (jmethodID)(SaxonProcessor::sxn_environ->env->GetMethodID (xdmAtomicClass, "<init>", "(Ljava/lang/String;)V"));
493
        jobject obj2 = (jobject)(SaxonProcessor::sxn_environ->env->NewObject(xdmAtomicClass, mID_atomic, obj));
494
        XdmAtomicValue * value = new XdmAtomicValue(obj2, "xs:string");
495
        value->setProcessor(this);
496
        return value;
497
    }
498

    
499
    XdmAtomicValue * SaxonProcessor::makeIntegerValue(int i){
500
        //jobject obj = integerValue(*SaxonProcessor::sxn_environ, i);
501
        jmethodID mID_atomic = (jmethodID)(SaxonProcessor::sxn_environ->env->GetMethodID (xdmAtomicClass, "<init>", "(J)V"));
502
        
503

    
504
        jobject obj = (jobject)(SaxonProcessor::sxn_environ->env->NewObject(xdmAtomicClass, mID_atomic, (jlong)i));
505
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}integer");
506
        value->setProcessor(this);
507
        return value;
508
    }
509

    
510
    XdmAtomicValue * SaxonProcessor::makeDoubleValue(double d){
511
        //jobject obj = doubleValue(*SaxonProcessor::sxn_environ, d);
512
        jmethodID mID_atomic = (jmethodID)(SaxonProcessor::sxn_environ->env->GetMethodID (xdmAtomicClass, "<init>", "(D)V"));
513
        jobject obj = (jobject)(SaxonProcessor::sxn_environ->env->NewObject(xdmAtomicClass, mID_atomic, (jdouble)d));
514
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}double");
515
        value->setProcessor(this);
516
        return value;
517
    }
518

    
519
    XdmAtomicValue * SaxonProcessor::makeFloatValue(float d){
520
        //jobject obj = doubleValue(*SaxonProcessor::sxn_environ, d);
521
        jmethodID mID_atomic = (jmethodID)(SaxonProcessor::sxn_environ->env->GetMethodID (xdmAtomicClass, "<init>", "(F)V"));
522
        jobject obj = (jobject)(SaxonProcessor::sxn_environ->env->NewObject(xdmAtomicClass, mID_atomic, (jfloat)d));
523
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}float");
524
        value->setProcessor(this);
525
        return value;
526
    }
527

    
528
    XdmAtomicValue * SaxonProcessor::makeLongValue(long l){
529
        //jobject obj = longValue(*SaxonProcessor::sxn_environ, l);
530
        jmethodID mID_atomic = (jmethodID)(SaxonProcessor::sxn_environ->env->GetMethodID (xdmAtomicClass, "<init>", "(J)V"));
531
        jobject obj = (jobject)(SaxonProcessor::sxn_environ->env->NewObject(xdmAtomicClass, mID_atomic, (jlong)l));
532
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}long");
533
        value->setProcessor(this);
534
        return value;
535
    }
536

    
537
    XdmAtomicValue * SaxonProcessor::makeBooleanValue(bool b){
538
        //jobject obj = booleanValue(*SaxonProcessor::sxn_environ, b);
539
        jmethodID mID_atomic = (jmethodID)(SaxonProcessor::sxn_environ->env->GetMethodID (xdmAtomicClass, "<init>", "(Z)V"));
540
        jobject obj = (jobject)(SaxonProcessor::sxn_environ->env->NewObject(xdmAtomicClass, mID_atomic, (jboolean)b));
541
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}boolean");
542
        value->setProcessor(this);
543
        return value;
544
    }
545

    
546
    XdmAtomicValue * SaxonProcessor::makeQNameValue(std::string str){
547
        jobject val = xdmValueAsObj(*SaxonProcessor::sxn_environ, "QName", str.c_str());
548
        XdmAtomicValue * value = new XdmAtomicValue(val, "QName");
549
        value->setProcessor(this);
550
        return value;
551
    }
552

    
553
    XdmAtomicValue * SaxonProcessor::makeAtomicValue(std::string typei, std::string strValue){
554
        jobject obj = xdmValueAsObj(*SaxonProcessor::sxn_environ, typei.c_str(), strValue.c_str());
555
        XdmAtomicValue * value = new XdmAtomicValue(obj, typei);
556
        value->setProcessor(this);
557
        return value;
558
    }
559

    
560
    const char * SaxonProcessor::getStringValue(XdmItem * item){
561
        const char *result = stringValue(*SaxonProcessor::sxn_environ, item->getUnderlyingValue(this));
562
#ifdef DEBUG
563
        if(result == NULL) {
564
                std::cout<<"getStringValue of XdmItem is NULL"<<std::endl;
565
        } else {
566
                std::cout<<"getStringValue of XdmItem is OK"<<std::endl;
567
        }
568
#endif
569
        return result;
570
    }
571

    
572

    
573

    
574

    
(8-8/37)