Project

Profile

Help

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

he / latest9.6 / hec / Saxon.C.API / SaxonProcessor.cpp @ 3e6ffd64

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::environ = 0;
32
int SaxonProcessor::refCount = 0;
33
int SaxonProcessor::jvmCreatedCPP=0;
34

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

    
39
void SaxonProcessor::exceptionClear(){
40
        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
//TODO - Exception handling in Saxon/C on both Java side and C++ side does not correctly handle multiple exceptions
55
//This needs working on in the next release
56
SaxonApiException * SaxonProcessor::checkForExceptionCPP(JNIEnv* env, jclass callingClass,  jobject callingObject){
57

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

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

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

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

    
98

    
99
                                                int exLength = (int)env->GetArrayLength(saxonExceptionObject);
100
                                                SaxonApiException * saxonExceptions = new SaxonApiException();
101
                                                for(int i=0; i<exLength;i++){
102
                                                        jobject exObj = env->GetObjectArrayElement(saxonExceptionObject, i);
103

    
104
                                                        jstring errCode = (jstring)(env->CallObjectMethod(exObj, ecID));
105
                                                        jstring errMessage = (jstring)(env->CallObjectMethod(exObj, emID));
106
                                                        jboolean isType = (env->CallBooleanMethod(exObj, typeID));
107
                                                        jboolean isStatic = (env->CallBooleanMethod(exObj, staticID));
108
                                                        jboolean isGlobal = (env->CallBooleanMethod(exObj, globalID));
109
                                                        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);
110
                                                        //env->ExceptionDescribe();
111
                                                }
112
                                                //env->ExceptionDescribe();
113
                                                env->ExceptionClear();
114
                                                return saxonExceptions;
115
                                        }
116
                                }
117
                }
118
        }
119
        SaxonApiException * saxonExceptions = new SaxonApiException(NULL, result1.c_str());
120
        //env->ExceptionDescribe();
121
        env->ExceptionClear();
122
        return saxonExceptions;
123
     }
124
        return NULL;
125

    
126
}
127

    
128

    
129

    
130
SaxonProcessor::SaxonProcessor(bool l){
131

    
132
    cwd="";
133
    licensei = l;
134
    versionStr = NULL;
135
    refCount++;
136

    
137

    
138
     if(jvmCreatedCPP == 0){
139
        jvmCreatedCPP=1;
140
    environ = new sxnc_environment;//(sxnc_environment *)malloc(sizeof(sxnc_environment));
141

    
142
    /*
143
     * First of all, load required component.
144
     * By the time of JET initialization, all components should be loaded.
145
     */
146

    
147
    environ->myDllHandle = loadDefaultDll ();
148

    
149
    /*
150
     * Initialize JET run-time.
151
     * The handle of loaded component is used to retrieve Invocation API.
152
     */
153
    initDefaultJavaRT (&environ); 
154
    } else {
155
#ifdef DEBUG
156
     std::cerr<<"SaxonProc constructor: jvm exists!"<<std::endl;
157
#endif
158

    
159
}
160

    
161
 
162
    versionClass = lookForClass(environ->env, "net/sf/saxon/Version");
163
    procClass = lookForClass(environ->env, "net/sf/saxon/s9api/Processor");
164
    saxonCAPIClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/SaxonCAPI");
165
    
166
    proc = createSaxonProcessor (environ->env, procClass, "(Z)V", NULL, licensei);
167
        if(!proc) {
168
                std::cout<<"proc is NULL in SaxonProcessor constructor"<<std::endl;
169
        }
170

    
171
    xdmAtomicClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
172
}
173

    
174
SaxonProcessor::SaxonProcessor(const char * configFile){
175
    cwd="";
176
    versionStr = NULL;
177
    refCount++;
178

    
179
    if(jvmCreatedCPP == 0){
180
        jvmCreatedCPP=1;
181
    //environ = new sxnc_environment;
182
        environ = (sxnc_environment *)malloc(sizeof(sxnc_environment));
183

    
184
    /*
185
     * First of all, load required component.
186
     * By the time of JET initialization, all components should be loaded.
187
     */
188

    
189
    environ->myDllHandle = loadDefaultDll ();
190

    
191
    /*
192
     * Initialize JET run-time.
193
     * The handle of loaded component is used to retrieve Invocation API.
194
     */
195
    initDefaultJavaRT (&environ); 
196
    }
197
 
198
    versionClass = lookForClass(environ->env, "net/sf/saxon/Version");
199

    
200
    procClass = lookForClass(environ->env, "net/sf/saxon/s9api/Processor");
201
    saxonCAPIClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/SaxonCAPI");
202

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

    
220
     std::cerr<<"SaxonProc constructor(configFile)"<<std::endl;
221
#endif
222
    xdmAtomicClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
223
}
224

    
225
    SaxonProcessor::~SaxonProcessor(){
226
        clearConfigurationProperties();
227
        if(versionStr != NULL) {
228
                delete versionStr;
229
        }
230
        refCount--;        //The might be redundant due to the bug fix 2670
231
   }
