Project

Profile

Help

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

he / src / main / c / samples / cppTests / testXSLT.cpp @ af4371f2

1
#include <sstream>
2
#include <stdio.h>
3
#include <cstdlib>
4
#include <pthread.h>
5
#include <unistd.h>
6
#include <thread>
7
#include "../../Saxon.C.API/SaxonProcessor.h"
8
#include "../../Saxon.C.API/XdmValue.h"
9
#include "../../Saxon.C.API/XdmItem.h"
10
#include "../../Saxon.C.API/XdmNode.h"
11
#include "CppTestUtils.h"
12

    
13
#include <string>
14

    
15
// TODO: write test case for checking parameters which are null
16

    
17

    
18
using namespace std;
19

    
20

    
21

    
22
/*
23
* Test transform to String. Source and stylesheet supplied as arguments
24
*/
25
void testTransformToString1(XsltProcessor * trans){
26
        
27
  cout<<endl<<"Test: TransformToString1:"<<endl;
28

    
29
    const char * output = trans->transformFileToString("cat.xml", "test.xsl");
30
   if(output == NULL) {
31
      printf("result is null \n");
32

    
33
    }else {
34
      printf("%s", output);
35
      printf("result is OK \n");
36
    }
37
      fflush(stdout);
38
        delete output;
39

    
40
}
41

    
42

    
43

    
44

    
45
/*
46
* Test transform to String. stylesheet supplied as argument. Source supplied as XdmNode
47
*/
48
void testTransformToString2(SaxonProcessor * processor, XsltProcessor * trans){
49

    
50
  cout<<endl<<"Test: TransformToString2:"<<endl;
51
  trans->clearParameters(true);
52
  trans->clearProperties();
53
    XdmNode * input = processor->parseXmlFromFile("cat.xml");
54

    
55
   if(input == NULL) {
56
        cout<<"Source document is null."<<endl;
57

    
58
    }
59

    
60
     trans->setSourceFromXdmNode((XdmNode*)input);
61
    const char * output = trans->transformFileToString(NULL, "test.xsl");
62
   if(output == NULL) {
63
      printf("result is null \n");
64

    
65
    }else {
66
      printf("%s", output);
67
      printf("result is OK \n");
68
    }
69
      fflush(stdout);
70
    delete output;
71
}
72

    
73
/*
74
* Test transform to String. stylesheet supplied as argument. Source supplied as XdmNode
75
Should be error. Stylesheet file does not exist
76
*/
77
void testTransformToString2a(SaxonProcessor * processor, XsltProcessor * trans){
78

    
79
  cout<<endl<<"Test: TransformToString2a:"<<endl;
80
  trans->clearParameters(true);
81
  trans->clearProperties();
82
    XdmNode * input = processor->parseXmlFromFile("cat.xml");
83

    
84
   if(input == NULL) {
85
        cout<<"Source document is null."<<endl;
86

    
87
    }
88

    
89
     trans->setSourceFromXdmNode((XdmNode*)input);
90
    const char * output = trans->transformFileToString(NULL, "test-error.xsl");
91
   if(output == NULL) {
92
      printf("result is null \n");
93

    
94
    }else {
95
      printf("%s", output);
96
      printf("result is OK \n");
97
    }
98
      fflush(stdout);
99
    delete output;
100
        
101
        
102

    
103
}
104

    
105
/*
106
* Test transform to String. stylesheet supplied as argument. Source supplied as XdmNode
107
Should be error. Source file does not exist
108
*/
109
void testTransformToString2b(SaxonProcessor * processor, XsltProcessor * trans){
110

    
111
  cout<<endl<<"Test: TransformToString2b:"<<endl;
112
  trans->clearParameters(true);
113
  trans->clearProperties();
114
    XdmNode * input = processor->parseXmlFromFile("cat-error.xml");
115

    
116
   if(input == NULL) {
117
        cout<<"Source document is null."<<endl;
118

    
119
    }
120

    
121
     trans->setSourceFromXdmNode((XdmNode*)input);
122
    const char * output = trans->transformFileToString(NULL, "test-error.xsl");
123
   if(output == NULL) {
124
      printf("result is null \nCheck For errors:");
125
      if(trans->exceptionOccurred()) {
126
        cout<<trans->getErrorMessage()<<endl;
127
      }        
128
    }else {
129
      printf("%s", output);
130
      printf("result is OK \n");
131
    }
132
      fflush(stdout);
133
    delete output;
134
        
135
    trans->exceptionClear();
136

    
137
}
138

    
139

    
140
/*
141
* Test transform to String. stylesheet supplied as argument. Source supplied as xml string
142
and integer parmater created and supplied
143
*/
144
void testTransformToString3(SaxonProcessor * processor, XsltProcessor * trans){
145

    
146
  cout<<endl<<"Test: TransformToString3:"<<endl;
147
  trans->clearParameters(true);
148
  trans->clearProperties();
149
    XdmNode * inputi = processor->parseXmlFromString("<out><person>text1</person><person>text2</person><person>text3</person></out>");
150

    
151
   XdmAtomicValue * value1 = processor->makeIntegerValue(10);
152

    
153
   trans->setParameter("numParam",(XdmValue *)value1);
154

    
155
   if(inputi == NULL) {
156
        cout<<"Source document inputi is null."<<endl;
157

    
158
    }
159

    
160
    trans->setSourceFromXdmNode((XdmNode*)inputi);
161
    const char * output = trans->transformFileToString(NULL, "test.xsl");
162
   if(output == NULL) {
163
      printf("result is null \n");
164

    
165
    }else {
166
      printf("%s", output);
167
      printf("result is OK \n");
168
    }
169
      fflush(stdout);
170
   delete output;
171

    
172
}
173

    
174
/*
175
* Test transform to String. stylesheet supplied as argument. Source supplied as xml string
176
and integer parmater created and supplied
177
*/
178
void testTransformToString4(SaxonProcessor * processor, XsltProcessor * trans){
179

    
180
  cout<<endl<<"Test: TransformToString4:"<<endl;
181
  trans->clearParameters(true);
182
  trans->clearProperties();
183
  XdmNode * input = processor->parseXmlFromString("<out><person>text1</person><person>text2</person><person>text3</person></out>");
184

    
185
  XdmValue * values = new XdmValue();
186
  values->addXdmItem((XdmItem*)processor->makeIntegerValue(10));
187
  values->addXdmItem((XdmItem*)processor->makeIntegerValue(5));
188
  values->addXdmItem((XdmItem*)processor->makeIntegerValue(6));
189
  values->addXdmItem((XdmItem*)processor->makeIntegerValue(7));
190
   
191
   trans->setParameter("values",(XdmValue *)values);
192

    
193
   if(input == NULL) {
194
        cout<<"Source document is null."<<endl;
195

    
196
    }
197

    
198
    trans->setSourceFromXdmNode((XdmNode*)input);
199
    const char * output = trans->transformFileToString(NULL, "test2.xsl");
200
   if(output == NULL) {
201
      printf("result is null \n");
202

    
203
    }else {
204
      printf("%s", output);
205
      printf("result is OK \n");
206
    }
207
      fflush(stdout);
208
    delete output;
209

    
210
}
211

    
212
void testTransformFromstring(SaxonProcessor * processor, XsltProcessor * trans){
213
cout<<endl<<"Test: testTransfromFromstring:"<<endl;
214
  trans->clearParameters(true);
215
  trans->clearProperties();
216
    XdmNode * input = processor->parseXmlFromString("<out><person>text1</person><person>text2</person><person>text3</person></out>");
217

    
218
   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>");
219
trans->setSourceFromXdmNode((XdmNode*)input);
220
 const char * output = trans->transformToString();
221
   if(output == NULL) {
222
      printf("result is null \n");
223

    
224
    }else {
225
      printf("%s", output);
226
      printf("result is OK \n");
227

    
228
    }
229
      fflush(stdout);
230
    delete output;
231

    
232

    
233
}
234

    
235
//Test case has error in the stylesheet
236
void testTransformFromstring2Err(SaxonProcessor * processor, XsltProcessor * trans){
237
cout<<endl<<"Test: testTransfromFromstring2-Error:"<<endl;
238
  trans->clearParameters(true);
239
  trans->clearProperties();
240
    XdmNode * input = processor->parseXmlFromString("<out><person>text1</person><person>text2</person><person>text3</person></out>");
241

    
242
   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>");
243
trans->setSourceFromXdmNode((XdmNode*)input);
244
 const char * output = trans->transformToString();
245
  if(output == NULL) {
246
      printf("result is null \nCheck For errors:\n");
247
      if(trans->exceptionOccurred()) {
248
        cout<<"Error count="<<trans->exceptionOccurred()<<", "<<trans->getErrorMessage()<<endl;
249
     }        
250
    }else {
251
      printf("%s", output);
252
      printf("result is OK \n");
253
    }
254
    fflush(stdout);
255
    delete output;
256

    
257
   trans->exceptionClear();
258

    
259

    
260
}
261

    
262
void testTrackingOfValueReference(SaxonProcessor * processor, XsltProcessor * trans){
263
  trans->clearParameters(true);
264
  trans->clearProperties();
265
 cout<<endl<<"Test: TrackingOfValueReference:"<<endl;
266
ostringstream test;
267
ostringstream valStr;
268
ostringstream name;
269
        for(int i=0; i<10; i++){
270
                test<<"v"<<i;
271
                valStr<<"<out><person>text1</person><person>text2</person><person>text3</person><value>"<<test.str()<<"</value></out>";
272
                name<<"value"<<i;
273
                
274
                XdmValue * values = (XdmValue*)processor->parseXmlFromString(valStr.str().c_str()); 
275
                //cout<<"Name:"<<name.str()<<", Value:"<<values->getHead()->getStringValue()<<endl;
276
                trans->setParameter(name.str().c_str(), values);
277
                test.str("");
278
                valStr.str("");
279
                name.str("");
280
        }
281
        
282
        std::map<std::string,XdmValue*> parMap = trans->getParameters();
283
        if(parMap.size()>0) {
284
cout<<"Parameter size: "<<parMap.size()<<endl;
285
        cout<<"Parameter size: "<<parMap.size()<<endl;//", Value:"<<trans->getParameters()["value0"]->getHead()->getStringValue()<<endl;
286
ostringstream name1;
287
        for(int i =0; i < 10;i++){
288
                name1<<"param:value"<<i;
289
                cout<<" i:"<<i<<" Map size:"<<parMap.size()<<", ";
290
                XdmValue * valuei = parMap[name1.str()];
291
                if(valuei != NULL ){
292
                        cout<<name1.str();
293
                        if(valuei->itemAt(0) != NULL)
294
                                cout<<"= "<<valuei->itemAt(0)->getStringValue();
295
                        cout<<endl;
296
                }
297
                name1.str("");
298
        }
299
        }
300
}
301

    
302
/*Test case should be error.*/
303
void testTrackingOfValueReferenceError(SaxonProcessor * processor, XsltProcessor * trans){
304
  trans->clearParameters(true);
305
  trans->clearProperties();
306
 cout<<endl<<"Test: TrackingOfValueReference-Error:"<<endl;
307
cout<<"Parameter Map size: "<<(trans->getParameters().size())<<endl;
308
ostringstream test;
309
ostringstream valStr;
310
ostringstream name;
311
        for(int i=0; i<10; i++){
312
                test<<"v"<<i;
313
                valStr<<"<out><person>text1</person><person>text2</person><person>text3</person><value>"<<test.str()<<"<value></out>";
314
                name<<"value"<<i;
315
                
316
                XdmValue * values = (XdmValue*)processor->parseXmlFromString(valStr.str().c_str());
317
                trans->setParameter(name.str().c_str(), values);
318
                test.str("");
319
                valStr.str("");
320
                name.str("");
321
        }
322
        std::map<std::string,XdmValue*> parMap = trans->getParameters();
323
cout<<"Parameter Map size: "<<parMap.size()<<endl;
324
        
325
ostringstream name1;
326
        for(int i =0; i < 10;i++){
327
                name1<<"param:value"<<i;
328
                cout<<" i:"<<i<<" Map size:"<<parMap.size()<<", ";
329
                 try {
330
                XdmValue * valuei = parMap.at(name1.str());
331
                if(valuei != NULL ){
332
                        cout<<name1.str();
333
                        if(valuei->itemAt(0) != NULL)
334
                                cout<<"= "<<valuei->itemAt(0)->getStringValue();
335
                        cout<<endl;
336
                }
337
                } catch(const std::out_of_range& oor) {
338
                        cout<< "Out of range exception occurred. Exception no. "<<endl;        
339
                }
340
                name1.str("");
341
        }
342
}
343

    
344

    
345
void testXdmNodeOutput(XsltProcessor * trans){
346
 trans->clearParameters(true);
347
  trans->clearProperties();
348

    
349

    
350
  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>");
351
            trans->setProperty("it","go");
352
            XdmNode * root = (XdmNode*)(trans->transformToValue());
353
             if(root == NULL) {  
354
                             
355
                        cout<<"Result is null"<<endl;
356
                        return;
357
                } 
358
               if(root->getNodeKind() == DOCUMENT){
359
                   cout<<"Result is a Document"<<endl;
360
                } else {
361
                        cout<<"Node is of kind:"<<root->getNodeKind()<<endl;
362
                }
363

    
364
  trans->clearProperties();
365

    
366
}
367

    
368
void exampleSimple1(XsltProcessor  *proc){
369
                cout<<"ExampleSimple1 taken from PHP:"<<endl;
370
                proc->setSourceFromFile("../php/xml/foo.xml");
371
                proc->compileFromFile("../php/xsl/foo.xsl");
372
                        
373
                const char *result = proc->transformToString();               
374
                if(result != NULL) {               
375
                        cout<<result<<endl;
376
                } else {
377
                        cout<<"Result is null"<<endl;
378
                }
379
                proc->clearParameters(true);
380
                proc->clearProperties();            
381
            }
