Project

Profile

Help

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

he / latest9.9 / hec / samples / cppTests / testXSLT30.cpp @ 5401a5ae

1
#include <sstream>
2
#include <stdio.h>
3
#include "../../Saxon.C.API/SaxonProcessor.h"
4
#include "../../Saxon.C.API/XdmValue.h"
5
#include "../../Saxon.C.API/XdmItem.h"
6
#include "../../Saxon.C.API/XdmNode.h"
7
#include "cppExtensionFunction.cpp"
8
#include "cppTestUnits.h"
9
#include <string>
10

    
11
// TODO: write test case for checking parameters which are null
12

    
13

    
14
using namespace std;
15
char fname[] = "_nativeCall";
16
char funcParameters[] = "(Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;)Ljava/lang/Object;";
17

    
18
JNINativeMethod cppMethods[] =
19
{
20
    {
21
         fname,
22
         funcParameters,
23
         (void *)&cppNativeCall
24
    }
25
};
26

    
27

    
28
/*
29
* Test transform to String. Source and stylesheet supplied as arguments
30
*/
31
void testApplyTemplatesString1(Xslt30Processor * trans, sResultCount *sresult){
32
        
33
  cout<<endl<<"Test: TransformToString1:"<<endl;
34
   trans->setInitialMatchSelectionAsFile("cat.xml");
35
    const char * output = trans->applyTemplatesReturningString("test.xsl");
36
   if(output == NULL) {
37
      printf("result is null ====== FAIL ====== \n");
38
      sresult->failure++;
39
         fflush(stdout);
40
        delete output;
41
        sresult->failureList.push_back("testApplyTemplatesString1-0");
42
        return;
43
    }else if (string(output).find(string("<out>text2</out>")) != std::string::npos) {
44
      //printf("%s", output);
45
      printf("result is OK \n");
46
      sresult->success++;
47
    } else {
48
      printf("result is null ====== FAIL ====== \n");
49
      sresult->failure++;
50
      sresult->failureList.push_back("testApplyTemplatesString1-1");
51
//        std::cout<<"output="<<output<<std::endl;
52
        }
53
      fflush(stdout);
54
        delete output;
55

    
56
}
57

    
58
/*
59
* Test transform to String. Source and stylesheet supplied as arguments
60
*/
61
void testTransformToStringExtensionFunc(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
62
        
63
  cout<<endl<<"Test: TransformToStringExtensionFunc:"<<endl;
64
trans->setProperty("extc", "home/ond1/work/svn/latest9.9-saxonc/samples/cppTests/cppExtensionFunction");
65

    
66
bool nativeFound = processor->registerNativeMethods(SaxonProcessor::sxn_environ->env, "com/saxonica/functions/extfn/cpp/NativeCall",
67
    cppMethods, sizeof(cppMethods) / sizeof(cppMethods[0]));
68
if(nativeFound) {
69
    const char * output = trans->transformFileToString("cat.xml", "testExtension.xsl");
70
//XdmValue* output = trans->transformFileToValue("cat.xml", "testExtension.xsl");
71
   if(output == NULL) {
72
        SaxonProcessor::sxn_environ->env->ExceptionDescribe();
73
      printf("result is null ====== FAIL ======  \n");
74
     sresult->failureList.push_back("testTransformToStringExnteionFunc");
75
    }else {
76
      //printf("%s", output);
77
      printf("result is OK \n");
78
    }
79
      fflush(stdout);
80
        delete output;
81
} else{
82
    printf("native Class not foun ====== FAIL ====== ");
83
    sresult->failureList.push_back("testTransformToStringExtensionFunc");
84
}
85
}
86

    
87

    
88

    
89
/*
90
* Test transform to String. stylesheet supplied as argument. Source supplied as XdmNode
91
*/
92
void testApplyTemplatesString2(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
93

    
94
  cout<<endl<<"Test: TransformToString2:"<<endl;
95
  trans->clearParameters(true);
96
  trans->clearProperties();
97
    XdmNode * input = processor->parseXmlFromFile("cat.xml");
98

    
99
   if(input == NULL) {
100
        cout<<"Source document is null."<<endl;
101

    
102
    }
103

    
104
     trans->setInitialMatchSelection((XdmValue*)input);
105
    const char * output = trans->applyTemplatesReturningString("test.xsl");
106
   if(output == NULL) {
107
      printf("result is null ====== FAIL ======  \n");
108
        sresult->failureList.push_back("testApplyTemplatesString2");
109
    }else {
110
      printf("%s", output);
111
      printf("result is OK \n");
112
    }
113
      fflush(stdout);
114
    delete output;
115
}
116

    
117
/*
118
* Test transform to String. stylesheet supplied as argument. Source supplied as XdmNode
119
Should be error. Stylesheet file does not exist
120
*/
121
void testApplyTemplates2a(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
122

    
123
  cout<<endl<<"Test: TransformToString2a:"<<endl;
124
  trans->clearParameters(true);
125
  trans->clearProperties();
126
    XdmNode * input = processor->parseXmlFromFile("cat.xml");
127

    
128
   if(input == NULL) {
129
        cout<<"Source document is null. ====== FAIL ======"<<endl;
130
        sresult->failure++;
131
        sresult->failureList.push_back("testApplyTemplates2a");
132
        return;
133
    } else {
134

    
135
     trans->setInitialMatchSelection((XdmValue*)input);
136
    }  
137
  const char * output = trans->applyTemplatesReturningString("test-error.xsl");
138
   if(output == NULL) {
139
      printf("result is null \n");
140
      sresult->success++;
141
    }else {
142
      printf("%s", output);
143
      printf("result is OK - ======= FAIL ======= \n");
144
        sresult->failure++;
145
        sresult->failureList.push_back("testApplyTemplates2a");
146
    }
147
      fflush(stdout);
148
    delete output;
149
        
150
        
151

    
152
}
153

    
154
/*
155
* Test transform to String. stylesheet supplied as argument. Source supplied as XdmNode
156
Should be error. Source file does not exist
157
*/
158
void testTransformToString2b(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
159

    
160
  cout<<endl<<"Test: TransformToString2b:"<<endl;
161
  trans->clearParameters(true);
162
  trans->clearProperties();
163
    XdmNode * input = processor->parseXmlFromFile("cat-error.xml");
164

    
165
   if(input == NULL) {
166
        cout<<"Source document is null. ====== FAIL ====== "<<endl;
167
        sresult->failureList.push_back("testTransformToString2b");
168
        return;
169
    }
170

    
171
     trans->setInitialMatchSelection((XdmNode*)input);
172
    const char * output = trans->transformFileToString(NULL, "test-error.xsl");
173
   if(output == NULL) {
174
      printf("result is null ====== FAIL ======  \nCheck For errors:");
175
        sresult->failureList.push_back("testTransformToString2b");
176
      if(trans->exceptionCount()>0) {
177
        cout<<trans->getErrorMessage(0)<<endl;
178
      }        
179
    }else {
180
      printf("%s", output);
181
      printf("result is OK \n");
182
    }
183
      fflush(stdout);
184
    delete output;
185
        
186
    trans->exceptionClear();
187

    
188
}
189

    
190

    
191
/*
192
* Test transform to String. stylesheet supplied as argument. Source supplied as xml string
193
and integer parmater created and supplied
194
*/
195
void testTransformToString3(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
196

    
197
  cout<<endl<<"Test: TransformToString3:"<<endl;
198
  trans->clearParameters(true);
199
  trans->clearProperties();
200
    XdmNode * inputi = processor->parseXmlFromString("<out><person>text1</person><person>text2</person><person>text3</person></out>");
201

    
202
   XdmAtomicValue * value1 = processor->makeIntegerValue(10);
203

    
204
   trans->setParameter("numParam",(XdmValue *)value1);
205

    
206
   if(inputi == NULL) {
207
        cout<<"Source document inputi is null. ====== FAIL ====== "<<endl;
208
        sresult->failureList.push_back("testTransformToString3");
209
        return;
210
    }
211

    
212
    trans->setInitialMatchSelection((XdmNode*)inputi);
213
    const char * output = trans->applyTemplatesReturningString("test.xsl");
214
   if(output == NULL) {
215
      printf("result is null ====== FAIL ====== \n");
216
        sresult->failureList.push_back("testTransformToString3");
217
    }else {
218
      printf("%s", output);
219
      printf("result is OK \n");
220
    }
221
      fflush(stdout);
222
   delete output;
223

    
224
}
225

    
226
/*
227
* Test transform to String. stylesheet supplied as argument. Source supplied as xml string
228
and integer parmater created and supplied
229
*/
230
void testTransformToString4(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
231

    
232
  cout<<endl<<"Test: TransformToString4:"<<endl;
233
  trans->clearParameters(true);
234
  trans->clearProperties();
235
    XdmNode * input = processor->parseXmlFromString("<out><person>text1</person><person>text2</person><person>text3</person></out>");
236

    
237
   XdmValue * values = new XdmValue(processor);
238
   values->addXdmItem((XdmItem*)processor->makeIntegerValue(10));
239
  values->addXdmItem((XdmItem*)processor->makeIntegerValue(5));
240
  values->addXdmItem((XdmItem*)processor->makeIntegerValue(6));
241
  values->addXdmItem((XdmItem*)processor->makeIntegerValue(7));
242
   
243
   trans->setParameter("values",(XdmValue *)values);
244

    
245
   if(input == NULL) {
246
        cout<<"Source document is null. ====== FAIL ====== "<<endl;
247
sresult->failureList.push_back("testTransformToString4");
248
    }
249
XdmNode * sheet = processor->parseXmlFromFile("test2.xsl");
250
    trans->setInitialMatchSelection((XdmNode*)input);
251
        trans->compileFromXdmNode(sheet);
252
    const char * output = trans->applyTemplatesReturningString(NULL/*"test2.xsl"*/);
253
   if(output == NULL) {
254
      printf("result is null \n");
255
        sresult->failureList.push_back("testTransformToString4");
256
    }else {
257
      printf("%s", output);
258
      printf("result is OK \n");
259
    }
260
      fflush(stdout);
261
    delete output;
262

    
263
}
264

    
265
void testTransformFromstring(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
266
cout<<endl<<"Test: testTransfromFromstring:"<<endl;
267
  trans->clearParameters(true);
268
  trans->clearProperties();
269
    XdmNode * input = processor->parseXmlFromString("<out><person>text1</person><person>text2</person><person>text3</person></out>");
270

    
271
   trans->compileFromString("<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='2.0'>       <xsl:param name='values' select='(2,3,4)' /><xsl:output method='xml' indent='yes' /><xsl:template match='*'><output><xsl:for-each select='$values' ><out><xsl:value-of select='. * 3'/></out></xsl:for-each></output></xsl:template></xsl:stylesheet>");
272

    
273
 const char * output = trans->transformToString((XdmNode*)input);
274
   if(output == NULL) {
275
      printf("result is null ====== FAIL ====== \n");
276
sresult->failureList.push_back("testTransformFromString");
277
    }else {
278
      printf("%s", output);
279
      printf("result is OK \n");
280

    
281
    }
282
      fflush(stdout);
283
    delete output;
284

    
285

    
286
}
287

    
288
//Test case has error in the stylesheet
289
void testTransformFromstring2Err(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
290
cout<<endl<<"Test: testTransfromFromstring2-Error:"<<endl;
291
  trans->clearParameters(true);
292
  trans->clearProperties();
293
    XdmNode * input = processor->parseXmlFromString("<out><person>text1</person><person>text2</person><person>text3</person></out>");
294

    
295
   trans->compileFromString("<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='2.0'>       <xsl:param name='values' select='(2,3,4)' /><xsl:output method='xml' indent='yes' /><xsl:template match='*'><output><xsl:for-each select='$values' ><out><xsl:value-of select='. * 3'/></out><xsl:for-each></output></xsl:template><xsl:stylesheet>");
296
trans->setInitialMatchSelection((XdmValue*)input);
297
 const char * output = trans->applyTemplatesReturningString();
298
  if(output == NULL) {
299
      printf("result is null ====== FAIL ======  \n\nCheck For errors:\n");
300
        sresult->failureList.push_back("testTransformFromstring2Err");
301
      if(trans->exceptionCount()>0) {
302
        cout<<"Error count="<<trans->exceptionCount()<<", "<<trans->getErrorMessage(0)<<endl;
303
     }        
304
    }else {
305
      printf("%s", output);
306
      printf("result is OK \n");
307
    }
308
    fflush(stdout);
309
    delete output;
310

    
311
   trans->exceptionClear();
312

    
313

    
314
}
315

    
316
void testTrackingOfValueReference(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
317
  trans->clearParameters(true);
318
  trans->clearProperties();
319
 cout<<endl<<"Test: TrackingOfValueReference:"<<endl;
320
ostringstream test;
321
ostringstream valStr;
322
ostringstream name;
323
        for(int i=0; i<10; i++){
324
                test<<"v"<<i;
325
                valStr<<"<out><person>text1</person><person>text2</person><person>text3</person><value>"<<test.str()<<"</value></out>";
326
                name<<"value"<<i;
327
                
328
                XdmValue * values = (XdmValue*)processor->parseXmlFromString(valStr.str().c_str());
329
                //cout<<"Name:"<<name.str()<<", Value:"<<values->getHead()->getStringValue()<<endl;
330
                trans->setParameter(name.str().c_str(), values);
331
                test.str("");
332
                valStr.str("");
333
                name.str("");
334
        }
335
        
336
        std::map<std::string,XdmValue*> parMap = trans->getParameters();
337
        if(parMap.size()>0) {
338
cout<<"Parameter size: "<<parMap.size()<<endl;
339
        cout<<"Parameter size: "<<parMap.size()<<endl;//", Value:"<<trans->getParameters()["value0"]->getHead()->getStringValue()<<endl;
340
ostringstream name1;
341
        for(int i =0; i < 10;i++){
342
                name1<<"param:value"<<i;
343
                cout<<" i:"<<i<<" Map size:"<<parMap.size()<<", ";
344
                XdmValue * valuei = parMap[name1.str()];
345
                if(valuei != NULL ){
346
                        cout<<name1.str();
347
                        if(valuei->itemAt(0) != NULL)
348
                                cout<<"= "<<valuei->itemAt(0)->getStringValue();
349
                        cout<<endl;
350
                } else {
351
                        sresult->failure++;
352
                        std::cerr<<"trackingValueReference ====== FAIL ======"<<std::endl;
353
                        sresult->failureList.push_back("testTrackingOfValueReference");
354
                }
355
                name1.str("");
356
        }
357
        }
358
        sresult->success++;
359
}
360

    
361
/*Test case should be error.*/
362
void testTrackingOfValueReferenceError(SaxonProcessor * processor, Xslt30Processor * trans, sResultCount * sresult){
363
  trans->clearParameters(true);
364
  trans->clearProperties();
365
 cout<<endl<<"Test: TrackingOfValueReference-Error:"<<endl;
366
cout<<"Parameter Map size: "<<(trans->getParameters().size())<<endl;
367
ostringstream test;
368
ostringstream valStr;
369
ostringstream name;
370
        for(int i=0; i<10; i++){
371
                test<<"v"<<i;
372
                valStr<<"<out><person>text1</person><person>text2</person><person>text3</person><value>"<<test.str()<<"<value></out>";
373
                name<<"value"<<i;
374
                
375
                XdmValue * values = (XdmValue*)processor->parseXmlFromString(valStr.str().c_str());
376
                trans->setParameter(name.str().c_str(), values);
377
                test.str("");
378
                valStr.str("");
379
                name.str("");
380
        }
381
        std::map<std::string,XdmValue*> parMap = trans->getParameters();
382
cout<<"Parameter Map size: "<<parMap.size()<<endl;
383
        
384
ostringstream name1;
385
        bool errorFound = false;
386
        for(int i =0; i < 10;i++){
387
                name1<<"param:value"<<i;
388
                cout<<" i:"<<i<<" Map size:"<<parMap.size()<<", ";
389
                 try {
390
                XdmValue * valuei = parMap.at(name1.str());
391
                if(valuei != NULL ){
392
                        cout<<name1.str();
393
                        if(valuei->itemAt(0) != NULL)
394
                                cout<<"= "<<valuei->itemAt(0)->getStringValue();
395
                        cout<<endl;
396
                }
397
                } catch(const std::out_of_range& oor) {
398
                        cout<< "Out of range exception occurred. Exception no. "<<endl;        
399
                        if(!errorFound){
400
                                sresult->success++;
401
                                errorFound = true;
402
                                        
403
                                return;                
404
                        }
405
                }
406
                name1.str("");
407
        }
408
        sresult->failure++;
409
        sresult->failureList.push_back("testTrackingOfValueReferenceError");
410
        
411
}
412

    
413
void testValidation(Xslt30Processor * trans, sResultCount * sresult){
414
 trans->clearParameters(true);
415
  trans->clearProperties();
416

    
417

    
418
trans->compileFromString("<?xml version='1.0'?><xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'                 xmlns:xs='http://www.w3.org/2001/XMLSchema' version='3.0' exclude-result-prefixes='#all'>     <xsl:import-schema><xs:schema><xs:element name='x' type='xs:int'/></xs:schema></xsl:import-schema> <xsl:template name='main'>          <xsl:result-document validation='strict'> <x>3</x>   </xsl:result-document>    </xsl:template>    </xsl:stylesheet>");
419

    
420
          const char * rootValue = trans->callTemplateReturningString(NULL, "main");
421

    
422

    
423
        if(rootValue == NULL) {
424
                std::cout<<"NULL found"<<std::endl;
425
                sresult->failure++;
426
                sresult->failureList.push_back("testValidation");
427
                return;
428

    
429
        } else {
430
                std::cout<<"Result="<<rootValue<<endl;
431
                sresult->success++;
432
        }
433
}
434

    
435

    
436
void testXdmNodeOutput(Xslt30Processor * trans, sResultCount * sresult){
437
 trans->clearParameters(true);
438
  trans->clearProperties();
439

    
440
        std::cout<<"testXdmNodeOutput"<<std::endl;
441
  trans->compileFromString("<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:template name='go'><a/></xsl:template></xsl:stylesheet>");
442
          XdmValue * rootValue = trans->callTemplateReturningValue(NULL, "go");
443
        if(rootValue == NULL){
444
                        cout<<"Result is null ====== FAIL ====== "<<endl;
445
                        sresult->failure++;
446
                        sresult->failureList.push_back("testXdmNodeOutput-0.0");
447
                        return;
448
        }
449
            XdmItem * rootItem = rootValue->getHead();
450
             if(rootItem == NULL) {  
451
                             
452
                        cout<<"Result is null ====== FAIL ====== "<<endl;
453
                        sresult->failure++;
454
                        sresult->failureList.push_back("testXdmNodeOutput-0");
455
                        return;
456
                } 
457
                XdmNode *root = (XdmNode*)rootItem; 
458
               if(root->getNodeKind() == DOCUMENT){
459
                   cout<<"Result is a Document"<<endl;
460
                } else {
461
                        cout<<"Node is of kind:"<<root->getNodeKind()<<endl;
462
                }
463
                const char * result = trans->callTemplateReturningString(NULL, "go");
464
                if(string(result).find(string("<a/>")) != std::string::npos) {
465
                        sresult->success++;
466
                } else {
467
                        //TODO - this test case prints the XML declaration. Check if this correct
468
                        sresult->failure++;
469
                        cout<<"testXdmNodeOutputAndString ======= FAIL========"<<endl;
470
                        sresult->failureList.push_back(result);
471
                }
472
  trans->clearProperties();
473
                
474
}
475

    
476
void exampleSimple1(Xslt30Processor  *proc, sResultCount *sresult){
477
                cout<<"ExampleSimple1 taken from PHP:"<<endl;
478
                proc->setInitialMatchSelectionAsFile("../php/xml/foo.xml");
479
                proc->compileFromFile("../php/xsl/foo.xsl");
480
                        
481
                const char *result = proc->applyTemplatesReturningString();               
482
                if(result != NULL) {               
483
                        cout<<result<<endl;
484
                        sresult->success++;
485
                } else {
486
                        cout<<"Result is null ====== FAIL ====== "<<endl;
487
                        sresult->failure++;
488
                }
489
                proc->clearParameters(true);
490
                proc->clearProperties();            
491
            }
