Project

Profile

Help

Revision 08626590

Added by O'Neil Delpratt 5 months ago

Saxon/C PHP development - refactor XsltExecutable and Xslt30Processor in separate files

View differences:

src/main/c/Saxon.C.API/PHP7-Build/php7_XsltExecutable.cpp
50 50
    xsltExecutable_object *obj = (xsltExecutable_object *)((char *)pobj - XtOffsetOf(xsltExecutable_object, std));
51 51

  
52 52
    XsltExecutable * xsltExecutable= obj->xsltExecutable;
53
    if(XsltExecutable != nullptr){
53
    if(xsltExecutable != nullptr){
54 54
    	delete xsltExecutable;
55 55
     }
56 56
}
......
81 81

  
82 82
PHP_METHOD(XsltExecutable, callFunctionReturningValue)
83 83
{
84
//arguments: const char * stylesheetFilename, const char* functionName, XdmValue * arguments, int argument_length
84
//arguments: const char* functionName, XdmValue * arguments, int argument_length
85 85

  
86 86
    XsltExecutable *xsltExecutable;
87 87
    HashTable *arr_hash;
88
    char* functionName;
88
    char* functionName = nullptr;
89 89
    zval * arguments_zval;
90 90
    zval * val;
91 91
    long num_key;
......
93 93
    int argument_length=0;
94 94
    zend_string *key;
95 95

  
96
    char * infilename;
97
    char * styleFileName = nullptr;
98
    size_t len1, len2;
96
    size_t len1;
99 97

  
100
    if (ZEND_NUM_ARGS()==2 && zend_parse_parameters(ZEND_NUM_ARGS() , "sa", &functionName, &len2, &arguments_zval) == FAILURE) {
98
    if (ZEND_NUM_ARGS()>2) {
99
        WRONG_PARAM_COUNT;
100
    }
101

  
102
    if (ZEND_NUM_ARGS()==1 && zend_parse_parameters(ZEND_NUM_ARGS() , "s", &functionName, &len1, &arguments_zval) == FAILURE) {
101 103
        RETURN_NULL();
102
    } else if (ZEND_NUM_ARGS()==3 && zend_parse_parameters(ZEND_NUM_ARGS() , "ssa", &styleFileName, &len1, &functionName, &len2, &arguments_zval) == FAILURE) {
104
    } else if (ZEND_NUM_ARGS()==2 && zend_parse_parameters(ZEND_NUM_ARGS() , "sa", &functionName, &len1, &arguments_zval) == FAILURE) {
103 105
        RETURN_NULL();
104 106
    }
105 107

  
......
108 110
    xsltExecutable = obj->xsltExecutable;
109 111
    arr_hash = Z_ARRVAL_P(arguments_zval);
110 112
    argument_length = zend_hash_num_elements(arr_hash);
111
   
113

  
112 114
    arguments = new XdmValue*[argument_length];
113
      
115

  
114 116
    if (xsltExecutable != nullptr) {
115 117
      ZEND_HASH_FOREACH_KEY_VAL(arr_hash, num_key, key, val) {
116 118
        if(Z_TYPE_P(val) != nullptr) {
117
	const char * objName =ZSTR_VAL(Z_OBJCE_P(val)->name);
118
      /*std::cerr<<"test type:"<<(Z_OBJCE_P(val)->name)<<std::endl;
119
	php_printf("num_key %d =>", num_key);
120
	php_printf("key %d =>", key);
121
	*/
122
	if(strcmp(objName, "Saxon\\XdmNode")==0) {
123
		zend_object* ooth = Z_OBJ_P(val);
124
		xdmNode_object * nobj = (xdmNode_object *)((char *)ooth - XtOffsetOf(xdmNode_object, std));
119
	        const char * objName =ZSTR_VAL(Z_OBJCE_P(val)->name);
120

  
121
        if(strcmp(objName, "Saxon\\XdmNode")==0) {
122
		    zend_object* ooth = Z_OBJ_P(val);
123
		    xdmNode_object * nobj = (xdmNode_object *)((char *)ooth - XtOffsetOf(xdmNode_object, std));
125 124
        	if(nobj != nullptr) {
126 125
            		XdmValue * value = (XdmValue *) nobj->xdmNode;
127 126
            		arguments[num_key] = value;
128 127
        	}
129
	}
130
	else if(strcmp(objName, "Saxon\\XdmAtomicValue")==0) {
131
		zend_object* ooth = Z_OBJ_P(val);
132
		xdmAtomicValue_object * nobj = (xdmAtomicValue_object *)((char *)ooth - XtOffsetOf(xdmAtomicValue_object, std));
128
	    } else if(strcmp(objName, "Saxon\\XdmAtomicValue")==0) {
129
		    zend_object* ooth = Z_OBJ_P(val);
130
		    xdmAtomicValue_object * nobj = (xdmAtomicValue_object *)((char *)ooth - XtOffsetOf(xdmAtomicValue_object, std));
133 131
        	if(nobj != nullptr) {
134
            		XdmValue * value = (XdmValue *) nobj->xdmAtomicValue;
135
            		arguments[num_key] = value;
132
        	    XdmValue * value = (XdmValue *) nobj->xdmAtomicValue;
133
        	    arguments[num_key] = value;
136 134
        	}
137
	}
138
	else if(strcmp(objName, "Saxon\\XdmValue")==0) {
135
	    } else if(strcmp(objName, "Saxon\\XdmValue")==0) {
139 136
		zend_object* ooth = Z_OBJ_P(val);
140 137
		xdmValue_object * nobj = (xdmValue_object *)((char *)ooth - XtOffsetOf(xdmValue_object, std));
141 138
        	if(nobj != nullptr) {
......
151 148

  
152 149

  
153 150
	//php_printf(" argument_length= %d",argument_length);
154
        XdmValue * result = xsltExecutable->callFunctionReturningValue(styleFileName, functionName, arguments, argument_length);
151
        XdmValue * result = xsltExecutable->callFunctionReturningValue(functionName, arguments, argument_length);
155 152
	if(result != nullptr) {
156 153
            if (object_init_ex(return_value, xdmValue_ce) != SUCCESS) {
157 154
                RETURN_NULL();
......
164 161
            }
165 162
        } else {
166 163
            if(obj->xsltExecutable->exceptionOccurred()){
167
  		//TODO
164
  		//TODO - create PHP exception
168 165
	    }
169 166
	    RETURN_NULL();
170 167
        }
......
184 181
    int argument_length=0;
185 182
    zend_string *key;
186 183

  
187
    char * infilename;
188
    char * styleFileName = nullptr;
189
    size_t len1, len2;
184
    size_t len1;
185

  
186

  
187
     if (ZEND_NUM_ARGS()>2) {
188
        WRONG_PARAM_COUNT;
189
    }
190 190

  
191
     if (ZEND_NUM_ARGS()==2 && zend_parse_parameters(ZEND_NUM_ARGS() , "sa", &functionName, &len2, &arguments_zval) == FAILURE) {
191
     if (ZEND_NUM_ARGS()==1 && zend_parse_parameters(ZEND_NUM_ARGS() , "s", &functionName, &len1, &arguments_zval) == FAILURE) {
192 192
        RETURN_NULL();
193
      }else if (ZEND_NUM_ARGS()==3 && zend_parse_parameters(ZEND_NUM_ARGS() , "ssa", &styleFileName, &len1, &functionName, &len2, &arguments_zval) == FAILURE) {
193
      }else if (ZEND_NUM_ARGS()==2 && zend_parse_parameters(ZEND_NUM_ARGS() , "sa", &functionName, &len1, &arguments_zval) == FAILURE) {
194 194
        RETURN_NULL();
195 195
    }
196 196

  
......
199 199
    xsltExecutable = obj->xsltExecutable;
200 200
    arr_hash = Z_ARRVAL_P(arguments_zval);
201 201
    argument_length = zend_hash_num_elements(arr_hash);
202
   
202

  
203 203
    arguments = new XdmValue*[argument_length];
204
      
204

  
205 205
    if (xsltExecutable != nullptr) {
206 206
      ZEND_HASH_FOREACH_KEY_VAL(arr_hash, num_key, key, val) {
207 207
        if(Z_TYPE_P(val) != nullptr) {
......
240 240
        }
241 241
      } ZEND_HASH_FOREACH_END();
242 242

  
243
        const char * result = xsltExecutable->callFunctionReturningString(styleFileName, functionName, arguments, argument_length);
243
        const char * result = xsltExecutable->callFunctionReturningString(functionName, arguments, argument_length);
244 244
	if(result != nullptr) {
245 245
            //char *str = estrdup(result);
246 246
            _RETURN_STRING(result);
247 247
        } else if(xsltExecutable->exceptionOccurred()){
248
            //TODO: xsltExecutable->checkException();
249
            const char * errStr = xsltExecutable->getErrorMessage();
250
            if(errStr != nullptr) {
251
                const char * errorCode = xsltExecutable->getErrorCode();
252
                if(errorCode!=nullptr) {
253
                    // TODO: throw exception
254
                }
255
            }
248
            //TODO: xsltExecutable->getException() then build PHP exception
249

  
256 250
        }
257 251
    }
258 252

  
......
273 267
    zend_string *key;
274 268

  
275 269
    char * outfilename;
276
    char * styleFileName = nullptr;
277 270
    size_t len1, len2, len3;
278 271

  
279 272

  
280 273
    if (ZEND_NUM_ARGS()==3 && zend_parse_parameters(ZEND_NUM_ARGS() , "sas", &functionName, &len2, &arguments_zval, &outfilename, &len3) == FAILURE) {
281 274
        RETURN_NULL();
282
    } else if (ZEND_NUM_ARGS()==4 && zend_parse_parameters(ZEND_NUM_ARGS() , "ssas", &styleFileName, &len1, &functionName, &len2, &arguments_zval, &outfilename, &len3) == FAILURE) {
283
        RETURN_NULL();
284 275
    }
285 276

  
286 277
    zend_object* pobj = Z_OBJ_P(getThis());
......
288 279
    xsltExecutable = obj->xsltExecutable;
289 280
    arr_hash = Z_ARRVAL_P(arguments_zval);
290 281
    argument_length = zend_hash_num_elements(arr_hash);
291
   
282

  
292 283
    arguments = new XdmValue*[argument_length];
293
      
284

  
294 285
    if (xsltExecutable != nullptr) {
295 286
      ZEND_HASH_FOREACH_KEY_VAL(arr_hash, num_key, key, val) {
296 287
        if(Z_TYPE_P(val) != nullptr) {
......
330 321
      } ZEND_HASH_FOREACH_END();
331 322

  
332 323

  
333
        xsltExecutable->callFunctionReturningFile(styleFileName, functionName, arguments, argument_length, outfilename);
324
        xsltExecutable->callFunctionReturningFile(functionName, arguments, argument_length, outfilename);
334 325
	if(xsltExecutable->exceptionOccurred()){
335
            //TODO: xsltExecutable->checkException();
336
            const char * errStr = xsltExecutable->getErrorMessage();
337
            if(errStr != nullptr) {
338
                const char * errorCode = xsltExecutable->getErrorCode();
339
            }
326
//TODO: xsltExecutable->getException() then build PHP exception
340 327
        }
341 328
    }
342 329

  
......
346 333

  
347 334
  XsltExecutable *xsltExecutable;
348 335
    char* templateName = nullptr;
349
   
350
    char * styleFileName = nullptr;
351
    size_t len1, len2;
352 336

  
337
    size_t len1, len2;
353 338

  
339
    if (ZEND_NUM_ARGS()>1) {
340
        WRONG_PARAM_COUNT;
341
    }
354 342
    if (ZEND_NUM_ARGS()==1 && zend_parse_parameters(ZEND_NUM_ARGS() , "s", &templateName, &len2) == FAILURE) {
355 343
        RETURN_NULL();
356
    } else if (ZEND_NUM_ARGS()>1 && zend_parse_parameters(ZEND_NUM_ARGS() , "ss", &styleFileName, &len1, &templateName, &len2) == FAILURE) {
357
        RETURN_NULL();
358 344
    }
359 345

  
360 346

  
361 347
    zend_object* pobj = Z_OBJ_P(getThis());
362 348
    xsltExecutable_object *obj = (xsltExecutable_object *)((char *)pobj - XtOffsetOf(xsltExecutable_object, std));
363 349
    xsltExecutable = obj->xsltExecutable;
364
      
350

  
365 351
    if (xsltExecutable != nullptr) {
366
   
352

  
367 353

  
368 354
	//php_printf(" argument_length= %d",argument_length);
369
        XdmValue * result = xsltExecutable->callTemplateReturningValue(styleFileName, templateName);
355
        XdmValue * result = xsltExecutable->callTemplateReturningValue(templateName);
370 356
	if(result != nullptr) {
371
 
372
            if (object_init_ex(return_value, xdmValue_ce) != SUCCESS) { 
357

  
358
            if (object_init_ex(return_value, xdmValue_ce) != SUCCESS) {
373 359
               RETURN_NULL();
374 360
            } else {
375 361
		zend_object *ooth =  Z_OBJ_P(return_value);
376
              
362

  
377 363
		xdmValue_object* vobj  = (xdmValue_object *)((char *)ooth - XtOffsetOf(xdmValue_object, std));
378 364
                assert (vobj != nullptr);
379 365
                vobj->xdmValue = result;
380
		
366

  
381 367
            }
382 368
        } else {
383 369
            if(obj->xsltExecutable->exceptionOccurred()){
......
392 378
    PHP_METHOD(XsltExecutable, callTemplateReturningString){
393 379
    XsltExecutable *xsltExecutable;
394 380
    char* templateName = nullptr;
395
   
396
    char * styleFileName = nullptr;
381

  
397 382
    size_t len1, len2;
398 383

  
399
    if (ZEND_NUM_ARGS()==1 && zend_parse_parameters(ZEND_NUM_ARGS() , "s", &templateName, &len2) == FAILURE) {
400
        RETURN_NULL();
384
    if (ZEND_NUM_ARGS()>1) {
385
        WRONG_PARAM_COUNT;
401 386
    }
402 387

  
403
    if (ZEND_NUM_ARGS()>1 && zend_parse_parameters(ZEND_NUM_ARGS() , "ss", &styleFileName, &len1, &templateName, &len2) == FAILURE) {
388
    if (ZEND_NUM_ARGS()==1 && zend_parse_parameters(ZEND_NUM_ARGS() , "s", &templateName, &len2) == FAILURE) {
404 389
        RETURN_NULL();
405 390
    }
406 391

  
392

  
407 393
    zend_object* pobj = Z_OBJ_P(getThis());
408 394
    xsltExecutable_object *obj = (xsltExecutable_object *)((char *)pobj - XtOffsetOf(xsltExecutable_object, std));
409 395
    xsltExecutable = obj->xsltExecutable;
410
      
396

  
411 397
    if (xsltExecutable != nullptr) {
412
   
398

  
413 399

  
414 400
	//php_printf(" argument_length= %d",argument_length);
415
        const char * result = xsltExecutable->callTemplateReturningString(styleFileName, templateName);
401
        const char * result = xsltExecutable->callTemplateReturningString(templateName);
416 402
	if(result != nullptr) {
417
            _RETURN_STRING(result); 
403
            _RETURN_STRING(result);
418 404
        } else {
419 405
            if(xsltExecutable->exceptionOccurred()){
420
            xsltExecutable->checkException();
421
            const char * errStr = xsltExecutable->getErrorMessage();
422
            if(errStr != nullptr) {
423
                const char * errorCode = xsltExecutable->getErrorCode();
424
                if(errorCode!=nullptr) {
425
                    // TODO: throw exception
426
                }
427
            }
406
//TODO: xsltExecutable->getException() then build PHP exception
428 407
           }
429 408
        }
430 409
    }
......
436 415
   XsltExecutable *xsltExecutable;
437 416
    char* templateName = nullptr;
438 417
    char * filename = nullptr;
439
    char * styleFileName = nullptr;
440
    size_t len1, len2, len3;
418
    size_t len2;
441 419

  
442
    if (ZEND_NUM_ARGS()==1 && zend_parse_parameters(ZEND_NUM_ARGS() , "s", &templateName, &len2) == FAILURE) {
443
        RETURN_NULL();
420
    if (ZEND_NUM_ARGS()>1 {
421
        WRONG_PARAM_COUNT;
444 422
    }
445

  
446
    if (ZEND_NUM_ARGS()>1 && zend_parse_parameters(ZEND_NUM_ARGS() , "ss", &styleFileName, &len1, &templateName, &len2) == FAILURE) {
423
    if (zend_parse_parameters(ZEND_NUM_ARGS() , "s", &templateName, &len2) == FAILURE) {
447 424
        RETURN_NULL();
448 425
    }
449 426

  
427

  
450 428
    zend_object* pobj = Z_OBJ_P(getThis());
451 429
    xsltExecutable_object *obj = (xsltExecutable_object *)((char *)pobj - XtOffsetOf(xsltExecutable_object, std));
452 430
    xsltExecutable = obj->xsltExecutable;
453
      
431

  
454 432
    if (xsltExecutable != nullptr) {
455
   	xsltExecutable->callTemplateReturningFile(styleFileName, templateName, filename);
433
   	xsltExecutable->callTemplateReturningFile(templateName, filename);
456 434
    }
457 435

  
458 436
  }
......
460 438

  
461 439
PHP_METHOD(XsltExecutable, applyTemplatesReturningValue){
462 440
   XsltExecutable *xsltExecutable;
463
    char * styleFileName = nullptr;
464 441
    size_t len1;
465 442

  
466 443
    if (ZEND_NUM_ARGS()>0) {
467

  
468
      if (zend_parse_parameters(ZEND_NUM_ARGS() , "s", &styleFileName, &len1) == FAILURE) {
469
          RETURN_NULL();
470
      }
444
        WRONG_PARAM_COUNT;
471 445
    }
472 446

  
473 447
    zend_object* pobj = Z_OBJ_P(getThis());
474 448
    xsltExecutable_object *obj = (xsltExecutable_object *)((char *)pobj - XtOffsetOf(xsltExecutable_object, std));
475 449
    xsltExecutable = obj->xsltExecutable;
476
      
450

  
477 451
    if (xsltExecutable != nullptr) {
478
   	XdmValue * result = xsltExecutable->applyTemplatesReturningValue(styleFileName);
479
    
452
   	XdmValue * result = xsltExecutable->applyTemplatesReturningValue();
453

  
480 454
	if(result != nullptr) {
481 455
            if (object_init_ex(return_value, xdmValue_ce) != SUCCESS) {
482 456
                RETURN_NULL();
......
502 476

  
503 477

  
504 478
PHP_METHOD(XsltExecutable, applyTemplatesReturningString){
505
 XsltExecutable *xsltExecutable;
506

  
507
    char * styleFileName = nullptr;
479
    XsltExecutable *xsltExecutable;
508 480
    size_t len1;
509 481

  
510

  
511 482
    if (ZEND_NUM_ARGS()>0) {
512
    
513
    	if (zend_parse_parameters(ZEND_NUM_ARGS() , "s", &styleFileName, &len1) == FAILURE) {
514
    	    RETURN_NULL();
515
    	}
483
        WRONG_PARAM_COUNT;
516 484
    }
517 485

  
518 486
    zend_object* pobj = Z_OBJ_P(getThis());
519 487
    xsltExecutable_object *obj = (xsltExecutable_object *)((char *)pobj - XtOffsetOf(xsltExecutable_object, std));
520 488
    xsltExecutable = obj->xsltExecutable;
521
      
489

  
522 490
    if (xsltExecutable != nullptr) {
523
        const char * result = xsltExecutable->applyTemplatesReturningString(styleFileName);
524
   
491
        const char * result = xsltExecutable->applyTemplatesReturningString();
492

  
525 493
	if(result != nullptr) {
526
            _RETURN_STRING(result); 
494
            _RETURN_STRING(result);
527 495
        } else {
528 496
            if(xsltExecutable->exceptionOccurred()){
529
            xsltExecutable->checkException();
530
            const char * errStr = xsltExecutable->getErrorMessage();
531
            if(errStr != nullptr) {
532
                const char * errorCode = xsltExecutable->getErrorCode();
533
                if(errorCode!=nullptr) {
534
                    // TODO: throw exception
535
                }
536
            }
497
//TODO: xsltExecutable->getException() then build PHP exception
537 498
           }
538 499
        }
539 500
    }
540 501

  
541 502
     RETURN_NULL();
542
   
503

  
543 504

  
544 505

  
545 506
}
......
549 510
PHP_METHOD(XsltExecutable, applyTemplatesReturningFile){
550 511
 XsltExecutable *xsltExecutable;
551 512
    char * filename = nullptr;
552
    char * styleFileName = nullptr;
553
    size_t len1, len2;
513
    size_t len1;
554 514

  
555
    if (ZEND_NUM_ARGS()==2 && zend_parse_parameters(ZEND_NUM_ARGS() , "ss", &styleFileName, &len1, &filename, &len2) == FAILURE) {
556
          RETURN_NULL();
557
    }
515
    if (ZEND_NUM_ARGS() == 1) {
558 516

  
559
   if (ZEND_NUM_ARGS()==1 && zend_parse_parameters(ZEND_NUM_ARGS() , "s", &filename, &len2) == FAILURE) {
560
          RETURN_NULL();
517
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &len1) == FAILURE) {
518
            RETURN_NULL();
519
        } else {
520
            WRONG_PARAM_COUNT;
521
        }
561 522
    }
562
    
523

  
563 524

  
564 525
    zend_object* pobj = Z_OBJ_P(getThis());
565 526
    xsltExecutable_object *obj = (xsltExecutable_object *)((char *)pobj - XtOffsetOf(xsltExecutable_object, std));
566 527
    xsltExecutable = obj->xsltExecutable;
567
      
528

  
568 529
    if (xsltExecutable != nullptr) {
569
   	xsltExecutable->applyTemplatesReturningFile(styleFileName, filename);
530
   	    xsltExecutable->applyTemplatesReturningFile(filename);
570 531
    }
532
    //TODO check for exception
571 533

  
572 534

  
573 535

  
......
586 548
    zend_string *key;
587 549

  
588 550
    char * infilename = nullptr;
589
    char * styleFileName = nullptr;
590
    size_t len1, len2;
551

  
552
    size_t len1;
591 553

  
592 554
        if (zend_parse_parameters(ZEND_NUM_ARGS() , "a", &arguments_zval) == FAILURE) {
593 555
        RETURN_NULL();
......
612 574

  
613 575
        xsltExecutable->addPackages(arguments, argument_length);
614 576
	if(xsltExecutable->exceptionOccurred()){
615
            //TODO: xsltExecutable->checkException();
616
            const char * errStr = xsltExecutable->getErrorMessage(0);
617
            if(errStr != nullptr) {
618
                const char * errorCode = xsltExecutable->getErrorCode(0);
619
            }
577
//TODO: xsltExecutable->getException() then build PHP exception
620 578
        }
621 579
    }
622 580
}    */
......
648 606
    xsltExecutable = obj->xsltExecutable;
649 607
    arr_hash = Z_ARRVAL_P(arguments_zval);
650 608
    argument_length = zend_hash_num_elements(arr_hash);
651
   
609

  
652 610
    arguments = new XdmValue*[argument_length];
653 611
    std::map<std::string,XdmValue*> parameters;
654 612
    if (xsltExecutable != nullptr) {
......
692 650

  
693 651
	//php_printf(" argument_length= %d",argument_length);
694 652
        xsltExecutable->setInitialTemplateParameters(parameters, tunnel);
695
	
653

  
696 654
    }
697 655

  
698 656
    }
......
723 681
      const char * objName =ZSTR_VAL(Z_OBJCE_P(oth)->name);
724 682
      //std::cout<<"test type:"<<(Z_OBJCE_P(oth)->name)<<std::endl;
725 683

  
726
      
684

  
727 685
      if(strcmp(objName, "Saxon\\XdmValue")==0) {
728 686
	zend_object * nobj = Z_OBJ_P(oth);
729 687

  
......
772 730

  
773 731

  
774 732
}
775
    
733

  
776 734

  
777 735
PHP_METHOD(XsltExecutable, setGlobalContextItem)
778 736
{
......
876 834
    XsltExecutable *xsltExecutable;
877 835
    char * outfileName = nullptr;
878 836
    char * infilename = nullptr;
879
    char * styleFileName = nullptr;
880
    size_t len1, len2, len3;
837
    size_t len1;
881 838

  
882
    if (zend_parse_parameters(ZEND_NUM_ARGS() , "sss", &infilename, &len1, &styleFileName, &len2, &outfileName, &len3) == FAILURE) {
839
    if (zend_parse_parameters(ZEND_NUM_ARGS() , "ss", &infilename, &len1, &outfileName, &len2) == FAILURE) {
883 840
        RETURN_NULL();
884 841
    }
885 842

  
......
889 846

  
890 847
    if (xsltExecutable != nullptr) {
891 848

  
892
        xsltExecutable->transformFileToFile(infilename, styleFileName, outfileName);
849
        xsltExecutable->transformFileToFile(infilename, outfileName);
893 850
        if(xsltExecutable->exceptionOccurred()) {
894 851
     	  // TODO: throw exception
895 852
        }
......
900 857
{
901 858
    XsltExecutable *xsltExecutable;
902 859
    char * infilename = nullptr;
903
    char * styleFileName = nullptr;
904
   size_t len1, len2;
860
   size_t len1;
905 861

  
906
    if (zend_parse_parameters(ZEND_NUM_ARGS() , "ss", &infilename, &len1, &styleFileName, &len2) == FAILURE) {
862
    if (zend_parse_parameters(ZEND_NUM_ARGS() , "s", &infilename, &len1) == FAILURE) {
907 863
        RETURN_NULL();
908 864
    }
909 865

  
......
913 869

  
914 870
    if (xsltExecutable != nullptr) {
915 871

  
916
        XdmValue * node = xsltExecutable->transformFileToValue(infilename, styleFileName);
872
        XdmValue * node = xsltExecutable->transformFileToValue(infilename);
917 873
        if(node != nullptr) {
918 874
            if (object_init_ex(return_value, xdmValue_ce) != SUCCESS) {
919 875
                RETURN_NULL();
......
939 895
{
940 896
    XsltExecutable *xsltExecutable;
941 897
    char * infilename = nullptr;
942
    char * styleFileName = nullptr;
943
    size_t len1, len2;
898
    size_t len1;
944 899

  
945
    if (zend_parse_parameters(ZEND_NUM_ARGS() , "ss", &infilename, &len1, &styleFileName, &len2) == FAILURE) {
900
    if (zend_parse_parameters(ZEND_NUM_ARGS() , "s", &infilename, &len1) == FAILURE) {
946 901
        RETURN_NULL();
947 902
    }
948 903

  
......
952 907

  
953 908
    if (xsltExecutable != nullptr) {
954 909

  
955
        const char * result = xsltExecutable->transformFileToString(infilename, styleFileName);
910
        const char * result = xsltExecutable->transformFileToString(infilename);
956 911
	if(result != nullptr) {
957 912
            //char *str = estrdup(result);
958 913
            _RETURN_STRING(result);
959 914
        } else if(xsltExecutable->exceptionOccurred()){
960
            //TODO: xsltExecutable->checkException();
961
            const char * errStr = xsltExecutable->getErrorMessage();
962
            if(errStr != nullptr) {
963
                const char * errorCode = xsltExecutable->getErrorCode();
964
                if(errorCode!=nullptr) {
965
                    // TODO: throw exception
966
                }
967
            }
915
//TODO: xsltExecutable->getException() then build PHP exception
968 916
        }
969 917
    }
970 918
}
......
981 929

  
982 930

  
983 931
    zval* oth;
984
   
932

  
985 933

  
986 934
    if (ZEND_NUM_ARGS() == 1 && zend_parse_parameters(ZEND_NUM_ARGS() , "z", &oth) == FAILURE) {
987 935
        RETURN_NULL();
......
1046 994

  
1047 995

  
1048 996
    zval* oth;
1049
   
997

  
1050 998

  
1051 999
    if (ZEND_NUM_ARGS() == 1 && zend_parse_parameters(ZEND_NUM_ARGS() , "z", &oth) == FAILURE) {
1052 1000
        RETURN_NULL();
......
1117 1065

  
1118 1066

  
1119 1067
    zval* oth;
1120
   
1068

  
1121 1069

  
1122 1070
    if (ZEND_NUM_ARGS() == 1 && zend_parse_parameters(ZEND_NUM_ARGS() , "z", &oth) == FAILURE) {
1123 1071
        RETURN_NULL();
......
1135 1083
        if(ZEND_NUM_ARGS() == 0) {
1136 1084
            xsltExecutable->transformToFile();
1137 1085
        } else {
1138
            if(Z_TYPE_P(oth) == mIS_NULL){
1086
            if(Z_TYPE_P(oth) == IS_NULL){
1139 1087
                php_error(E_WARNING,"Error setting source value");
1140 1088
                return;
1141 1089
            }
......
1370 1318
    xsltExecutable_object *obj = (xsltExecutable_object *)((char *)pobj - XtOffsetOf(xsltExecutable_object, std));
1371 1319
    xsltExecutable = obj->xsltExecutable;
1372 1320
    if (xsltExecutable != nullptr) {
1373
        const char * errCode = xsltExecutable->getErrorCode();
1321
        SaxonApiException * exception = xsltExecutable->getException();
1322
        const char * errCode = exception->getErrorCode();
1374 1323
        if(errCode != nullptr) {
1375 1324
            //char *str = estrdup(errCode);
1376 1325
            _RETURN_STRING(errCode);
......
1382 1331
PHP_METHOD(XsltExecutable, getErrorMessage)
1383 1332
{
1384 1333
    XsltExecutable *xsltExecutable;
1385
    long index;
1386
    if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) {
1387
        RETURN_NULL();
1334
    if (ZEND_NUM_ARGS()>0) {
1335
        WRONG_PARAM_COUNT;
1388 1336
    }
1389 1337
    zend_object* pobj = Z_OBJ_P(getThis());
1390 1338
    xsltExecutable_object *obj = (xsltExecutable_object *)((char *)pobj - XtOffsetOf(xsltExecutable_object, std));
1391 1339
    xsltExecutable = obj->xsltExecutable;
1392 1340
    if (xsltExecutable != nullptr) {
1393
        const char * errStr = xsltExecutable->getErrorMessage((int)index);
1341
        SaxonApiException * exception = xsltExecutable->getException();
1342
        const char * errStr = exception->getMessage();
1394 1343
        if(errStr != nullptr) {
1395 1344
            //char *str = estrdup(errStr);
1396 1345
            _RETURN_STRING(errStr);
1346
            //TODO free exception variable?
1397 1347
        }
1398 1348
    }
1399 1349
    RETURN_NULL();

Also available in: Unified diff