382

    
383
void exampleSimple1Err(XsltProcessor  *proc){
384
                cout<<"ExampleSimple1 taken from PHP:"<<endl;
385
                proc->setSourceFromFile("cat.xml");
386
                proc->compileFromFile("err.xsl");
387
                        
388
                const char *result = proc->transformToString();               
389
                if(result != NULL) {               
390
                        cout<<result<<endl;
391
                } else {
392
                        cout<<"Result is null"<<endl;
393
                }
394
                proc->clearParameters(true);
395
                proc->clearProperties();            
396
            }
397

    
398

    
399
  void exampleSimple2(XsltProcessor  *proc){
400
                cout<<"<b>exampleSimple2:</b><br/>"<<endl;
401
                proc->setSourceFromFile("../php/xml/foo.xml");
402
                proc->compileFromFile("../php/xsl/foo.xsl");
403
                const char * filename = "output1.xml";
404
                proc->setOutputFile(filename);
405
                proc->transformToFile();
406
                                
407
                if (CppTestUtils::exists(filename)) {
408
                    cout<<"The file $filename exists"<<endl;;
409
                } else {
410
                    cout<<"The file $filename does not exist"<<endl;
411
                }
412
                       proc->clearParameters(true);
413
                proc->clearProperties();
414
            }
415

    
416
void exampleSimple3(SaxonProcessor * saxonProc, XsltProcessor  *proc){
417
                cout<<"<b>exampleSimple3:</b><br/>"<<endl;
418
                proc->clearParameters(true);
419
                proc->clearProperties();
420
                XdmNode * xdmNode = saxonProc->parseXmlFromString("<doc><b>text value of out</b></doc>");
421
                if(xdmNode == NULL) {
422
                        cout<<"xdmNode is null'"<<endl;
423
                        return;        
424
                }            
425
                proc->setSourceFromXdmNode((XdmNode*)xdmNode);
426
                cout<<"end of exampleSimple3"<<endl;
427
                proc->clearParameters(true);
428
                proc->clearProperties();
429
}
430

    
431
void exampleParam(SaxonProcessor * saxonProc, XsltProcessor  *proc){
432
                cout<< "\nExampleParam:</b><br/>"<<endl;
433
                proc->setSourceFromFile("../php/xml/foo.xml");
434
                proc->compileFromFile("../php/xsl/foo.xsl");
435
            
436
                XdmAtomicValue * xdmvalue = saxonProc->makeStringValue("Hello to you");
437
                if(xdmvalue !=NULL){
438
                        
439
                        proc->setParameter("a-param", (XdmValue*)xdmvalue);
440
                } else {
441
                        cout<< "Xdmvalue is null"<<endl;
442
                }
443
                const char * result = proc->transformToString();
444
                if(result != NULL) {                
445
                        cout<<"Output:"<<result<<endl;
446
                } else {
447
                        cout<<"Result is NULL<br/>"<<endl;
448
                }
449
               
450
                //proc->clearParameters();                
451
                //unset($result);
452
                //echo 'again with a no parameter value<br/>';
453
                
454
                proc->setProperty("!indent", "yes"); 
455
                const char *result2 = proc->transformToString();
456
               
457
                proc->clearProperties();
458
                if(result2 != NULL) {                
459
                        cout<<result2<<endl;
460
                }
461
               
462
              //  unset($result);
463
               // echo 'again with no parameter and no properties value set. This should fail as no contextItem set<br/>';
464
                XdmAtomicValue * xdmValue2 = saxonProc->makeStringValue("goodbye to you");
465
                proc->setParameter("a-param", (XdmValue*)xdmValue2);
466
                
467
                const char *result3 = proc->transformToString();   
468
                if(result3 != NULL) {             
469
                        cout<<"Output ="<<result3<<endl;
470
                } else {
471
                        cout<<"Error in result"<<endl;
472
                }
473
                proc->clearParameters();
474
                proc->clearProperties(); 
475
                        
476
            }