492

    
493
void exampleSimple1Err(Xslt30Processor  *proc, sResultCount *sresult){
494
                cout<<"ExampleSimple1 taken from PHP:"<<endl;
495
                proc->setInitialMatchSelectionAsFile("cat.xml");
496
                proc->compileFromFile("err.xsl");
497
                        
498
                const char *result = proc->applyTemplatesReturningString();               
499
                if(result != NULL) {               
500
                        cout<<result<<endl;
501
                        sresult->failure++;
502
                        sresult->failureList.push_back("exampleSimple1Err");
503
                } else {
504
                        cout<<"Result expected as null "<<endl;
505
                        sresult->success++;
506
                }
507
                proc->clearParameters(true);
508
                proc->clearProperties();            
509
            }
510

    
511
int exists(const char *fname)
512
{
513
    FILE *file;
514
    file = fopen(fname, "r");
515
    if (file)
516
    {
517
        fclose(file);
518
        return 1;
519
    }
520
    return 0;
521
}
522

    
523

    
524
  void exampleSimple2(Xslt30Processor  *proc, sResultCount *sresult){
525
                cout<<"<b>exampleSimple2:</b><br/>"<<endl;
526
                //proc->setcwd("");
527
                proc->setInitialMatchSelectionAsFile("../php/xml/foo.xml");
528
                
529
                proc->compileFromFile("../php/xsl/foo.xsl");
530
                const char * filename = "output1.xml";
531
                proc->setOutputFile(filename);
532
                proc->applyTemplatesReturningFile(NULL, "output1.xml");
533
                                
534
                if (exists("output1.xml")) {
535
                    cout<<"The file $filename exists"<<endl;
536
                   remove("output1.xml");
537
                   sresult->success++;
538
                } else {
539
                    cout<<"The file "<<filename<<" does not exist"<<endl;
540
                    if(proc->exceptionCount()>0) {
541
                            cout<<proc->getErrorMessage(0)<<endl;
542
                         }
543
                    sresult->failure++;
544
                        sresult->failureList.push_back("exampleSimple2");
545
                }
546
                       proc->clearParameters(true);
547
                proc->clearProperties();
548
            }
