Project

Profile

Help

Revision 0af164b2

Added by O'Neil Delpratt over 5 years ago

Saxon/C bug fix relating to issue 2772

View differences:

latest9.6/hec/Saxon.C.API/SaxonProcessor.cpp
28 28

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

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

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

  
43 43
SaxonApiException * SaxonProcessor::getException(){
......
141 141

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

  
146 146

  
147 147
    /*
......
149 149
     * By the time of JET initialization, all components should be loaded.
150 150
     */
151 151

  
152
    environ->myDllHandle = loadDefaultDll ();
152
    sxn_environ->myDllHandle = loadDefaultDll ();
153 153

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

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

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

  
179 179
SaxonProcessor::SaxonProcessor(const char * configFile){
......
183 183

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

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

  
194
    environ->myDllHandle = loadDefaultDll ();
194
    sxn_environ->myDllHandle = loadDefaultDll ();
195 195

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

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

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

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

  
230 230
    SaxonProcessor::~SaxonProcessor(){
......
240 240
void SaxonProcessor::applyConfigurationProperties(){
241 241
	if(configProperties.size()>0) {
242 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 );
243
		jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
244
		jobjectArray stringArray1 = sxn_environ->env->NewObjectArray( (jint)size, stringClass, 0 );
245
		jobjectArray stringArray2 = sxn_environ->env->NewObjectArray( (jint)size, stringClass, 0 );
246 246
		static jmethodID mIDappConfig = NULL;
247 247
		if(mIDappConfig == NULL) {
248
			mIDappConfig = (jmethodID) environ->env->GetStaticMethodID(saxonCAPIClass,"applyToConfiguration",
248
			mIDappConfig = (jmethodID) sxn_environ->env->GetStaticMethodID(saxonCAPIClass,"applyToConfiguration",
249 249
					"(Lnet/sf/saxon/s9api/Processor;[Ljava/lang/String;[Ljava/lang/String;)V");
250 250
			if (!mIDappConfig) {
251 251
				std::cerr << "Error: SaxonDll." << "applyToConfiguration"
......
255 255
		}
256 256
		int i=0;
257 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()) );
258
	     		sxn_environ->env->SetObjectArrayElement( stringArray1, i, sxn_environ->env->NewStringUTF( (iter->first).c_str()  ));
259
	     		sxn_environ->env->SetObjectArrayElement( stringArray2, i, sxn_environ->env->NewStringUTF((iter->second).c_str()) );
260 260
	   }
261 261
		
262
		environ->env->CallStaticObjectMethod(saxonCAPIClass, mIDappConfig,proc, stringArray1,stringArray2);
262
		sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, mIDappConfig,proc, stringArray1,stringArray2);
263 263
		if (exceptionOccurred()) {
264
	   		exception= checkForExceptionCPP(environ->env, saxonCAPIClass, NULL);
264
	   		exception= checkForExceptionCPP(sxn_environ->env, saxonCAPIClass, NULL);
265 265
			exceptionClear();
266 266
      		 }
267 267
   
268
 	  environ->env->DeleteLocalRef(stringArray1);
269
	  environ->env->DeleteLocalRef(stringArray2);
268
 	  sxn_environ->env->DeleteLocalRef(stringArray1);
269
	  sxn_environ->env->DeleteLocalRef(stringArray2);
270 270
		
271 271
	}
272 272
}
......
278 278
	saxonCAPIClass = other.saxonCAPIClass;
279 279
	cwd = other.cwd;
280 280
	proc = other.proc;
281
	//environ = other.environ;
281
	//sxn_environ= other.environ;
282 282
	parameters = other.parameters;
283 283
	configProperties = other.configProperties;
284 284
	licensei = other.licensei;