477

    
478
// test parameter and properties maps where we update key, value pair.
479
void exampleParam2(SaxonProcessor * saxonProc, XsltProcessor  *proc){
480
                cout<< "\nExampleParam:</b><br/>"<<endl;
481
                proc->setSourceFromFile("../php/xml/foo.xml");
482
                proc->compileFromFile("../php/xsl/foo.xsl");
483

    
484
                XdmAtomicValue * xdmvalue = saxonProc->makeStringValue("Hello to you");
485
                XdmAtomicValue * xdmvalue2i = saxonProc->makeStringValue("Hello from me");
486
                if(xdmvalue !=NULL){
487

    
488
                        proc->setParameter("a-param", (XdmValue*)xdmvalue);
489
                        proc->setParameter("a-param", (XdmValue*)xdmvalue2i);
490
                } else {
491
                        cout<< "Xdmvalue is null"<<endl;
492
                }
493
                const char * result = proc->transformToString();
494
                if(result != NULL) {
495
                        cout<<"Output:"<<result<<endl;
496
                } else {
497
                        cout<<"Result is NULL<br/>"<<endl;
498
                }
499

    
500
                //proc->clearParameters();
501
                //unset($result);
502
                //echo 'again with a no parameter value<br/>';
503

    
504
                proc->setProperty("!indent", "no");
505
                proc->setProperty("!indent", "yes");
506
                const char *result2 = proc->transformToString();
507

    
508
                proc->clearProperties();
509
                if(result2 != NULL) {
510
                        cout<<result2<<endl;
511
                }
512

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

    
518
                const char *result3 = proc->transformToString();
519
                if(result3 != NULL) {
520
                        cout<<"Output ="<<result3<<endl;
521
                } else {
522
                        cout<<"Error in result"<<endl;
523
                }
524
                proc->clearParameters();
525
                proc->clearProperties();
526

    
527
            }