549

    
550
void exampleSimple3(SaxonProcessor * saxonProc, Xslt30Processor  *proc, sResultCount *sresult){
551
                cout<<"<b>exampleSimple3:</b><br/>"<<endl;
552
                proc->clearParameters(true);
553
                proc->clearProperties();
554
                XdmNode * xdmNode = saxonProc->parseXmlFromString("<doc><b>text value of out</b></doc>");
555
                if(xdmNode == NULL) {
556
                        cout<<"Error: xdmNode is null'"<<endl;
557
                        sresult->failure++;
558
                        sresult->failureList.push_back("exampleSimple3");
559
                        return;        
560
                }            
561
                proc->setInitialMatchSelection((XdmNode*)xdmNode);
562
                cout<<"end of exampleSimple3"<<endl;
563
                proc->clearParameters(true);
564
                proc->clearProperties();
565
                sresult->success++;
566
}
567

    
568
void exampleParam(SaxonProcessor * saxonProc, Xslt30Processor  *proc, sResultCount *sresult){
569
                cout<< "\nExampleParam:</b><br/>"<<endl;
570
                proc->setInitialMatchSelectionAsFile("../php/xml/foo.xml");
571
                proc->compileFromFile("../php/xsl/foo.xsl");
572
            
573
                XdmAtomicValue * xdmvalue = saxonProc->makeStringValue("Hello to you");
574
                if(xdmvalue !=NULL){
575
                        
576
                        proc->setParameter("a-param", (XdmValue*)xdmvalue);
577

    
578
                } else {
579
                        cout<< "Xdmvalue is null - ====== FAIL ====="<<endl;
580
                        sresult->failure++;
581
                        sresult->failureList.push_back("exampleParam-1");
582
                }
583
                const char * result = proc->applyTemplatesReturningString();
584
                if(result != NULL) {                
585
                        cout<<"Output:"<<result<<endl;
586
                        sresult->success++;
587
                } else {
588
                        cout<<"Result is NULL<br/>  ======= fail ====="<<endl;
589
                        sresult->failure++;
590
                        sresult->failureList.push_back("exampleParam-2");
591
                }
592
               
593
                //proc->clearParameters();                
594
                //unset($result);
595
                //echo 'again with a no parameter value<br/>';
596
                
597
                proc->setProperty("!indent", "yes"); 
598
                const char *result2 = proc->applyTemplatesReturningString();
599
               
600
                proc->clearProperties();
601
                if(result2 != NULL) {                
602
                        cout<<result2<<endl;
603
                        sresult->success++;
604
                }
605
               
606
              //  unset($result);
607
               // echo 'again with no parameter and no properties value set. This should fail as no contextItem set<br/>';
608
                XdmAtomicValue * xdmValue2 = saxonProc->makeStringValue("goodbye to you");
609
                proc->setParameter("a-param", (XdmValue*)xdmValue2);
610
                
611
                const char *result3 = proc->applyTemplatesReturningString();   
612
                if(result3 != NULL) {             
613
                        cout<<"Output ="<<result3<<endl;
614
                        sresult->success++;
615
                } else {
616
                        cout<<"Error in result ===== FAIL ======="<<endl;
617
                        sresult->failure++;
618
                        sresult->failureList.push_back("exampleParam");
619
                }
620
                proc->clearParameters();
621
                proc->clearProperties(); 
622
                        
623
}
624

    
625
// test parameter and properties maps where we update key, value pair.
626
void exampleParam2(SaxonProcessor * saxonProc, Xslt30Processor  *proc, sResultCount *sresult){
627
                cout<< "\nExampleParam:</b><br/>"<<endl;
628
                proc->setInitialMatchSelectionAsFile("../php/xml/foo.xml");
629
                proc->compileFromFile("../php/xsl/foo.xsl");
630

    
631
                XdmAtomicValue * xdmvalue = saxonProc->makeStringValue("Hello to you");
632
                XdmAtomicValue * xdmvalue2i = saxonProc->makeStringValue("Hello from me");
633
                if(xdmvalue !=NULL){
634

    
635
                        proc->setParameter("a-param", (XdmValue*)xdmvalue);
636
                        proc->setParameter("a-param", (XdmValue*)xdmvalue2i);
637

    
638
                } else {
639
                        cout<< "Xdmvalue is null - ====== FAIL ====="<<endl;
640
                        sresult->failure++;
641
                        sresult->failureList.push_back("exampleParam-1");
642
                }
643
                const char * result = proc->applyTemplatesReturningString();
644
                if(result != NULL) {
645
                    string sresult = string(result);
646
                    if(sresult.compare("Hello from me") == 0) {}
647
                        cout<<"Output:"<<result<<endl;
648
                        sresult->success++;
649
                        }  else {
650
                            out<<"Result is "<<result<<""<br/>  ======= fail ====="<<endl;
651
                            sresult->failure++;
652
                    sresult->failureList.push_back("exampleParam-2");
653
                        }
654
                } else {
655
                        cout<<"Result is NULL<br/>  ======= fail ====="<<endl;
656
                        sresult->failure++;
657
                        sresult->failureList.push_back("exampleParam-2");
658
                }