232

    
233

    
234

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

    
264
                
265
        }
266
}
267

    
268

    
269
SaxonProcessor& SaxonProcessor::operator=( const SaxonProcessor& other ){
270
        versionClass = other.versionClass;
271
        procClass = other.procClass;
272
        saxonCAPIClass = other.saxonCAPIClass;
273
        cwd = other.cwd;
274
        proc = other.proc;
275
        environ = other.environ;
276
        parameters = other.parameters;
277
        configProperties = other.configProperties;
278
        licensei = other.licensei;
279
        exception = other.exception;
280
        return *this;
281
}
282

    
283
XsltProcessor * SaxonProcessor::newXsltProcessor(){
284
    applyConfigurationProperties();
285
    return (new XsltProcessor(this, cwd));
286
}
287

    
288
XQueryProcessor * SaxonProcessor::newXQueryProcessor(){
289
    applyConfigurationProperties();
290
    return (new XQueryProcessor(this,cwd));
291
}
292

    
293
XPathProcessor * SaxonProcessor::newXPathProcessor(){
294
    applyConfigurationProperties();
295
    return (new XPathProcessor(this, cwd));
296
}
297

    
298
SchemaValidator * SaxonProcessor::newSchemaValidator(){
299
        if(licensei) {
300
                 applyConfigurationProperties();
301
                return (new SchemaValidator(this, cwd));
302
        } else {
303
                std::cerr<<"\nError: Processor is not licensed for schema processing!"<<std::endl;
304
                return NULL;
305
        }
306
}
307

    
308

    
309

    
310
const char * SaxonProcessor::version() {
311

    
312
     if(versionStr == NULL) {
313
             static jmethodID MID_version = (jmethodID)environ->env->GetStaticMethodID(saxonCAPIClass, "getProductVersion", "(Lnet/sf/saxon/s9api/Processor;)Ljava/lang/String;");
314
            if (!MID_version) {
315
                std::cerr<<"\nError: MyClassInDll "<<"SaxonCAPI.getProductVersion()"<<" not found"<<std::endl;
316
                return NULL;
317
            }
318

    
319
            jstring jstr = (jstring)(environ->env->CallStaticObjectMethod(saxonCAPIClass, MID_version, proc));
320
            versionStr = environ->env->GetStringUTFChars(jstr, NULL);
321
    }
322
    return versionStr;
323
}
324

    
325
void SaxonProcessor::setcwd(const char* dir){
326
    cwd = std::string(dir);
327
}
328

    
329
void SaxonProcessor::setResourcesDirectory(const char* dir){
330
        memset(&resources_dir[0], 0, sizeof(resources_dir));
331
        strncat(resources_dir, dir, strlen(dir));
332
}
333

    
334
const char * SaxonProcessor::getResourcesDirectory(){
335
        return resources_dir;
336
}
337

    
338

    
339
XdmNode * SaxonProcessor::parseXmlFromString(const char* source){
340
        
341
    jmethodID mID = (jmethodID)environ->env->GetStaticMethodID(saxonCAPIClass, "parseXmlString", "(Lnet/sf/saxon/s9api/Processor;Lnet/sf/saxon/s9api/SchemaValidator;Ljava/lang/String;)Lnet/sf/saxon/s9api/XdmNode;");
342
    if (!mID) {
343
        cerr<<"\nError: MyClassInDll "<<"parseXmlString()"<<" not found"<<endl;
344
        return NULL;
345
    }
346
//TODO SchemaValidator
347

    
348
   jobject xdmNodei = environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, NULL, environ->env->NewStringUTF(source));
349
        if(xdmNodei) {
350
                XdmNode * value = new XdmNode(xdmNodei);
351
                value->setProcessor(this);
352
                return value;
353
        }   else if (exceptionOccurred()) {
354
           exception= checkForExceptionCPP(environ->env, saxonCAPIClass, NULL);
355
                exceptionClear();
356
       }
357
   
358
#ifdef DEBUG
359
        environ->env->ExceptionDescribe();
360
#endif
361
 
362
   return NULL;
363
}
364

    
365
int SaxonProcessor::getNodeKind(jobject obj){
366
        jclass xdmNodeClass = lookForClass(environ->env, "Lnet/sf/saxon/s9api/XdmNode;");
367
        static jmethodID nodeKindMID = (jmethodID) environ->env->GetMethodID(xdmNodeClass,"getNodeKind", "()Lnet/sf/saxon/s9api/XdmNodeKind;");
368
        if (!nodeKindMID) {
369
                cerr << "Error: MyClassInDll." << "getNodeKind" << " not found\n"
370
                                << endl;
371
                return 0;
372
        } 
373

    
374
        jobject nodeKindObj = (environ->env->CallObjectMethod(obj, nodeKindMID));
375
        if(!nodeKindObj) {
376
                std::cout<<"saxonProc nodeKind error"<<std::endl;
377
                return 0;
378
        }
379
        jclass xdmUtilsClass = lookForClass(environ->env, "Lnet/sf/saxon/option/cpp/XdmUtils;");
380

    
381

    
382
        jmethodID mID2 = (jmethodID) environ->env->GetStaticMethodID(xdmUtilsClass,"convertNodeKindType", "(Lnet/sf/saxon/s9api/XdmNodeKind;)I");
383

    
384
        if (!mID2) {
385
                cerr << "Error: MyClassInDll." << "convertNodeKindType" << " not found\n"
386
                                << endl;
387
                return 0;
388
        } 
389
        if(!nodeKindObj){
390
                return 0;        
391
        }
392
        int nodeKind = (long)(environ->env->CallStaticObjectMethod(xdmUtilsClass, mID2, nodeKindObj));
393

    
394
        return nodeKind;
395
}
396

    
397
XdmNode * SaxonProcessor::parseXmlFromFile(const char* source){
398

    
399
    jmethodID mID = (jmethodID)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;");
400
    if (!mID) {
401
        cerr<<"\nError: MyClassInDll "<<"parseXmlFile()"<<" not found"<<endl;
402
        return NULL;
403
    }
404
//TODO SchemaValidator
405
   jobject xdmNodei = environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, environ->env->NewStringUTF(cwd.c_str()),  NULL, environ->env->NewStringUTF(source));
406
     if(exceptionOccurred()) {
407
           exception= checkForExceptionCPP(environ->env, saxonCAPIClass, NULL);
408
           exceptionClear();
409
                           
410
     } else {
411

    
412
        XdmNode * value = new XdmNode(xdmNodei);
413
        value->setProcessor(this);
414
        return value;
415
   }
416
   return NULL;
417
}
418

    
419
XdmNode * SaxonProcessor::parseXmlFromUri(const char* source){
420

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

    
437

    
438
  /**
439
     * Set a configuration property.
440
     *
441
     * @param name of the property
442
     * @param value of the property
443
     */
444
    void SaxonProcessor::setConfigurationProperty(const char * name, const char * value){
445
        configProperties.insert(std::pair<std::string, std::string>(std::string(name), std::string(value)));
446
    }
447

    
448
   void SaxonProcessor::clearConfigurationProperties(){
449
        configProperties.clear();
450
   }
451

    
452

    
453
void SaxonProcessor::release(){
454
        if(SaxonProcessor::jvmCreatedCPP!=0) {
455
                SaxonProcessor::jvmCreatedCPP =0;
456

    
457
                 finalizeJavaRT (SaxonProcessor::environ->jvm);
458

    
459
                //delete environ ;
460
        /*clearParameters();
461
        clearProperties();*/
462
} else {
463
#ifdef DEBUG
464
     std::cerr<<"SaxonProc: JVM finalize not called!"<<std::endl;
465
#endif
466
}
467
}
468

    
469

    
470

    
471

    
472
/* ========= Factory method for Xdm ======== */
473

    
474
    XdmAtomicValue * SaxonProcessor::makeStringValue(std::string str){
475
        jobject obj = getJavaStringValue(*environ, str.c_str());
476
        jmethodID mID_atomic = (jmethodID)(environ->env->GetMethodID (xdmAtomicClass, "<init>", "(Ljava/lang/String;)V"));
477
        jobject obj2 = (jobject)(environ->env->NewObject(xdmAtomicClass, mID_atomic, obj));
478
        XdmAtomicValue * value = new XdmAtomicValue(obj2, "xs:string");
479
        value->setProcessor(this);
480
        return value;
481
    }
482

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

    
492
    XdmAtomicValue * SaxonProcessor::makeIntegerValue(int i){
493
        //jobject obj = integerValue(*environ, i);
494
        jmethodID mID_atomic = (jmethodID)(environ->env->GetMethodID (xdmAtomicClass, "<init>", "(J)V"));
495
        
496

    
497
        jobject obj = (jobject)(environ->env->NewObject(xdmAtomicClass, mID_atomic, (jlong)i));
498
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}integer");
499
        value->setProcessor(this);
500
        return value;
501
    }