528

    
529

    
530
/* XMarkbench mark test q12.xsl with just-in-time=true*/
531
void xmarkTest1(XsltProcessor  *proc){
532
                cout<<"XMarkbench mark test q12.xsl (JIT=true):"<<endl;
533

    
534
        proc->setJustInTimeCompilation(true);
535

    
536
        XdmValue *result = proc->transformFileToValue("xmark100k.xml", "q12.xsl");
537
                if(result != NULL) {
538
                        cout<<"XdmNode returned"<<endl;
539
                } else {
540
                         printf("result is null \nCheck For errors:");
541
             if(proc->exceptionOccurred()) {
542
                    cout<<proc->getErrorMessage()<<endl;
543
             }
544
                }
545
                proc->clearParameters(true);
546
                proc->clearProperties();
547

    
548
 }
549

    
550

    
551

    
552
 /* XMarkbench mark test q12.xsl with just-in-time=true*/
553
 void xmarkTest2(XsltProcessor  *proc){
554
                 cout<<"XMarkbench mark test q12.xsl (JIT=true):"<<endl;
555

    
556

    
557
         XdmValue *result = proc->transformFileToValue("xmark100k.xml", "q12.xsl");
558
                 if(result != NULL) {
559
                         cout<<"XdmNode returned"<<endl;
560
                 } else {
561
                          printf("result is null \nCheck For errors:");
562
              if(proc->exceptionOccurred()) {
563
                     cout<<proc->getErrorMessage()<<endl;
564
              }
565
                 }
566
                 proc->clearParameters(true);
567
                 proc->clearProperties();
568

    
569
  }