659

660
                //proc->clearParameters();
661
                //unset($result);
662
                //echo 'again with a no parameter value<br/>';
663

664
                proc->setProperty("!indent", "no");
665
                proc->setProperty("!indent", "yes");
666
        const char *result2 = proc->applyTemplatesReturningString();
667

668
                proc->clearProperties();
669
                if(result2 != NULL) {
670
                        cout<<result2<<endl;
671
                        sresult->success++;
672
                }
673

674
              //  unset($result);
675
               // echo 'again with no parameter and no properties value set. This should fail as no contextItem set<br/>';
676
                XdmAtomicValue * xdmValue2 = saxonProc->makeStringValue("goodbye to you");
677
                proc->setParameter("a-param", (XdmValue*)xdmValue2);
678

679
                const char *result3 = proc->applyTemplatesReturningString();
680
                if(result3 != NULL) {
681
                        cout<<"Output ="<<result3<<endl;
682
                        sresult->success++;
683
                } else {
684
                        cout<<"Error in result ===== FAIL ======="<<endl;
685
                        sresult->failure++;
686
                        sresult->failureList.push_back("exampleParam");
687
                }
688
                proc->clearParameters();
689
                proc->clearProperties();
690

691
}
692

693
/* XMarkbench mark test q12.xsl with just-in-time=true*/
694
void xmarkTest1(Xslt30Processor  *proc, sResultCount * sresult){
695
                cout<<"XMarkbench mark test q12.xsl (JIT=true):"<<endl;
696

697
        proc->setJustInTimeCompilation(true);
698

699
        XdmValue *result = proc->transformFileToValue("xmark100k.xml", "q12.xsl");
700
                if(result != NULL) {
701
                        cout<<"XdmNode returned"<<endl;
702
                        sresult->success++;
703
                } else {
704
                         printf("result is null \nCheck For errors:");
705
                        sresult->failure++;
706
                        sresult->failureList.push_back("xmarkTest1");
707
             if(proc->exceptionCount()>0) {
708
                    cout<<proc->getErrorMessage(0)<<endl;
709
             }
710
                }
711
                proc->clearParameters(true);
712
                proc->clearProperties();
713

714
 }