......
316 316
const char * SaxonProcessor::version() {
317 317

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

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

  
345 345
XdmNode * SaxonProcessor::parseXmlFromString(const char* source){
346 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;");
347
    jmethodID mID = (jmethodID)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 348
    if (!mID) {
349 349
	cerr<<"\nError: MyClassInDll "<<"parseXmlString()"<<" not found"<<endl;
350 350
        return NULL;
351 351
    }
352 352
//TODO SchemaValidator
353 353

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

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

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

  
387 387

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

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

  
400 400
	return nodeKind;
401 401
}
402 402

  
403 403
XdmNode * SaxonProcessor::parseXmlFromFile(const char* source){
404 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;");
405
    jmethodID mID = (jmethodID)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 406
    if (!mID) {
407 407
	cerr<<"\nError: MyClassInDll "<<"parseXmlFile()"<<" not found"<<endl;
408 408
        return NULL;
409 409
    }
410 410
//TODO SchemaValidator
411
   jobject xdmNodei = environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, environ->env->NewStringUTF(cwd.c_str()),  NULL, environ->env->NewStringUTF(source));
411
   jobject xdmNodei = sxn_environ->env->CallStaticObjectMethod(saxonCAPIClass, mID, proc, sxn_environ->env->NewStringUTF(cwd.c_str()),  NULL, sxn_environ->env->NewStringUTF(source));
412 412
     if(exceptionOccurred()) {
413
	   exception= checkForExceptionCPP(environ->env, saxonCAPIClass, NULL);
413
	   exception= checkForExceptionCPP(sxn_environ->env, saxonCAPIClass, NULL);
414 414
	   exceptionClear();
415 415
	   		
416 416
     } else {
......
424 424

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

  
458 458

  
459

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

  
463
 		finalizeJavaRT (environ->jvm);
464
 		finalizeJavaRT (sxn_environ->jvm);
464 465

  
465
		//delete environ ;
466
		//delete sxn_environ;
466 467
	/*clearParameters();
467 468
	clearProperties();*/
468 469
} else {
......
478 479
/* ========= Factory method for Xdm ======== */
479 480

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

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

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

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

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

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

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

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

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

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

  
559 560
    const char * SaxonProcessor::getStringValue(XdmItem * item){
560
	const char *result = stringValue(*environ, item->getUnderlyingValue(this));
561
	const char *result = stringValue(*sxn_environ, item->getUnderlyingValue(this));
561 562
#ifdef DEBUG
562 563
	if(result == NULL) {
563 564
		std::cout<<"getStringValue of XdmItem is NULL"<<std::endl;
latest9.6/hec/Saxon.C.API/SaxonProcessor.h
48 48
class XdmAtomicValue;
49 49

  
50 50
extern int jvmCreatedCPP;
51
extern sxnc_environment * environ;
51
extern sxnc_environment * sxn_environ;
52 52
extern int refCount;
53 53

  
54 54
// The Saxon XSLT interface class
......
512 512
    const char * version();
513 513

  
514 514

  
515

  
515 516
//	XPathEngine
516 517
//	XQueryEngine
517 518
//	SchemaManager
latest9.6/hec/Saxon.C.API/SchemaValidator.cpp
15 15
	/*
16 16
	 * Look for class.
17 17
	 */
18
	cppClass = lookForClass(environ->env,
18
	cppClass = lookForClass(sxn_environ->env,
19 19
			"net/sf/saxon/option/cpp/SchemaValidatorForCpp");
20 20
	if ((proc->proc) == NULL) {
21 21
		std::cerr << "Processor is NULL" << std::endl;
22 22
	}
23 23

  
24
	cppV = createSaxonProcessor2(environ->env, cppClass,
24
	cppV = createSaxonProcessor2(sxn_environ->env, cppClass,
25 25
			"(Lnet/sf/saxon/s9api/Processor;)V", proc->proc);
26 26

  
27 27
#ifdef DEBUG
28
	jmethodID debugMID = environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
29
	environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
28
	jmethodID debugMID = sxn_environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
29
	sxn_environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
30 30
#endif    
31 31

  
32 32
	proc->exception = NULL;
......
39 39
				if(proc->exception != NULL) {
40 40
					delete proc->exception;
41 41
				}
42
				proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
42
				proc->exception = proc->checkForExceptionCPP(sxn_environ->env, cppClass, NULL);
43 43
				
44 44
     			
45 45
			
46 46
#ifdef DEBUG
47
		environ->env->ExceptionDescribe();
47
		sxn_environ->env->ExceptionDescribe();
48 48
#endif
49 49
		proc->exceptionClear();
50 50
	}
......
63 63

  
64 64
  XdmNode * SchemaValidator::getValidationReport(){
65 65
	jmethodID mID =
66
		(jmethodID) environ->env->GetMethodID(cppClass, "getValidationReport", "()Lnet/sf/saxon/s9api/XdmNode;");
66
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "getValidationReport", "()Lnet/sf/saxon/s9api/XdmNode;");
67 67
	if (!mID) {
68 68
		std::cerr << "Error: libsaxon." << "validate.getValidationReport()" << " not found\n"
69 69
			<< std::endl;
70 70
	} else {
71 71
		jobject result = (jobject)(
72
			environ->env->CallObjectMethod(cppV, mID));
72
			sxn_environ->env->CallObjectMethod(cppV, mID));
73 73
		
74 74
		if (result) {
75 75
			XdmNode * node = new XdmNode(result);
......
87 87
        }
88 88
	
89 89
	jmethodID mID =
90
		(jmethodID) environ->env->GetMethodID(cppClass, "registerSchema",
90
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "registerSchema",
91 91
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
92 92
	if (!mID) {
93 93
		std::cerr << "Error: libsaxon." << "validate" << " not found\n"
......
95 95
	} else {
96 96
	jobjectArray stringArray = NULL;
97 97
	jobjectArray objectArray = NULL;
98
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
99
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
98
	jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
99
	jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
100 100

  
101 101
	int size = parameters.size() + properties.size();
102 102
#ifdef DEBUG
......
105 105
		std::cerr<<"size:"<<size<<std::endl;
106 106
#endif
107 107
	if (size > 0) {
108
		objectArray = environ->env->NewObjectArray((jint) size,
108
		objectArray = sxn_environ->env->NewObjectArray((jint) size,
109 109
				objectClass, 0);
110
		stringArray = environ->env->NewObjectArray((jint) size,
110
		stringArray = sxn_environ->env->NewObjectArray((jint) size,
111 111
				stringClass, 0);
112 112
		int i = 0;
113 113
		for (std::map<std::string, XdmValue*>::iterator iter = parameters.begin();
114 114
				iter != parameters.end(); ++iter, i++) {
115
			environ->env->SetObjectArrayElement(stringArray, i,
116
					environ->env->NewStringUTF((iter->first).c_str()));
117
			environ->env->SetObjectArrayElement(objectArray, i,
115
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
116
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
117
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
118 118
					(iter->second)->getUnderlyingValue(proc));
119 119
#ifdef DEBUG
120 120
				std::string s1 = typeid(iter->second).name();
......
133 133
		}
134 134
		for (std::map<std::string, std::string>::iterator iter = properties.begin();
135 135
				iter != properties.end(); ++iter, i++) {
136
			environ->env->SetObjectArrayElement(stringArray, i,
137
					environ->env->NewStringUTF((iter->first).c_str()));
138
			environ->env->SetObjectArrayElement(objectArray, i,
139
					environ->env->NewStringUTF((iter->second).c_str()));
136
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
137
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
138
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
139
					sxn_environ->env->NewStringUTF((iter->second).c_str()));
140 140
		}
141 141
	}
142 142
	
143
			environ->env->CallVoidMethod(cppV, mID,
144
					environ->env->NewStringUTF(cwdV.c_str()),
145
					environ->env->NewStringUTF(sourceFile), stringArray, objectArray);
143
			sxn_environ->env->CallVoidMethod(cppV, mID,
144
					sxn_environ->env->NewStringUTF(cwdV.c_str()),
145
					sxn_environ->env->NewStringUTF(sourceFile), stringArray, objectArray);
146 146

  
147 147
	if (size > 0) {
148
		environ->env->DeleteLocalRef(stringArray);
149
		environ->env->DeleteLocalRef(objectArray);
148
		sxn_environ->env->DeleteLocalRef(stringArray);
149
		sxn_environ->env->DeleteLocalRef(objectArray);
150 150
	}
151 151

  
152 152
}
......
154 154
				if(proc->exception != NULL) {
155 155
					delete proc->exception;
156 156
				}
157
				proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
157
				proc->exception = proc->checkForExceptionCPP(sxn_environ->env, cppClass, NULL);
158 158
				
159 159
     			
160 160
			
161 161
#ifdef DEBUG
162
		environ->env->ExceptionDescribe();
162
		sxn_environ->env->ExceptionDescribe();
163 163
#endif
164 164
		proc->exceptionClear();
165 165
	}
......
173 173
	     return;
174 174
        }
175 175
	jmethodID mID =
176
		(jmethodID) environ->env->GetMethodID(cppClass, "registerSchemaString",
176
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "registerSchemaString",
177 177
				"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
178 178

  
179 179
	if (!mID) {
......
182 182
	} else {
183 183
	jobjectArray stringArray = NULL;
184 184
	jobjectArray objectArray = NULL;
185
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
186
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
185
	jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
186
	jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
187 187

  
188 188
	int size = parameters.size() + properties.size();
189 189
#ifdef DEBUG
......
193 193
#endif
194 194

  
195 195
	if (size > 0) {
196
		objectArray = environ->env->NewObjectArray((jint) size,
196
		objectArray = sxn_environ->env->NewObjectArray((jint) size,
197 197
				objectClass, 0);
198
		stringArray = environ->env->NewObjectArray((jint) size,
198
		stringArray = sxn_environ->env->NewObjectArray((jint) size,
199 199
				stringClass, 0);
200 200
		int i = 0;
201 201
		for (std::map<std::string, XdmValue*>::iterator iter = parameters.begin();
202 202
				iter != parameters.end(); ++iter, i++) {
203
			environ->env->SetObjectArrayElement(stringArray, i,
204
					environ->env->NewStringUTF((iter->first).c_str()));
205
			environ->env->SetObjectArrayElement(objectArray, i,
203
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
204
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
205
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
206 206
					(iter->second)->getUnderlyingValue(proc));
207 207
#ifdef DEBUG
208 208
				std::string s1 = typeid(iter->second).name();
......
221 221
		}
222 222
		for (std::map<std::string, std::string>::iterator iter = properties.begin();
223 223
				iter != properties.end(); ++iter, i++) {
224
			environ->env->SetObjectArrayElement(stringArray, i,
225
					environ->env->NewStringUTF((iter->first).c_str()));
226
			environ->env->SetObjectArrayElement(objectArray, i,
227
					environ->env->NewStringUTF((iter->second).c_str()));
224
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
225
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
226
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
227
					sxn_environ->env->NewStringUTF((iter->second).c_str()));
228 228
		}
229 229
	}
230 230

  
231 231
	
232
			environ->env->CallVoidMethod(cppV, mID,
233
					environ->env->NewStringUTF(cwdV.c_str()),
234
					(sourceStr != NULL ? environ->env->NewStringUTF(sourceStr) : NULL), NULL, stringArray, objectArray);
232
			sxn_environ->env->CallVoidMethod(cppV, mID,
233
					sxn_environ->env->NewStringUTF(cwdV.c_str()),
234
					(sourceStr != NULL ? sxn_environ->env->NewStringUTF(sourceStr) : NULL), NULL, stringArray, objectArray);
235 235

  
236 236
	if (size > 0) {
237
		environ->env->DeleteLocalRef(stringArray);
238
		environ->env->DeleteLocalRef(objectArray);
237
		sxn_environ->env->DeleteLocalRef(stringArray);
238
		sxn_environ->env->DeleteLocalRef(objectArray);
239 239
	}
240 240

  
241 241
}
......
245 245
				if(proc->exception != NULL) {
246 246
					delete proc->exception;
247 247
				}
248
				proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
248
				proc->exception = proc->checkForExceptionCPP(sxn_environ->env, cppClass, NULL);
249 249
				
250 250
     			
251 251
#ifdef DEBUG
252
			environ->env->ExceptionDescribe();
252
			sxn_environ->env->ExceptionDescribe();
253 253
#endif
254 254
			proc->exceptionClear();
255 255
		}
......
264 264
        }*/
265 265
setProperty("resources", proc->getResourcesDirectory());
266 266
jmethodID mID =
267
		(jmethodID) environ->env->GetMethodID(cppClass, "validate",
267
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "validate",
268 268
				"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
269 269
if (!mID) {
270 270
	std::cerr << "Error: libsaxon." << "validate" << " not found\n"
......
273 273
} else {
274 274
	jobjectArray stringArray = NULL;
275 275
	jobjectArray objectArray = NULL;
276
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
277
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
276
	jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
277
	jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
278 278

  
279 279
	int size = parameters.size() + properties.size();
280 280
#ifdef DEBUG
......
283 283
		std::cerr<<"size:"<<size<<std::endl;
284 284
#endif
285 285
	if (size > 0) {
286
		objectArray = environ->env->NewObjectArray((jint) size,
286
		objectArray = sxn_environ->env->NewObjectArray((jint) size,
287 287
				objectClass, 0);
288
		stringArray = environ->env->NewObjectArray((jint) size,
288
		stringArray = sxn_environ->env->NewObjectArray((jint) size,
289 289
				stringClass, 0);
290 290
		int i = 0;
291 291
		for (std::map<std::string, XdmValue*>::iterator iter = parameters.begin();
292 292
				iter != parameters.end(); ++iter, i++) {
293
			environ->env->SetObjectArrayElement(stringArray, i,
294
					environ->env->NewStringUTF((iter->first).c_str()));
295
			environ->env->SetObjectArrayElement(objectArray, i,
293
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
294
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
295
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
296 296
					(iter->second)->getUnderlyingValue(proc));
297 297

  
298 298
#ifdef DEBUG
......
312 312
		}
313 313
		for (std::map<std::string, std::string>::iterator iter = properties.begin();
314 314
				iter != properties.end(); ++iter, i++) {
315
			environ->env->SetObjectArrayElement(stringArray, i,
316
					environ->env->NewStringUTF((iter->first).c_str()));
317
			environ->env->SetObjectArrayElement(objectArray, i,
318
					environ->env->NewStringUTF((iter->second).c_str()));
315
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
316
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
317
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
318
					sxn_environ->env->NewStringUTF((iter->second).c_str()));
319 319

  
320 320
		}
321 321
	}
322 322
	
323
			environ->env->CallVoidMethod(cppV, mID,
324
					environ->env->NewStringUTF(cwdV.c_str()), 
325
					(sourceFile != NULL ? environ->env->NewStringUTF(sourceFile) : NULL), (outputFile.empty() ? NULL : outputFile.c_str() ), stringArray, objectArray);
323
			sxn_environ->env->CallVoidMethod(cppV, mID,
324
					sxn_environ->env->NewStringUTF(cwdV.c_str()), 
325
					(sourceFile != NULL ? sxn_environ->env->NewStringUTF(sourceFile) : NULL), (outputFile.empty() ? NULL : outputFile.c_str() ), stringArray, objectArray);
326 326

  
327 327
	if (size > 0) {
328
		environ->env->DeleteLocalRef(stringArray);
329
		environ->env->DeleteLocalRef(objectArray);
328
		sxn_environ->env->DeleteLocalRef(stringArray);
329
		sxn_environ->env->DeleteLocalRef(objectArray);
330 330
	}
331 331
		if(exceptionOccurred()) {
332 332
			if(proc->exception != NULL) {
333 333
				delete proc->exception;
334 334
			}
335
				proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
335
				proc->exception = proc->checkForExceptionCPP(sxn_environ->env, cppClass, NULL);
336 336
				
337 337
     			
338 338

  
339 339

  
340 340
#ifdef DEBUG
341
	environ->env->ExceptionDescribe();
341
	sxn_environ->env->ExceptionDescribe();
342 342
#endif
343 343
			proc->exceptionClear();
344 344
		}
......
352 352
        }
353 353
setProperty("resources", proc->getResourcesDirectory());
354 354
jmethodID mID =
355
		(jmethodID) environ->env->GetMethodID(cppClass, "validateToNode",
355
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "validateToNode",
356 356
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmNode;");
357 357
if (!mID) {
358 358
	std::cerr << "Error: libsaxon." << "validate" << " not found\n"
......
361 361
} else {
362 362
	jobjectArray stringArray = NULL;
363 363
	jobjectArray objectArray = NULL;
364
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
365
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
364
	jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
365
	jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
366 366

  
367 367
	int size = parameters.size() + properties.size();
368 368
#ifdef DEBUG
......
371 371
		std::cerr<<"size:"<<size<<std::endl;
372 372
#endif
373 373
	if (size > 0) {
374
		objectArray = environ->env->NewObjectArray((jint) size,
374
		objectArray = sxn_environ->env->NewObjectArray((jint) size,
375 375
				objectClass, 0);
376
		stringArray = environ->env->NewObjectArray((jint) size,
376
		stringArray = sxn_environ->env->NewObjectArray((jint) size,
377 377
				stringClass, 0);
378 378
		int i = 0;
379 379
		for (std::map<std::string, XdmValue*>::iterator iter = parameters.begin();
380 380
				iter != parameters.end(); ++iter, i++) {
381
			environ->env->SetObjectArrayElement(stringArray, i,
382
					environ->env->NewStringUTF((iter->first).c_str()));
383
			environ->env->SetObjectArrayElement(objectArray, i,
381
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
382
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
383
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
384 384
					(iter->second)->getUnderlyingValue(proc));
385 385
#ifdef DEBUG
386 386
				std::string s1 = typeid(iter->second).name();
......
399 399
		}
400 400
		for (std::map<std::string, std::string>::iterator iter = properties.begin();
401 401
				iter != properties.end(); ++iter, i++) {
402
			environ->env->SetObjectArrayElement(stringArray, i,
403
					environ->env->NewStringUTF((iter->first).c_str()));
404
			environ->env->SetObjectArrayElement(objectArray, i,
405
					environ->env->NewStringUTF((iter->second).c_str()));
402
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
403
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
404
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
405
					sxn_environ->env->NewStringUTF((iter->second).c_str()));
406 406
		}
407 407
	}
408 408
	jobject result = (jobject)(
409
			environ->env->CallObjectMethod(cppV, mID,
410
					environ->env->NewStringUTF(cwdV.c_str()),
411
					environ->env->NewStringUTF(sourceFile), stringArray, objectArray));
409
			sxn_environ->env->CallObjectMethod(cppV, mID,
410
					sxn_environ->env->NewStringUTF(cwdV.c_str()),
411
					sxn_environ->env->NewStringUTF(sourceFile), stringArray, objectArray));
412 412
	if (size > 0) {
413
		environ->env->DeleteLocalRef(stringArray);
414
		environ->env->DeleteLocalRef(objectArray);
413
		sxn_environ->env->DeleteLocalRef(stringArray);
414
		sxn_environ->env->DeleteLocalRef(objectArray);
415 415
	}
416 416
	if (result) {
417 417
		XdmNode * node = new XdmNode(result);
......
421 421

  
422 422
}
423 423
#ifdef DEBUG
424
	environ->env->ExceptionDescribe();
424
	sxn_environ->env->ExceptionDescribe();
425 425
#endif
426
environ->env->ExceptionClear();
426
sxn_environ->env->ExceptionClear();
427 427

  
428 428
}
429 429

  
......
432 432
 	delete proc->exception;
433 433
 	proc->exception = NULL;
434 434
 }
435
   environ->env->ExceptionClear();
435
   sxn_environ->env->ExceptionClear();
436 436
 }
437 437

  
438 438
const char * SchemaValidator::getErrorCode(int i) {
......
454 454
	 proc->exception = proc->checkForException(environ, cppClass, cpp);
455 455
	 }
456 456
	 return proc->exception;*/
457
	return checkForException(*(environ), cppClass, cppV);
457
	return checkForException(*(sxn_environ), cppClass, cppV);
458 458
}
459 459

  
460 460
int SchemaValidator::exceptionCount(){
latest9.6/hec/Saxon.C.API/XPathProcessor.cpp
15 15
	/*
16 16
	 * Look for class.
17 17
	 */
18
	cppClass = lookForClass(environ->env,
18
	cppClass = lookForClass(sxn_environ->env,
19 19
			"net/sf/saxon/option/cpp/XPathProcessor");
20 20
	if ((proc->proc) == NULL) {
21 21
		cerr << "Processor is NULL" << endl;
22 22
	}
23 23

  
24
	cppXP = createSaxonProcessor2(environ->env, cppClass,
24
	cppXP = createSaxonProcessor2(sxn_environ->env, cppClass,
25 25
			"(Lnet/sf/saxon/s9api/Processor;)V", proc->proc);
26 26

  
27 27

  
28 28

  
29 29
#ifdef DEBUG
30
	jmethodID debugMID = environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
31
	environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
30
	jmethodID debugMID = sxn_environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
31
	sxn_environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
32 32
#endif    
33 33

  
34 34
	proc->exception = NULL;
......
47 47
}
48 48
setProperty("resources", proc->getResourcesDirectory());
49 49
jmethodID mID =
50
		(jmethodID) environ->env->GetMethodID(cppClass, "evaluate",
50
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "evaluate",
51 51
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)[Lnet/sf/saxon/s9api/XdmValue;");
52 52
if (!mID) {
53 53
	cerr << "Error: MyClassInDll." << "evaluate" << " not found\n"
......
56 56
} else {
57 57
	jobjectArray stringArray = NULL;
58 58
	jobjectArray objectArray = NULL;
59
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
60
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
59
	jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
60
	jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
61 61

  
62 62
	int size = parameters.size() + properties.size();
63 63
	if (size > 0) {
64
		objectArray = environ->env->NewObjectArray((jint) size,
64
		objectArray = sxn_environ->env->NewObjectArray((jint) size,
65 65
				objectClass, 0);
66
		stringArray = environ->env->NewObjectArray((jint) size,
66
		stringArray = sxn_environ->env->NewObjectArray((jint) size,
67 67
				stringClass, 0);
68 68
		int i = 0;
69 69
		for (map<std::string, XdmValue*>::iterator iter = parameters.begin();
70 70
				iter != parameters.end(); ++iter, i++) {
71
			environ->env->SetObjectArrayElement(stringArray, i,
72
					environ->env->NewStringUTF((iter->first).c_str()));
73
			environ->env->SetObjectArrayElement(objectArray, i,
71
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
72
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
73
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
74 74
					(iter->second)->getUnderlyingValue(proc));
75 75
		}
76 76
		for (map<std::string, std::string>::iterator iter = properties.begin();
77 77
				iter != properties.end(); ++iter, i++) {
78
			environ->env->SetObjectArrayElement(stringArray, i,
79
					environ->env->NewStringUTF((iter->first).c_str()));
80
			environ->env->SetObjectArrayElement(objectArray, i,
81
					environ->env->NewStringUTF((iter->second).c_str()));
78
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
79
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
80
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
81
					sxn_environ->env->NewStringUTF((iter->second).c_str()));
82 82
		}
83 83
	}
84 84
	jobjectArray results = (jobjectArray)(
85
			environ->env->CallObjectMethod(cppXP, mID,
86
					environ->env->NewStringUTF(cwdXP.c_str()),
87
					environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
85
			sxn_environ->env->CallObjectMethod(cppXP, mID,
86
					sxn_environ->env->NewStringUTF(cwdXP.c_str()),
87
					sxn_environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
88 88
	if(!results) {
89 89
		if(exceptionOccurred()) {
90 90
			if(proc->exception != NULL) {
91 91
				delete proc->exception;
92 92
			}
93
			proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
93
			proc->exception = proc->checkForExceptionCPP(sxn_environ->env, cppClass, NULL);
94 94
			proc->exceptionClear();
95 95
			return NULL;
96 96
	   		
97 97
     		}
98 98
	}
99 99
	
100
	int sizex = environ->env->GetArrayLength(results);
100
	int sizex = sxn_environ->env->GetArrayLength(results);
101 101
	if (size > 0) {
102
		environ->env->DeleteLocalRef(stringArray);
103
		environ->env->DeleteLocalRef(objectArray);
102
		sxn_environ->env->DeleteLocalRef(stringArray);
103
		sxn_environ->env->DeleteLocalRef(objectArray);
104 104
	}
105 105
	if (sizex>0) {
106
		jclass atomicValueClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
107
		jclass nodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmNode");
108
		jclass functionItemClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
106
		jclass atomicValueClass = lookForClass(sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
107
		jclass nodeClass = lookForClass(sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
108
		jclass functionItemClass = lookForClass(sxn_environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
109 109

  
110 110
		XdmValue * value = new XdmValue();
111 111
		value->setProcessor(proc);
112 112
		XdmItem * xdmItem = NULL;
113 113
		for (int p=0; p < sizex; ++p) 
114 114
		{
115
			jobject resulti = environ->env->GetObjectArrayElement(results, p);
115
			jobject resulti = sxn_environ->env->GetObjectArrayElement(results, p);
116 116
			//value->addUnderlyingValue(resulti);
117 117

  
118
			if(environ->env->IsInstanceOf(resulti, atomicValueClass)           == JNI_TRUE) {
118
			if(sxn_environ->env->IsInstanceOf(resulti, atomicValueClass)           == JNI_TRUE) {
119 119
				xdmItem = new XdmAtomicValue(resulti);
120 120
				
121 121

  
122
			} else if(environ->env->IsInstanceOf(resulti, nodeClass)           == JNI_TRUE) {
122
			} else if(sxn_environ->env->IsInstanceOf(resulti, nodeClass)           == JNI_TRUE) {
123 123
				xdmItem = new XdmNode(resulti);
124 124

  
125 125

  
126
			} else if (environ->env->IsInstanceOf(resulti, functionItemClass)           == JNI_TRUE) {
126
			} else if (sxn_environ->env->IsInstanceOf(resulti, functionItemClass)           == JNI_TRUE) {
127 127
				continue;
128 128
			}
129 129
			xdmItem->setProcessor(proc);
130 130
			value->addXdmItem(xdmItem);
131 131
		}
132
		environ->env->DeleteLocalRef(results);
132
		sxn_environ->env->DeleteLocalRef(results);
133 133
		return value;
134 134
	}
135 135
}
......
144 144
        }
145 145
setProperty("resources", proc->getResourcesDirectory());
146 146
jmethodID mID =
147
		(jmethodID) environ->env->GetMethodID(cppClass, "evaluateSingle",
147
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "evaluateSingle",
148 148
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmItem;");
149 149
if (!mID) {
150 150
	cerr << "Error: MyClassInDll." << "evaluateSingle" << " not found\n"
......
153 153
} else {
154 154
	jobjectArray stringArray = NULL;
155 155
	jobjectArray objectArray = NULL;
156
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
157
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
156
	jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
157
	jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
158 158

  
159 159
	int size = parameters.size() + properties.size();
160 160
#ifdef DEBUG
......
163 163
		cerr<<"size:"<<size<<endl;
164 164
#endif
165 165
	if (size > 0) {
166
		objectArray = environ->env->NewObjectArray((jint) size,
166
		objectArray = sxn_environ->env->NewObjectArray((jint) size,
167 167
				objectClass, 0);
168
		stringArray = environ->env->NewObjectArray((jint) size,
168
		stringArray = sxn_environ->env->NewObjectArray((jint) size,
169 169
				stringClass, 0);
170 170
		int i = 0;
171 171
		for (map<std::string, XdmValue*>::iterator iter = parameters.begin();
172 172
				iter != parameters.end(); ++iter, i++) {
173
			environ->env->SetObjectArrayElement(stringArray, i,
174
					environ->env->NewStringUTF((iter->first).c_str()));
175
			environ->env->SetObjectArrayElement(objectArray, i,
173
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
174
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
175
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
176 176
					(iter->second)->getUnderlyingValue(proc));
177 177
#ifdef DEBUG
178 178
				string s1 = typeid(iter->second).name();
......
191 191
		}
192 192
		for (map<std::string, std::string>::iterator iter = properties.begin();
193 193
				iter != properties.end(); ++iter, i++) {
194
			environ->env->SetObjectArrayElement(stringArray, i,
195
					environ->env->NewStringUTF((iter->first).c_str()));
196
			environ->env->SetObjectArrayElement(objectArray, i,
197
					environ->env->NewStringUTF((iter->second).c_str()));
194
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
195
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
196
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
197
					sxn_environ->env->NewStringUTF((iter->second).c_str()));
198 198
		}
199 199
	}
200 200
	jobject result = (jobject)(
201
			environ->env->CallObjectMethod(cppXP, mID,
202
					environ->env->NewStringUTF(cwdXP.c_str()),
203
					environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
201
			sxn_environ->env->CallObjectMethod(cppXP, mID,
202
					sxn_environ->env->NewStringUTF(cwdXP.c_str()),
203
					sxn_environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
204 204
	if (size > 0) {
205
		environ->env->DeleteLocalRef(stringArray);
206
		environ->env->DeleteLocalRef(objectArray);
205
		sxn_environ->env->DeleteLocalRef(stringArray);
206
		sxn_environ->env->DeleteLocalRef(objectArray);
207 207
	}
208 208
	if (result) {
209
		jclass atomicValueClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
210
		jclass nodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmNode");
211
		jclass functionItemClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
209
		jclass atomicValueClass = lookForClass(sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
210
		jclass nodeClass = lookForClass(sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
211
		jclass functionItemClass = lookForClass(sxn_environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
212 212
		XdmItem * xdmItem = NULL;
213
		if(environ->env->IsInstanceOf(result, atomicValueClass)           == JNI_TRUE) {
213
		if(sxn_environ->env->IsInstanceOf(result, atomicValueClass)           == JNI_TRUE) {
214 214
			xdmItem = new XdmAtomicValue(result);
215 215

  
216
		} else if(environ->env->IsInstanceOf(result, nodeClass)           == JNI_TRUE) {
216
		} else if(sxn_environ->env->IsInstanceOf(result, nodeClass)           == JNI_TRUE) {
217 217
			
218 218
			xdmItem = new XdmNode(result);
219 219

  
220
		} else if (environ->env->IsInstanceOf(result, functionItemClass)           == JNI_TRUE) {
220
		} else if (sxn_environ->env->IsInstanceOf(result, functionItemClass)           == JNI_TRUE) {
221 221
			return NULL;
222 222
		}
223 223
		xdmItem->setProcessor(proc);
......
226 226
			if(proc->exception != NULL) {
227 227
				delete proc->exception;
228 228
			}
229
			proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
229
			proc->exception = proc->checkForExceptionCPP(sxn_environ->env, cppClass, NULL);
230 230
			proc->exceptionClear();
231 231
	   		
232 232
     		}
......
256 256
		return;
257 257
        }
258 258
	jmethodID mID =
259
		(jmethodID) environ->env->GetMethodID(cppClass, "declareNamespace",
259
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "declareNamespace",
260 260
				"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
261 261
	if (!mID) {
262 262
	cerr << "Error: MyClassInDll." << "declareNameSpace" << " not found\n"
263 263
			<< endl;
264 264

  
265 265
	} else {
266
			environ->env->CallObjectMethod(cppXP, mID,
267
					environ->env->NewStringUTF(prefix),
268
					environ->env->NewStringUTF(uri));
266
			sxn_environ->env->CallObjectMethod(cppXP, mID,
267
					sxn_environ->env->NewStringUTF(prefix),
268
					sxn_environ->env->NewStringUTF(uri));
269 269
	}
270 270

  
271 271
}
......
277 277
        }
278 278
setProperty("resources", proc->getResourcesDirectory());
279 279
jmethodID mID =
280
		(jmethodID) environ->env->GetMethodID(cppClass, "setBaseURI",
280
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "setBaseURI",
281 281
				"(Ljava/lang/String;)Z");
282 282
if (!mID) {
283 283
	cerr << "Error: MyClassInDll." << "setBaseURI" << " not found\n"
......
285 285

  
286 286
} else {
287 287

  
288
	environ->env->CallObjectMethod(cppXP, mID,
289
					environ->env->NewStringUTF(uriStr));
288
	sxn_environ->env->CallObjectMethod(cppXP, mID,
289
					sxn_environ->env->NewStringUTF(uriStr));
290 290
}
291 291

  
292 292
}
......
298 298
        }
299 299
setProperty("resources", proc->getResourcesDirectory());
300 300
jmethodID mID =
301
		(jmethodID) environ->env->GetMethodID(cppClass, "effectiveBooleanValue",
301
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "effectiveBooleanValue",
302 302
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Z");
303 303
if (!mID) {
304 304
	cerr << "Error: MyClassInDll." << "effectiveBooleanValue" << " not found\n"
......
307 307
} else {
308 308
	jobjectArray stringArray = NULL;
309 309
	jobjectArray objectArray = NULL;
310
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
311
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
310
	jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
311
	jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
312 312

  
313 313
	int size = parameters.size() + properties.size();
314 314
	if (size > 0) {
315
		objectArray = environ->env->NewObjectArray((jint) size,
315
		objectArray = sxn_environ->env->NewObjectArray((jint) size,
316 316
				objectClass, 0);
317
		stringArray = environ->env->NewObjectArray((jint) size,
317
		stringArray = sxn_environ->env->NewObjectArray((jint) size,
318 318
				stringClass, 0);
319 319
		int i = 0;
320 320
		for (map<std::string, XdmValue*>::iterator iter = parameters.begin();
321 321
				iter != parameters.end(); ++iter, i++) {
322
			environ->env->SetObjectArrayElement(stringArray, i,
323
					environ->env->NewStringUTF((iter->first).c_str()));
324
			environ->env->SetObjectArrayElement(objectArray, i,
322
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
323
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
324
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
325 325
					(iter->second)->getUnderlyingValue(proc));
326 326
		}
327 327
		for (map<std::string, std::string>::iterator iter = properties.begin();
328 328
				iter != properties.end(); ++iter, i++) {
329
			environ->env->SetObjectArrayElement(stringArray, i,
330
					environ->env->NewStringUTF((iter->first).c_str()));
331
			environ->env->SetObjectArrayElement(objectArray, i,
332
					environ->env->NewStringUTF((iter->second).c_str()));
329
			sxn_environ->env->SetObjectArrayElement(stringArray, i,
330
					sxn_environ->env->NewStringUTF((iter->first).c_str()));
331
			sxn_environ->env->SetObjectArrayElement(objectArray, i,
332
					sxn_environ->env->NewStringUTF((iter->second).c_str()));
333 333
		}
334 334
	}
335 335
	jboolean result = (jboolean)(
336
			environ->env->CallBooleanMethod(cppXP, mID,
337
					environ->env->NewStringUTF(cwdXP.c_str()),
338
					environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
336
			sxn_environ->env->CallBooleanMethod(cppXP, mID,
337
					sxn_environ->env->NewStringUTF(cwdXP.c_str()),
338
					sxn_environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
339 339
	if (size > 0) {
340
		environ->env->DeleteLocalRef(stringArray);
341
		environ->env->DeleteLocalRef(objectArray);
340
		sxn_environ->env->DeleteLocalRef(stringArray);
341
		sxn_environ->env->DeleteLocalRef(objectArray);
342 342
	}
343 343
	if(exceptionOccurred()) {
344 344
			if(proc->exception != NULL) {
345 345
				delete proc->exception;
346 346
			}
347
			proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
347
			proc->exception = proc->checkForExceptionCPP(sxn_environ->env, cppClass, NULL);
348 348
			proc->exceptionClear();
349 349
	   		
350 350
     	}
......
414 414
		proc->exception = NULL;	
415 415
	}
416 416

  
417
   environ->env->ExceptionClear();
417
   sxn_environ->env->ExceptionClear();
418 418
 
419 419
}
420 420

  
......
442 442

  
443 443

  
444 444
    const char* XPathProcessor::checkException(){
445
	return checkForException(*(environ), cppClass, cppXP);
445
	return checkForException(*(sxn_environ), cppClass, cppXP);
446 446
    }
447 447

  
latest9.6/hec/Saxon.C.API/XQueryProcessor.cpp
13 13
    proc = p;
14 14

  
15 15
  
16
     cppClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/XQueryEngine");
16
     cppClass = lookForClass(sxn_environ->env, "net/sf/saxon/option/cpp/XQueryEngine");
17 17

  
18 18

  
19
    cppXQ = createSaxonProcessor2 (environ->env, cppClass, "(Lnet/sf/saxon/s9api/Processor;)V", proc->proc);
19
    cppXQ = createSaxonProcessor2 (sxn_environ->env, cppClass, "(Lnet/sf/saxon/s9api/Processor;)V", proc->proc);
20 20
    
21 21
#ifdef DEBUG
22
	jmethodID debugMID = environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
23
	environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
22
	jmethodID debugMID = sxn_environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
23
	sxn_environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
24 24
#endif
25 25

  
26 26
    proc->exception = NULL;
......
61 61
		return;
62 62
        }
63 63
	jmethodID mID =
64
		(jmethodID) environ->env->GetMethodID(cppClass, "declareNamespace",
64
		(jmethodID) sxn_environ->env->GetMethodID(cppClass, "declareNamespace",
65 65
				"(Ljava/lang/String;Ljava/lang/String;)V");
66 66
	if (!mID) {
67 67
	cerr << "Error: MyClassInDll." << "declareNameSpace" << " not found\n"
......
69 69

  
70 70
	} else {
71 71
	
72
			environ->env->CallObjectMethod(cppXQ, mID,
73
					environ->env->NewStringUTF(prefix),
74
					environ->env->NewStringUTF(uri));
72
			sxn_environ->env->CallObjectMethod(cppXQ, mID,
73
					sxn_environ->env->NewStringUTF(prefix),
74
					sxn_environ->env->NewStringUTF(uri));
75 75
	}
76 76

  
77 77
}
......
164 164
    void XQueryProcessor::executeQueryToFile(const char * infilename, const char * ofilename, const char * query){
165 165
	setProperty("resources", proc->getResourcesDirectory());  
166 166

  
167
	jmethodID mID = (jmethodID)environ->env->GetMethodID (cppClass,"executeQueryToFile", "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
167
	jmethodID mID = (jmethodID)sxn_environ->env->GetMethodID (cppClass,"executeQueryToFile", "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
168 168
 	if (!mID) {
169 169
        cout<<"Error: MyClassInDll."<<"executeQueryToFile"<<" not found\n"<<endl;
170 170
    } else {
......
177 177
	if(size >0) {
178 178

  
179 179
	   int i=0;
180
           jclass objectClass = lookForClass(environ->env, "java/lang/Object");
181
	   jclass stringClass = lookForClass(environ->env, "java/lang/String");
182
	   objectArray = environ->env->NewObjectArray( (jint)size, objectClass, 0 );
183
	   stringArray = environ->env->NewObjectArray( (jint)size, stringClass, 0 );
180
           jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
181
	   jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
182
	   objectArray = sxn_environ->env->NewObjectArray( (jint)size, objectClass, 0 );
183
	   stringArray = sxn_environ->env->NewObjectArray( (jint)size, stringClass, 0 );
184 184
	   if(query!= NULL) {
185
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("qs") );
186
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(query));
185
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF("qs") );
186
     	     sxn_environ->env->SetObjectArrayElement( objectArray, i, sxn_environ->env->NewStringUTF(query));
187 187
	     i++;	
188 188
	   }
189 189
	   if(infilename!= NULL) {
190
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("s") );
191
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(infilename));
190
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF("s") );
191
     	     sxn_environ->env->SetObjectArrayElement( objectArray, i, sxn_environ->env->NewStringUTF(infilename));
192 192
	     i++;	
193 193
	   }
194 194
	   for(map<std::string, XdmValue* >::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter, i++) {
195
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str() ) );
196
		bool checkCast = environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
195
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF( (iter->first).c_str() ) );
196
		bool checkCast = sxn_environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(sxn_environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
197 197
		if(( (bool)checkCast)==false ){
198 198
			failure = "FAILURE in  array of XdmValueForCpp";
199 199
		} 
200
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
200
	     sxn_environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
201 201
	   }
202 202
  	   for(map<std::string, std::string >::iterator iter=properties.begin(); iter!=properties.end(); ++iter, i++) {
203
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str()  ));
204
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)(environ->env->NewStringUTF((iter->second).c_str())) );
203
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF( (iter->first).c_str()  ));
204
	     sxn_environ->env->SetObjectArrayElement( objectArray, i, (jobject)(sxn_environ->env->NewStringUTF((iter->second).c_str())) );
205 205
	   }
206 206
	}
207 207

  
208
	 environ->env->CallObjectMethod(cppXQ, mID, environ->env->NewStringUTF(cwdXQ.c_str()), environ->env->NewStringUTF(ofilename), stringArray, objectArray );
209
	  environ->env->DeleteLocalRef(objectArray);
210
	  environ->env->DeleteLocalRef(stringArray);
208
	 sxn_environ->env->CallObjectMethod(cppXQ, mID, sxn_environ->env->NewStringUTF(cwdXQ.c_str()), sxn_environ->env->NewStringUTF(ofilename), stringArray, objectArray );
209
	  sxn_environ->env->DeleteLocalRef(objectArray);
210
	  sxn_environ->env->DeleteLocalRef(stringArray);
211 211

  
212 212
	if(exceptionOccurred()) {
213 213
			if(proc->exception != NULL) {
214 214
				delete proc->exception;
215 215
			}		
216
		proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);	
216
		proc->exception = proc->checkForExceptionCPP(sxn_environ->env, cppClass, NULL);	
217 217
		proc->exceptionClear();
218 218
	   		
219 219
     	}
......
226 226

  
227 227
    XdmValue * XQueryProcessor::executeQueryToValue(const char * infilename, const char * query){
228 228
	setProperty("resources", proc->getResourcesDirectory()); 
229
 jmethodID mID = (jmethodID)environ->env->GetMethodID (cppClass,"executeQueryToValue", "(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
229
 jmethodID mID = (jmethodID)sxn_environ->env->GetMethodID (cppClass,"executeQueryToValue", "(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
230 230
 if (!mID) {
231 231
        cout<<"Error: MyClassInDll."<<"executeQueryToValue"<<" not found\n"<<endl;
232 232
    } else {
......
238 238
	if(infilename!= NULL) size++;
239 239
	if(size >0) {
240 240
	   int i=0;
241
           jclass objectClass = lookForClass(environ->env, "java/lang/Object");
242
	   jclass stringClass = lookForClass(environ->env, "java/lang/String");
243
	   objectArray = environ->env->NewObjectArray( (jint)size, objectClass, 0 );
244
	   stringArray = environ->env->NewObjectArray( (jint)size, stringClass, 0 );
241
           jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
242
	   jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
243
	   objectArray = sxn_environ->env->NewObjectArray( (jint)size, objectClass, 0 );
244
	   stringArray = sxn_environ->env->NewObjectArray( (jint)size, stringClass, 0 );
245 245

  
246 246
	   if(query!= NULL) {
247
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("qs") );
248
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(query));
247
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF("qs") );
248
     	     sxn_environ->env->SetObjectArrayElement( objectArray, i, sxn_environ->env->NewStringUTF(query));
249 249
	     i++;	
250 250
	   }
251 251
	   if(infilename!= NULL) {
252
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("s") );
253
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(infilename));
252
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF("s") );
253
     	     sxn_environ->env->SetObjectArrayElement( objectArray, i, sxn_environ->env->NewStringUTF(infilename));
254 254
	     i++;	
255 255
	   }
256 256
	   for(map<std::string, XdmValue* >::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter, i++) {
257
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str() ) );
258
		bool checkCast = environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
257
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF( (iter->first).c_str() ) );
258
		bool checkCast = sxn_environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(sxn_environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
259 259
		if(( (bool)checkCast)==false ){
260 260
			failure = "FAILURE in  array of XdmValueForCpp";
261 261
		} 
262
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
262
	     sxn_environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
263 263
	   }
264 264
  	   for(map<std::string, std::string >::iterator iter=properties.begin(); iter!=properties.end(); ++iter, i++) {
265
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str()  ));
266
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)(environ->env->NewStringUTF((iter->second).c_str())) );
265
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF( (iter->first).c_str()  ));
266
	     sxn_environ->env->SetObjectArrayElement( objectArray, i, (jobject)(sxn_environ->env->NewStringUTF((iter->second).c_str())) );
267 267
	   }
268 268
	}
269 269

  
270
	  jobject result = (jobject)(environ->env->CallObjectMethod(cppXQ, mID, environ->env->NewStringUTF(cwdXQ.c_str()), stringArray, objectArray ));
271
	  environ->env->DeleteLocalRef(objectArray);
272
	  environ->env->DeleteLocalRef(stringArray);
270
	  jobject result = (jobject)(sxn_environ->env->CallObjectMethod(cppXQ, mID, sxn_environ->env->NewStringUTF(cwdXQ.c_str()), stringArray, objectArray ));
271
	  sxn_environ->env->DeleteLocalRef(objectArray);
272
	  sxn_environ->env->DeleteLocalRef(stringArray);
273 273
    if(result) {
274
		jclass atomicValueClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
275
		jclass nodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmNode");
276
		jclass functionItemClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
274
		jclass atomicValueClass = lookForClass(sxn_environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
275
		jclass nodeClass = lookForClass(sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
276
		jclass functionItemClass = lookForClass(sxn_environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
277 277
		XdmValue * xdmValue = NULL;
278
		if(environ->env->IsInstanceOf(result, atomicValueClass)           == JNI_TRUE) {
278
		if(sxn_environ->env->IsInstanceOf(result, atomicValueClass)           == JNI_TRUE) {
279 279
				xdmValue = new XdmAtomicValue(result);
280 280
				
281 281

  
282
			} else if(environ->env->IsInstanceOf(result, nodeClass)           == JNI_TRUE) {
282
			} else if(sxn_environ->env->IsInstanceOf(result, nodeClass)           == JNI_TRUE) {
283 283
				xdmValue = new XdmNode(result);
284 284

  
285
			} else if (environ->env->IsInstanceOf(result, functionItemClass)           == JNI_TRUE) {
285
			} else if (sxn_environ->env->IsInstanceOf(result, functionItemClass)           == JNI_TRUE) {
286 286
				return NULL;
287 287
			} else {
288 288
				xdmValue = new XdmValue(result);
......
294 294
			if(proc->exception != NULL) {
295 295
				delete proc->exception;
296 296
			}
297
			proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
297
			proc->exception = proc->checkForExceptionCPP(sxn_environ->env, cppClass, NULL);
298 298
			proc->exceptionClear();
299 299
	   		
300 300
     		} 
......
305 305

  
306 306
    const char * XQueryProcessor::executeQueryToString(const char * infilename, const char * query){
307 307
	setProperty("resources", proc->getResourcesDirectory()); 
308
 jmethodID mID = (jmethodID)environ->env->GetMethodID (cppClass,"executeQueryToString", "(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");
308
 jmethodID mID = (jmethodID)sxn_environ->env->GetMethodID (cppClass,"executeQueryToString", "(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");
309 309
 if (!mID) {
310 310
        cout<<"Error: MyClassInDll."<<"executeQueryToString"<<" not found\n"<<endl;
311 311
    } else {
......
317 317
	if(infilename!= NULL) size++;
318 318
	if(size >0) {
319 319
	   int i=0;
320
           jclass objectClass = lookForClass(environ->env, "java/lang/Object");
321
	   jclass stringClass = lookForClass(environ->env, "java/lang/String");
322
	   objectArray = environ->env->NewObjectArray( (jint)size, objectClass, 0 );
323
	   stringArray = environ->env->NewObjectArray( (jint)size, stringClass, 0 );
320
           jclass objectClass = lookForClass(sxn_environ->env, "java/lang/Object");
321
	   jclass stringClass = lookForClass(sxn_environ->env, "java/lang/String");
322
	   objectArray = sxn_environ->env->NewObjectArray( (jint)size, objectClass, 0 );
323
	   stringArray = sxn_environ->env->NewObjectArray( (jint)size, stringClass, 0 );
324 324

  
325 325
	   if(query!= NULL) {
326
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("qs") );
327
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(query));
326
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF("qs") );
327
     	     sxn_environ->env->SetObjectArrayElement( objectArray, i, sxn_environ->env->NewStringUTF(query));
328 328
	     i++;	
329 329
	   }
330 330
	   if(infilename!= NULL) {
331
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("s") );
332
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(infilename));
331
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF("s") );
332
     	     sxn_environ->env->SetObjectArrayElement( objectArray, i, sxn_environ->env->NewStringUTF(infilename));
333 333
	     i++;	
334 334
	   }
335 335
	   for(map<std::string, XdmValue* >::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter, i++) {
336
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str() ) );
337
		bool checkCast = environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
336
	     sxn_environ->env->SetObjectArrayElement( stringArray, i, sxn_environ->env->NewStringUTF( (iter->first).c_str() ) );
337
		bool checkCast = sxn_environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(sxn_environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
338 338
		if(( (bool)checkCast)==false ){
339 339
			failure = "FAILURE in  array of XdmValueForCpp";
340 340
		} 
341
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
341
	     sxn_environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
342 342
	   }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff