Project

Profile

Help

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

he / latest9.6 / hec / Saxon.C.API / SaxonProcessor.cpp @ 0608038f

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 * environ = 0;
32
int refCount = 0;
33
int 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
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
    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
    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 (&environ); 
159
    } else {
160
#ifdef DEBUG
161
     std::cerr<<"SaxonProc constructor: jvm exists!"<<std::endl;
162
#endif
163

    
164
}
165

    
166
 
167
    versionClass = lookForClass(environ->env, "net/sf/saxon/Version");
168
    procClass = lookForClass(environ->env, "net/sf/saxon/s9api/Processor");
169
    saxonCAPIClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/SaxonCAPI");
170
    
171
    proc = createSaxonProcessor (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(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
    //environ = new sxnc_environment;
187
        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
    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 (&environ); 
201
    }
202
 
203
    versionClass = lookForClass(environ->env, "net/sf/saxon/Version");
204

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

    
208
     static jmethodID mIDcreateProc = (jmethodID)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 = environ->env->CallStaticObjectMethod(saxonCAPIClass, mIDcreateProc,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(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(environ->env, "java/lang/String");
244
                jobjectArray stringArray1 = environ->env->NewObjectArray( (jint)size, stringClass, 0 );
245
                jobjectArray stringArray2 = environ->env->NewObjectArray( (jint)size, stringClass, 0 );
246
                static jmethodID mIDappConfig = NULL;
247
                if(mIDappConfig == NULL) {
248
                        mIDappConfig = (jmethodID) 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
                             environ->env->SetObjectArrayElement( stringArray1, i, environ->env->NewStringUTF( (iter->first).c_str()  ));
259
                             environ->env->SetObjectArrayElement( stringArray2, i, environ->env->NewStringUTF((iter->second).c_str()) );
260
           }
261
                
262
                environ->env->CallStaticObjectMethod(saxonCAPIClass, mIDappConfig,proc, stringArray1,stringArray2);
263
                if (exceptionOccurred()) {
264
                           exception= checkForExceptionCPP(environ->env, saxonCAPIClass, NULL);
265
                        exceptionClear();
266
                       }
267
   
268
           environ->env->DeleteLocalRef(stringArray1);
269
          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
        //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)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)(environ->env->CallStaticObjectMethod(saxonCAPIClass, MID_version, proc));
326
            versionStr = 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)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 = environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, NULL, 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(environ->env, saxonCAPIClass, NULL);
361
                exceptionClear();
362
       }
363
   
364
#ifdef DEBUG
365
        environ->env->ExceptionDescribe();
366
#endif
367
 
368
   return NULL;
369
}
370

    
371
int SaxonProcessor::getNodeKind(jobject obj){
372
        jclass xdmNodeClass = lookForClass(environ->env, "Lnet/sf/saxon/s9api/XdmNode;");
373
        static jmethodID nodeKindMID = (jmethodID) 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 = (environ->env->CallObjectMethod(obj, nodeKindMID));
381
        if(!nodeKindObj) {
382
                std::cout<<"saxonProc nodeKind error"<<std::endl;
383
                return 0;
384
        }
385
        jclass xdmUtilsClass = lookForClass(environ->env, "Lnet/sf/saxon/option/cpp/XdmUtils;");
386

    
387

    
388
        jmethodID mID2 = (jmethodID) 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)(environ->env->CallStaticObjectMethod(xdmUtilsClass, mID2, nodeKindObj));
399

    
400
        return nodeKind;
401
}
402

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

    
405
    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;");
406
    if (!mID) {
407
        cerr<<"\nError: MyClassInDll "<<"parseXmlFile()"<<" not found"<<endl;
408
        return NULL;
409
    }
410
//TODO SchemaValidator
411
   jobject xdmNodei = environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, environ->env->NewStringUTF(cwd.c_str()),  NULL, environ->env->NewStringUTF(source));
412
     if(exceptionOccurred()) {
413
           exception= checkForExceptionCPP(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)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 = environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, environ->env->NewStringUTF(""), environ->env->NewStringUTF(source));
433
     if(exceptionOccurred()) {
434
           exception= checkForExceptionCPP(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
void SaxonProcessor::release(){
460
        if(jvmCreatedCPP!=0) {
461
                jvmCreatedCPP =0;
462

    
463
                 finalizeJavaRT (environ->jvm);
464

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

    
475

    
476

    
477

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

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

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

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

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

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

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

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

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

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

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

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

    
571

    
572

    
573

    
(8-8/37)