715

716

717

718
 /* XMarkbench mark test q12.xsl with just-in-time=true*/
719
 void xmarkTest2(Xslt30Processor  *proc, sResultCount *sresult){
720
                 cout<<"XMarkbench mark test q12.xsl (JIT=true):"<<endl;
721

722

723
         XdmValue *result = proc->transformFileToValue("xmark100k.xml", "q12.xsl");
724
                 if(result != NULL) {
725
                         cout<<"XdmNode returned"<<endl;
726
                 } else {
727
                          printf("result is null \nCheck For errors:");
728
                        sresult->failure++;
729
                        sresult->failureList.push_back("xmarkTest2");
730
              if(proc->exceptionCount()>0) {
731
                     cout<<proc->getErrorMessage(0)<<endl;
732
              }
733
                 }
734
                 proc->clearParameters(true);
735
                 proc->clearProperties();
736

737
  }
738

739
/* XMarkbench mark test q12.xsl with just-in-time=true*/
740
void exampleSimple_xmark(Xslt30Processor  *proc, sResultCount *sresult){
741
                cout<<"XMarkbench mark test q12.xsl:"<<endl;
742

743
        proc->setJustInTimeCompilation(true);
744

745
        XdmValue *result = proc->transformFileToValue("xmark100k.xml", "q12.xsl");
746
                if(result != NULL) {
747
                        cout<<"XdmNode returned"<<endl;
748
                } else {
749
                         printf("result is null \nCheck For errors:");
750
             if(proc->exceptionCount()>0) {
751
                    cout<<proc->getErrorMessage(0)<<endl;
752
             }
753
                }
754
                proc->clearParameters(true);
755
                proc->clearProperties();
756

757
 }
758

759