570

    
571
/* XMarkbench mark test q12.xsl with just-in-time=true*/
572
void exampleSimple_xmark(XsltProcessor  *proc){
573
                cout<<"XMarkbench mark test q12.xsl:"<<endl;
574

    
575
        proc->setJustInTimeCompilation(true);
576

    
577
        XdmValue *result = proc->transformFileToValue("xmark100k.xml", "q12.xsl");
578
                if(result != NULL) {
579
                        cout<<"XdmNode returned"<<endl;
580
                } else {
581
                         printf("result is null \nCheck For errors:");
582
             if(proc->exceptionOccurred()) {
583
                    cout<<proc->getErrorMessage()<<endl;
584
             }
585
                }
586
                proc->clearParameters(true);
587
                proc->clearProperties();
588

    
589
 }
590

    
591

    
592
/*
593
* Test saving nd loading a Xslt package
594
*/
595
void testPackage1(XsltProcessor * trans){
596

    
597
  cout<<endl<<"Test: Saving and loading Packages:"<<endl;
598
  trans->clearParameters(true);
599
  trans->clearProperties();
600

    
601
    trans->compileFromFileAndSave("test.xsl", "test1.sef");
602
     const char * output = trans->transformFileToString("cat.xml","test1.sef");        
603
   if(output == NULL) {
604
      printf("result is null \n");
605
        const char * message = trans->checkException();
606
        if(message != NULL) {
607
                cout<<"Error message =" << message<< endl;
608
        }
609

    
610
    }else {
611
      printf("%s", output);
612
      printf("result is OK \n");
613
    }
614
      fflush(stdout);
615
    delete output;
616
}
617

    
618

    
619
/*
620
* Test saving and loading a Xslt package
621
*/
622
void testPackage2(XsltProcessor * trans){
623

    
624
  cout<<endl<<"Test: Saving and loading Packages2:"<<endl;
625
  trans->clearParameters(true);
626
  trans->clearProperties();
627

    
628
        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>";
629

    
630
    trans->compileFromStringAndSave(stylesheet, "test2.sef");
631
     const char * output = trans->transformFileToString("cat.xml","test2.sef");        
632
   if(output == NULL) {
633
      printf("result is null \n");
634
        const char * message = trans->checkException();
635
        if(message != NULL) {
636
                cout<<"Error message =" << message<< endl;
637
        }
638
    }else {
639
      printf("%s", output);
640
      printf("result is OK \n");
641
    }
642
      fflush(stdout);
643
    delete output;
644
}
645

    
646

    
647

    
648
int main()
649
{
650
SaxonProcessor::jvmCreatedCPP = 1;
651

    
652
    SaxonProcessor * processor = new SaxonProcessor(true);
653
    cout<<"Test: XsltProcessor with Saxon version="<<processor->version()<<endl<<endl; 
654
    //processor->setcwd("/home");
655
   processor->setConfigurationProperty("http://saxon.sf.net/feature/generateByteCode","false");
656

    
657
  
658
    XsltProcessor * trans = processor->newXsltProcessor();
659
   exampleSimple1Err(trans);
660
    exampleSimple1(trans);
661
    exampleSimple_xmark(trans);
662
    exampleSimple2(trans);
663
    exampleSimple3(processor, trans);
664

    
665
    testTransformToString1(trans);
666

    
667
    testTransformToString2(processor, trans);
668

    
669
    testTransformToString2a(processor, trans);
670

    
671
    testTransformToString2b(processor, trans);
672

    
673
    testTransformToString3(processor, trans);
674
        
675
    testTransformToString4(processor, trans);
676

    
677
    testTransformFromstring(processor, trans);
678

    
679
    testTransformFromstring2Err(processor, trans);
680

    
681
    testTrackingOfValueReference(processor, trans);
682

    
683
    testTrackingOfValueReferenceError(processor, trans);
684

    
685
    testPackage1(trans);
686

    
687
   testPackage2(trans);
688

    
689
    testXdmNodeOutput(trans);
690

    
691
    exampleParam(processor, trans);
692

    
693
    exampleParam2(processor, trans);
694

    
695
    xmarkTest1(trans);
696

    
697
    xmarkTest2(trans);
698

    
699

    
700
    delete trans;
701
delete processor;
702
    // processor->release();
703
SaxonProcessor::jvmCreatedCPP = 1;
704

    
705
 SaxonProcessor * processor2 = new SaxonProcessor(true);
706
    cout<<"Test2: XsltProcessor with Saxon version="<<processor2->version()<<endl<<endl; 
707
    //processor->setcwd("/home");
708
    
709

    
710
    XsltProcessor * trans2 = processor2->newXsltProcessor();
711
testTransformToString1(trans2);
712
  delete trans2;
713
     processor2->release();
714

    
715
    return 0;
716
}
(26-26/28)