502

    
503
    XdmAtomicValue * SaxonProcessor::makeDoubleValue(double d){
504
        //jobject obj = doubleValue(*environ, d);
505
        jmethodID mID_atomic = (jmethodID)(environ->env->GetMethodID (xdmAtomicClass, "<init>", "(D)V"));
506
        jobject obj = (jobject)(environ->env->NewObject(xdmAtomicClass, mID_atomic, (jdouble)d));
507
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}double");
508
        value->setProcessor(this);
509
        return value;
510
    }
511

    
512
    XdmAtomicValue * SaxonProcessor::makeFloatValue(float d){
513
        //jobject obj = doubleValue(*environ, d);
514
        jmethodID mID_atomic = (jmethodID)(environ->env->GetMethodID (xdmAtomicClass, "<init>", "(F)V"));
515
        jobject obj = (jobject)(environ->env->NewObject(xdmAtomicClass, mID_atomic, (jfloat)d));
516
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}float");
517
        value->setProcessor(this);
518
        return value;
519
    }
520

    
521
    XdmAtomicValue * SaxonProcessor::makeLongValue(long l){
522
        //jobject obj = longValue(*environ, l);
523
        jmethodID mID_atomic = (jmethodID)(environ->env->GetMethodID (xdmAtomicClass, "<init>", "(J)V"));
524
        jobject obj = (jobject)(environ->env->NewObject(xdmAtomicClass, mID_atomic, (jlong)l));
525
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}long");
526
        value->setProcessor(this);
527
        return value;
528
    }
529

    
530
    XdmAtomicValue * SaxonProcessor::makeBooleanValue(bool b){
531
        //jobject obj = booleanValue(*environ, b);
532
        jmethodID mID_atomic = (jmethodID)(environ->env->GetMethodID (xdmAtomicClass, "<init>", "(Z)V"));
533
        jobject obj = (jobject)(environ->env->NewObject(xdmAtomicClass, mID_atomic, (jboolean)b));
534
        XdmAtomicValue * value = new XdmAtomicValue(obj, "Q{http://www.w3.org/2001/XMLSchema}boolean");
535
        value->setProcessor(this);
536
        return value;
537
    }
538

    
539
    XdmAtomicValue * SaxonProcessor::makeQNameValue(std::string str){
540
        jobject val = xdmValueAsObj(*environ, "QName", str.c_str());
541
        XdmAtomicValue * value = new XdmAtomicValue(val, "QName");
542
        value->setProcessor(this);
543
        return value;
544
    }
545

    
546
    XdmAtomicValue * SaxonProcessor::makeAtomicValue(std::string typei, std::string strValue){
547
        jobject obj = xdmValueAsObj(*environ, typei.c_str(), strValue.c_str());
548
        XdmAtomicValue * value = new XdmAtomicValue(obj, typei);
549
        value->setProcessor(this);
550
        return value;
551
    }
552

    
553
    const char * SaxonProcessor::getStringValue(XdmItem * item){
554
        const char *result = stringValue(*environ, item->getUnderlyingValue(this));
555
#ifdef DEBUG
556
        if(result == NULL) {
557
                std::cout<<"getStringValue of XdmItem is NULL"<<std::endl;
558
        } else {
559
                std::cout<<"getStringValue of XdmItem is OK"<<std::endl;
560
        }
561
#endif
562
        return result;
563
    }
564

    
565

    
566

    
567

    
(8-8/37)