760
/*
761
* Test saving nd loading a Xslt package
762
*/
763
void testPackage1(Xslt30Processor * trans, sResultCount *sresult){
764

765
  cout<<endl<<"Test: Saving and loading Packages:"<<endl;
766
  trans->clearParameters(true);
767
  trans->clearProperties();
768

769
    trans->compileFromFileAndSave("test.xsl", "test1.sef");
770
     const char * output = trans->transformFileToString("cat.xml","test1.sef");        
771
   if(output == NULL) {
772
      printf("result is null \n");
773
        const char * message = trans->checkException();
774
        if(message != NULL) {
775
                cout<<"Error message =" << message<< endl;
776
        }
777
        sresult->failure++;
778
        sresult->failureList.push_back("testPackage1");
779

780
    }else {
781
      printf("%s", output);
782
      printf("result is OK \n");
783
      sresult->success++;
784
    }
785
      fflush(stdout);
786
    delete output;
787
}
788

789

790
/*
791
* Test saving and loading a Xslt package
792
*/
793
void testPackage2(Xslt30Processor * trans, sResultCount * sresult){
794

795
  cout<<endl<<"Test: Saving and loading Packages2 - Error:"<<endl;
796
  trans->clearParameters(true);
797
  trans->clearProperties();
798

799
        const char * stylesheet = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='2.0'>       <xsl:param name='values' select='(2,3,4)' /><xsl:output method='xml' indent='yes' /><xsl:template match='*'><output><xsl:for-each select='$values' ><out><xsl:value-of select='. * 3'/></out><xsl:for-each></output></xsl:template><xsl:stylesheet>";
800

    
801
    trans->compileFromStringAndSave(stylesheet, "test2.sef");
802
     const char * output = trans->transformFileToString("cat.xml","test2.sef");        
803
   if(output == NULL) {
804
      printf("result is null as expected \n");
805
        const char * message = trans->checkException();
806
        if(message != NULL) {
807
                cout<<"Error message =" << message<< endl;
808
        }
809
        sresult->success++;
810
    }else {
811
      printf("%s", output);
812
      printf("result is OK \n");
813
      sresult->failure++;
814
      sresult->failureList.push_back("testPackage2");
815
    }
816
      fflush(stdout);
817
    delete output;
818
}
819

    
820
 void testCallFunction(SaxonProcessor * proc, Xslt30Processor * trans, sResultCount * sresult){ 
821
           
822
           const char* source = "<?xml version='1.0'?> <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:f='http://localhost/' version='3.0'> <xsl:function name='f:add' visibility='public'>    <xsl:param name='a'/><xsl:param name='b'/> <xsl:sequence select='$a + $b'/></xsl:function></xsl:stylesheet>";
823
            cout<<endl<<"Test: testCallFunction:"<<endl;
824
            trans->compileFromString(source);
825
                XdmValue ** valueArray =new XdmValue*[2];
826

    
827
                valueArray[0] = (XdmValue*)(proc->makeIntegerValue(2));
828
                valueArray[1] = (XdmValue*)(proc->makeIntegerValue(3));
829
            XdmValue *v = NULL;//TODO fix trans->callFunctionReturningValue(NULL, "{http://localhost/}add", valueArray);
830
                
831
            if(v != NULL && (v->getHead())->isAtomic() && ((XdmAtomicValue*) (v->getHead()))->getLongValue()==5){
832
                sresult->success++;
833
            } else {
834
                if(v!= NULL && !(v->getHead())->isAtomic()) {
835
                        cout<<"Value in callFunction is not atomic - but expected as atomic value"<<endl;
836
                }
837
                cout<<"testCallFunction ======= FAIL ======"<<endl;
838
                const char * message = trans->checkException();
839
                if(message != NULL) {
840
                  cout<<"Error message =" << message<< endl;
841
                }
842
                sresult->failure++;
843
                sresult->failureList.push_back("testCallFunction");
844
                }
845
                delete valueArray[0];
846
                delete valueArray[1];
847
                delete valueArray;
848
    }
849

    
850
void testInitialTemplate(SaxonProcessor * proc, Xslt30Processor * trans, sResultCount * sresult) {
851

    
852

    
853
    const char* source = "<?xml version='1.0'?>  <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'  xmlns:xs='http://www.w3.org/2001/XMLSchema'  version='3.0'>  <xsl:template match='*'>     <xsl:param name='a' as='xs:double'/>     <xsl:param name='b' as='xs:float'/>     <xsl:sequence select='., $a + $b'/>  </xsl:template>  </xsl:stylesheet>";
854
cout<<endl<<"Test:testInitialTemplate"<<endl;
855
    trans->compileFromString(source);
856
    XdmNode * node = proc->parseXmlFromString("<e/>");
857

    
858
    trans->setResultAsRawValue(false);
859
std::map<std::string,XdmValue*> parameterValues;
860
 parameterValues["a"] = proc->makeIntegerValue(12);
861
parameterValues["b"] = proc->makeIntegerValue(5);
862
    trans->setInitialTemplateParameters(parameterValues, false);
863
    trans->setInitialMatchSelection(node);
864
    XdmValue * result = trans->applyTemplatesReturningValue();
865
 if(result != NULL){
866
        sresult->success++;
867
        cout<<"Result="<<result->getHead()->getStringValue()<<endl;
868
} else {
869
        sresult->failure++;
870
}
871

    
872
}
873

    
874
void testResolveUri(SaxonProcessor * proc, Xslt30Processor * trans, sResultCount * sresult) {
875
 cout<<endl<<"Test: testResolveUri:"<<endl;
876
 
877
trans->compileFromString("<xsl:stylesheet version='3.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:err='http://www.w3.org/2005/xqt-errors'><xsl:template name='go'><xsl:try><xsl:variable name='uri' as='xs:anyURI' select=\"resolve-uri('notice trailing space /out.xml')\"/> <xsl:message select='$uri'/><xsl:result-document href='{$uri}'><out/></xsl:result-document><xsl:catch><xsl:sequence select=\"'$err:code: ' || $err:code  || ', $err:description: ' || $err:description\"/></xsl:catch></xsl:try></xsl:template></xsl:stylesheet>");
878

    
879

    
880
            XdmValue * value = trans->callTemplateReturningValue(NULL, "go");
881

    
882

    
883
                if(value == NULL) {
884

    
885
                        sresult->failure++;
886
                        sresult->failureList.push_back("testResolveUri");
887
                } else {
888
                                    
889
                const char * svalue = value->itemAt(0)->getStringValue();
890
                cout<<"testResolveUri = "<<svalue<<endl;
891
                sresult->success++;
892
                }
893

    
894
        
895

    
896
}
897

    
898
void testContextNotRoot(SaxonProcessor * proc, Xslt30Processor * trans, sResultCount * sresult) {
899
        cout<<endl<<"Test: testContextNotRoot"<<endl;
900
 
901
     XdmNode * node = proc->parseXmlFromString("<doc><e>text</e></doc>");
902

    
903
     trans->compileFromString("<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:variable name='x' select='.'/><xsl:template match='/'>errorA</xsl:template><xsl:template match='e'>[<xsl:value-of select='name($x)'/>]</xsl:template></xsl:stylesheet>");
904
        trans->setGlobalContextItem(node);                                
905
    if(node->getChildCount()>0){
906
                  XdmNode * eNode = node->getChildren()[0]->getChildren()[0];
907
                cout<<"Node content = "<<eNode->toString()<<endl;
908
            trans->setInitialMatchSelection(eNode);
909
            const char* result = trans->applyTemplatesReturningString();
910
                
911
            if(result == NULL) {
912

    
913
                cout<<"testCallFunction ======= FAIL ======"<<endl;
914
                const char * message = trans->checkException();
915
                if(message != NULL) {
916
                  cout<<"Error message =" << message<< endl;
917
                }
918
                        sresult->failure++;
919
                        sresult->failureList.push_back("testContextNotRoot");
920
                } else {
921
                                    
922
                cout<<"testContextNotRoot = "<<result<<endl;
923
                sresult->success++;
924
                }
925
       }
926
    }
927

    
928

    
929

    
930

    
931
void testContextNotRootNamedTemplate(SaxonProcessor * proc, Xslt30Processor * trans, sResultCount * sresult) {
932
        cout<<endl<<"Test: testContextNotRootNamedTemplate"<<endl;
933
 
934
     XdmNode * node = proc->parseXmlFromString("<doc><e>text</e></doc>");
935

    
936
     trans->compileFromString("<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:variable name='x' select='.'/><xsl:template match='/'>errorA</xsl:template><xsl:template name='main'>[<xsl:value-of select='name($x)'/>]</xsl:template></xsl:stylesheet>");
937
        trans->setGlobalContextItem(node);                                
938
            const char* result = trans->callTemplateReturningString(NULL, "main");
939
                
940
            if(result == NULL) {
941

    
942
                cout<<"testCallFunction ======= FAIL ======"<<endl;
943
                const char * message = trans->checkException();
944
                if(message != NULL) {
945
                  cout<<"Error message =" << message<< endl;
946
                }
947
                        sresult->failure++;
948
                        sresult->failureList.push_back("testContextNotRootNamedTemplate");
949
                } else {
950
                                    
951
                cout<<"testContextNotRoot = "<<result<<endl;
952
                sresult->success++;
953
                }
954
       
955
    }
956

    
957

    
958

    
959
void testContextNotRootNamedTemplateValue(SaxonProcessor * proc, Xslt30Processor * trans, sResultCount * sresult) {
960
        cout<<endl<<"Test: testContextNotRootNamedTemplateValue"<<endl;
961
 
962
     XdmNode * node = proc->parseXmlFromString("<doc><e>text</e></doc>");
963

    
964
     trans->compileFromString("<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:variable name='x' select='.'/><xsl:template match='/'>errorA</xsl:template><xsl:template name='main'>[<xsl:value-of select='name($x)'/>]</xsl:template></xsl:stylesheet>");
965
        trans->setGlobalContextItem(node);                                
966
            XdmValue * result = trans->callTemplateReturningValue(NULL, "main");
967
                
968
            if(result == NULL) {
969

    
970
                cout<<"testCallFunction ======= FAIL ======"<<endl;
971
                const char * message = trans->checkException();
972
                if(message != NULL) {
973
                  cout<<"Error message =" << message<< endl;
974
                }
975
                        sresult->failure++;
976
                        sresult->failureList.push_back("testContextNotRootNamedTemplateValue");
977
                } else {
978
                                    
979
                cout<<"testContextNotRoot = "<<result->getHead()->getStringValue()<<endl;
980
                sresult->success++;
981
                }
982
       
983
    }
984

    
985
void testCallSystemFunction(SaxonProcessor * proc, sResultCount * sresult) {
986
                XdmFunctionItem *fi = XdmFunctionItem.getSystemFunction(proc, "{http://www.w3.org/2005/xpath-functions}parse-json", 1);
987
                if(fi == NULL) {
988
                    sresult->failure++;
989
                    sresult->failureList.push_back("testCallSystemFunction");
990

    
991
                }
992
                XdmValue * result = fi->call(proc, proc->makeStringValue("[1,2,3]"));
993

    
994
                std::cerr<<"Result = "<<result->getStringValue()<<endl;
995
                assertEquals(3, result.arrayLength());
996

    
997
        }
998

    
999

    
1000
void testPipeline(SaxonProcessor * proc, sResultCount * sresult){
1001
  cout<<endl<<"Test: testPipeline"<<endl;
1002
 
1003
         Xslt30Processor * stage1 = proc->newXslt30Processor();
1004
          stage1->compileFromString("<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:template match='/'><a><xsl:copy-of select='.'/></a></xsl:template></xsl:stylesheet>");
1005
          XdmNode * inn = proc->parseXmlFromString("<z/>");
1006

    
1007
          Xslt30Processor * stage2 = proc->newXslt30Processor();
1008
          stage2->compileFromString("<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:template match='/'><a><xsl:copy-of select='.'/></a></xsl:template></xsl:stylesheet>");
1009

    
1010

    
1011
        if(stage2->exceptionCount()>0){
1012
                const char * message = stage2->getErrorMessage(0);
1013
                cout<<"exception-CP0="<< message<<endl;
1014
            }
1015
/*
1016
          Xslt30Processor * stage3 = proc->newXslt30Processor();
1017
          stage3->compileFromString("<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:template match='/'><a><xsl:copy-of select='.'/></a></xsl:template></xsl:stylesheet>");
1018

1019
          Xslt30Processor * stage4 = proc->newXslt30Processor();
1020
          stage4->compileFromString("<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:template match='/'><a><xsl:copy-of select='.'/></a></xsl:template></xsl:stylesheet>");
1021

1022
          Xslt30Processor * stage5 = proc->newXslt30Processor();
1023
          stage5->compileFromString("<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:template match='/'><a><xsl:copy-of select='.'/></a></xsl:template></xsl:stylesheet>");
1024
*/
1025
          stage1->setProperty("!indent", "no");
1026
          stage1->setInitialMatchSelection(inn);
1027

    
1028
          XdmValue * d1 = stage1->applyTemplatesReturningValue();
1029
           if(stage1->exceptionCount()>0){
1030
                cout<<"Exception message="<<(stage1->getErrorMessage(0))<<endl;
1031
                return;
1032
            }
1033
                
1034
          if(d1==NULL){
1035
                cout<<"ERROR1"<<endl;;
1036
                return;
1037
            }
1038
        XdmItem * d11 = d1->getHead();
1039
        if(d11 == NULL)        {
1040

    
1041
                cout<<"d11 is NULL\n"<<endl;
1042
        }
1043
        const char *data = d1->getHead()->toString();
1044

    
1045
        if(data != NULL){
1046
        cout<<"d1 result="<<data<<endl;
1047
        }else {
1048
        cout<<"checkpoint\n"<<endl;
1049

    
1050
        return;
1051
        }
1052
          stage2->setProperty("!indent", "no");
1053
          stage2->setInitialMatchSelection(d1->getHead());
1054
          XdmValue * d2 = stage2->applyTemplatesReturningValue();
1055
          if(d2==NULL){
1056
                cout<<"ERROR-11\n"<<endl;
1057
           if(stage2->exceptionCount()>0){
1058
                const char * message = stage2->getErrorMessage(0);
1059
                cout<<"exception="<< message<<endl;
1060
            }
1061
                return;
1062
            } else {
1063
                cout<<"d2 result = "<<d2->getHead()->toString()<<endl;
1064
                }
1065
          /*$stage3->setProperty("!indent", "no");
1066
          $stage3->setInitialMatchSelection($d2);
1067
          $d3 = $stage3->applyTemplatesReturningValue();
1068
          if($d3==NULL){
1069
                echo "ERROR2";                
1070
                exit(1);
1071
            }
1072
          $stage4->setProperty("!indent", "no");
1073
          $stage4->setInitialMatchSelection($d3);
1074
          $d4 = $stage4->applyTemplatesReturningValue();
1075
         if($d3==NULL){
1076
                echo "ERROR3";
1077
                exit(1);
1078
            }
1079
          $stage5->setProperty("!indent", "no");
1080
          $stage4->setInitialMatchSelection($d4);
1081
          $sw = $stage5->applyTemplatesReturningString();
1082
          if($sw==NULL){
1083
                echo "ERROR4";
1084
                exit(1);
1085
            }
1086
          cout<<sw<<endl;
1087
*/
1088

    
1089
}
1090

    
1091
int main()
1092
{
1093

    
1094
    
1095
    SaxonProcessor * processor = new SaxonProcessor(true);
1096
    cout<<"Test: Xslt30Processor with Saxon version="<<processor->version()<<endl<<endl; 
1097
    //processor->setcwd("/home");
1098
   if(processor->isSchemaAwareProcessor()) {
1099

    
1100
    std::cerr<<"Processor is Schema Aware"<<std::endl;
1101
  } else {
1102
        std::cerr<<"Processor is not Schema Aware"<<std::endl;
1103
 }
1104
   processor->setConfigurationProperty("http://saxon.sf.net/feature/generateByteCode","false");
1105
   sResultCount *sresult = new sResultCount();
1106
    Xslt30Processor * trans = processor->newXslt30Processor();
1107
        //testValidation(trans,sresult);
1108
testInitialTemplate(processor, trans, sresult);
1109
   exampleSimple1Err(trans, sresult);
1110
    exampleSimple1(trans, sresult);
1111
    exampleSimple_xmark(trans, sresult);
1112
    exampleSimple2(trans, sresult);
1113
    exampleSimple3(processor, trans, sresult);
1114

    
1115
    testApplyTemplatesString1(trans, sresult);
1116

    
1117
    testApplyTemplatesString2(processor, trans, sresult);
1118

    
1119
    testApplyTemplates2a(processor, trans, sresult);
1120

    
1121
    testTransformToString4(processor, trans, sresult);
1122

    
1123

    
1124

    
1125
    /*testTransformToString2b(processor, trans, sresult);
1126

1127
    testTransformToString3(processor, trans, sresult);
1128
        
1129
    testTransformFromstring(processor, trans, sresult);
1130

1131
    testTransformFromstring2Err(processor, trans, sresult);      */
1132

    
1133
    testTrackingOfValueReference(processor, trans,sresult);
1134

    
1135
    testTrackingOfValueReferenceError(processor, trans, sresult);
1136

    
1137
    testPackage1(trans, sresult);
1138

    
1139
   testPackage2(trans, sresult);
1140

    
1141
    testXdmNodeOutput(trans, sresult);
1142

    
1143
    exampleParam(processor, trans, sresult);
1144

    
1145
    xmarkTest1(trans, sresult);
1146

    
1147
    xmarkTest2(trans, sresult);
1148
   testCallFunction(processor, trans, sresult);
1149
   testResolveUri(processor, trans, sresult);
1150
    testContextNotRoot(processor, trans, sresult);
1151
testContextNotRootNamedTemplate(processor, trans, sresult);
1152
testContextNotRootNamedTemplateValue(processor, trans, sresult);
1153
testPipeline(processor, sresult); 
1154

    
1155
  //Available in PE and EE
1156
   //testTransformToStringExtensionFunc(processor, trans);
1157

    
1158
    delete trans;
1159
delete processor;
1160
    // processor->release();
1161

    
1162

    
1163
 SaxonProcessor * processor2 = new SaxonProcessor(true);
1164

    
1165
    Xslt30Processor * trans2 = processor2->newXslt30Processor();
1166
testApplyTemplatesString1(trans2, sresult);
1167
  delete trans2;
1168
     processor2->release();
1169

    
1170
   std::cout<<"\nTest Results - Number of tests= "<<(sresult->success+sresult->failure)<<", Successes = "<<sresult->success<<",  Failures= "<<sresult->failure<<std::endl;
1171

    
1172
std::list<std::string>::iterator it;
1173
 std::cout<<"Failed tests:"<<std::endl;
1174
// Make iterate point to begining and incerement it one by one till it reaches the end of list.
1175
for (it = sresult->failureList.begin(); it != sresult->failureList.end(); it++)
1176
{
1177
        //Print the contents
1178
        std::cout << it->c_str() << std::endl;
1179
 
1180
}
1181

    
1182

    
1183

    
1184
    return 0;
1185
}
(24-24/25)