Project

Profile

Help

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

he / src / main / c / Saxon.C.API / XsltExecutable.cpp @ 85a9912e

1
// XsltExecutable.cpp : Defines the exported functions for the DLL application.
2
//
3

    
4
#include "XsltExecutable.h"
5
#include "XdmValue.h"
6
#include "XdmItem.h"
7
#include "XdmNode.h"
8
#include "XdmFunctionItem.h"
9
#include "XdmMap.h"
10
#include "XdmArray.h"
11
#include "XdmAtomicValue.h"
12

    
13
#ifdef DEBUG
14
#include <typeinfo> //used for testing only
15
#endif
16

    
17

    
18
XsltExecutable::XsltExecutable(jobject exObject, std::string curr) {
19

    
20

    
21

    
22
    /*
23
     * Look for class.
24
     */
25
    cppClass = lookForClass(SaxonProcessor::sxn_environ->env,
26
                            "net/sf/saxon/option/cpp/Xslt30Processor");
27

    
28
    messageListenerClass = lookForClass(SaxonProcessor::sxn_environ->env,
29
                                               "net/sf/saxon/option/cpp/SaxonCMessageListener");
30

    
31
#ifdef DEBUG
32
    jmethodID debugMID = SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
33
    SaxonProcessor::sxn_environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
34

    
35
#endif
36
    tunnel = false;
37
    selection = nullptr;
38
    selectionV = nullptr;
39
    saxonMessageListenerObj = nullptr;
40
    executableObject = exObject;
41
    cwdXE = curr;
42
}
43

    
44
XsltExecutable::~XsltExecutable() {
45
    clearProperties();
46
    clearParameters();
47

    
48
    if(selection) {
49
        SaxonProcessor::sxn_environ->env->DeleteGlobalRef(selection);
50
        selection = nullptr;
51
    }
52

    
53
    SaxonProcessor::sxn_environ->env->DeleteGlobalRef(executableObject);
54

    
55
}
56

    
57

    
58
XsltExecutable::XsltExecutable(const XsltExecutable &other) {
59

    
60
    /*
61
     * Look for class.
62
     */
63
    cppClass = lookForClass(SaxonProcessor::sxn_environ->env,
64
                            "net/sf/saxon/option/cpp/Xslt30Processor");
65

    
66
    executableObject = other.executableObject;
67
    selectionV = other.selectionV;
68
    if (selectionV != nullptr) {
69
        setInitialMatchSelection(other.selectionV);
70
    } else {
71
        selection = other.selection;
72
    }
73
    tunnel = other.tunnel;
74

    
75
    std::map<std::string, XdmValue *>::const_iterator paramIter = other.parameters.begin();
76
    while (paramIter != other.parameters.end()) {
77

    
78
        XdmValue *valuei = paramIter->second;
79
        if (valuei == nullptr) {
80
            std::cerr << "Error in XsltExecutable copy constructor - parameter value is NULL" << std::endl;
81
        } else {
82
            parameters[paramIter->first] = new XdmValue(*(valuei));
83
        }
84
        paramIter++;
85
    }
86

    
87
    std::map<std::string, std::string>::const_iterator propIter = other.properties.begin();
88
    while (propIter != other.properties.end()) {
89
        properties[propIter->first] = propIter->second;
90
        propIter++;
91
    }
92

    
93
}
94

    
95

    
96
bool XsltExecutable::exceptionOccurred() {
97
    return SaxonProcessor::sxn_environ->env->ExceptionCheck();
98
}
99

    
100
const char *XsltExecutable::getErrorCode() {
101
    SaxonApiException *exception = SaxonProcessor::checkForExceptionCPP(SaxonProcessor::sxn_environ->env, cppClass,
102
                                                                        nullptr);
103
    if (exception == nullptr) { return nullptr; }
104
    return exception->getErrorCode();
105
}
106

    
107

    
108
void XsltExecutable::setGlobalContextItem(XdmItem *value) {
109
    if (value != nullptr) {
110
        value->incrementRefCount();
111
        parameters["node"] = value;
112
    }
113
}
114

    
115
void XsltExecutable::setGlobalContextFromFile(const char *ifile) {
116
    if (ifile != nullptr) {
117
        setProperty("s", ifile);
118
    }
119
}
120

    
121
void XsltExecutable::setInitialMatchSelection(XdmValue *_selection) {
122
    if (_selection != nullptr) {
123
        _selection->incrementRefCount();
124
        selectionV = _selection;
125
        selection = SaxonProcessor::sxn_environ->env->NewGlobalRef(_selection->getUnderlyingValue());
126
    }
127
}
128

    
129

    
130
void XsltExecutable::setInitialMatchSelectionAsFile(const char *filename) {
131
    if (filename != nullptr) {
132
        selection = SaxonProcessor::sxn_environ->env->NewGlobalRef(SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
133

    
134
    }
135
}
136

    
137
void XsltExecutable::setOutputFile(const char *ofile) {
138
    setProperty("o", ofile);
139
}
140

    
141
void XsltExecutable::setBaseOutputURI(const char *baseURI) {
142
    if (baseURI != nullptr) {
143
        setProperty("baseoutput", baseURI);
144
    }
145
}
146

    
147

    
148
void XsltExecutable::setParameter(const char *name, XdmValue *value) {
149
    if (value != nullptr && name != nullptr) {
150
        value->incrementRefCount();
151
        int s = parameters.size();
152
        std::string skey = "param:" + std::string(name);
153
        parameters[skey] = value;
154
        if (s == parameters.size()) {
155
            std::map<std::string, XdmValue *>::iterator it;
156
            it = parameters.find(skey);
157
            if (it != parameters.end()) {
158
                XdmValue *valuei = it->second;
159
                if(valuei != nullptr) {
160
                    valuei->decrementRefCount();
161
                    if (valuei->getRefCount() < 1) {
162
                        delete value;
163
                    }
164
                    parameters.erase(skey);
165
                    parameters[skey] = value;
166
                }
167
            }
168
        }
169
    }
170
}
171

    
172
void XsltExecutable::setInitialTemplateParameters(std::map<std::string, XdmValue *> _itparameters, bool _tunnel) {
173
    for (std::map<std::string, XdmValue *>::iterator itr = _itparameters.begin(); itr != _itparameters.end(); itr++) {
174
        parameters["itparam:" + std::string(itr->first)] = itr->second;
175
        itr->second->incrementRefCount();
176
    }
177
    tunnel = _tunnel;
178
    if (tunnel) {
179
        setProperty("tunnel", "true");
180
    }
181
}
182

    
183
XdmValue *XsltExecutable::getParameter(const char *name) {
184
    std::map<std::string, XdmValue *>::iterator it;
185
    it = parameters.find("param:" + std::string(name));
186
    if (it != parameters.end())
187
        return it->second;
188
    else {
189
        it = parameters.find("sparam:" + std::string(name));
190
        if (it != parameters.end())
191
            return it->second;
192
    }
193
    return nullptr;
194
}
195

    
196
bool XsltExecutable::removeParameter(const char *name) {
197
    return (bool) (parameters.erase("param:" + std::string(name)));
198
}
199

    
200

    
201
void XsltExecutable::setResultAsRawValue(bool option) {
202
    if (option) {
203
        setProperty("outvalue", "yes");
204
    }
205
}
206

    
207
XsltExecutable * XsltExecutable::clone() {
208
    XsltExecutable * executable = new XsltExecutable(*this);
209
    return executable;
210

    
211
}
212

    
213
void XsltExecutable::setProperty(const char *name, const char *value) {
214
    if (name != nullptr) {
215
        int s = properties.size();
216

    
217
        std::string skey = std::string(name);
218
        properties.insert(std::pair<std::string, std::string>(skey, std::string((value == nullptr ? "" : value))));
219

    
220
        if (s == properties.size()) {
221
            std::map<std::string, std::string>::iterator it;
222
            it = properties.find(skey);
223
            if (it != properties.end()) {
224
                properties.erase(skey);
225
                properties[skey] = std::string((value == nullptr ? "" : value));
226
            }
227
        }
228
    }
229
}
230

    
231
const char *XsltExecutable::getProperty(const char *name) {
232
    std::map<std::string, std::string>::iterator it;
233
    it = properties.find(std::string(name));
234
    if (it != properties.end())
235
        return it->second.c_str();
236
    return nullptr;
237
}
238

    
239
void XsltExecutable::clearParameters(bool delValues) {
240
    if (delValues) {
241
        for (std::map<std::string, XdmValue *>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
242

    
243
            XdmValue *value = itr->second;
244
            if(value != nullptr) {
245
                value->decrementRefCount();
246
#ifdef DEBUG
247
                std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
248
#endif
249
                if (value->getRefCount() < 1) {
250
                    delete value;
251
                }
252
            }
253
        }
254

    
255

    
256
    } else {
257
        for (std::map<std::string, XdmValue *>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
258
            parameters.erase(itr);
259
            /*if(value != NULL) {
260
                value->decrementRefCount();
261
            }*/
262

    
263
        }
264

    
265
    }
266
    parameters.clear();
267

    
268
}
269

    
270
void XsltExecutable::clearProperties() {
271
    properties.clear();
272

    
273
}
274

    
275

    
276
std::map<std::string, XdmValue *> &XsltExecutable::getParameters() {
277
    std::map<std::string, XdmValue *> &ptr = parameters;
278
    return ptr;
279
}
280

    
281
std::map<std::string, std::string> &XsltExecutable::getProperties() {
282
    std::map<std::string, std::string> &ptr = properties;
283
    return ptr;
284
}
285

    
286
void XsltExecutable::exceptionClear() {
287
    SaxonProcessor::sxn_environ->env->ExceptionClear();
288
}
289

    
290
void XsltExecutable::setcwd(const char *dir) {
291
    if (dir != nullptr) {
292
        cwdXE = std::string(dir);
293
    }
294
}
295

    
296

    
297
void XsltExecutable::exportStylesheet(const char *filename) {
298

    
299

    
300
    static jmethodID exportmID = nullptr;
301

    
302
    if (!exportmID) {
303
        exportmID = SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass, "save",
304
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;)V");
305
    }
306

    
307
    if (filename == nullptr) {
308
        std::cerr << "Error: Error: export file name is nullptr" << std::endl;
309
        return;
310
    }
311
    SaxonProcessor::sxn_environ->env->CallStaticVoidMethod(cppClass, exportmID,
312
                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(
313
                                                                   cwdXE.c_str()),
314
                                                           executableObject,
315
                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
316

    
317
}
318

    
319
void XsltExecutable::applyTemplatesReturningFile(const char *output_filename) {
320

    
321
    if (selection == nullptr) {
322
        std::cerr
323
                << "Error: The initial match selection has not been set. Please set it using setInitialMatchSelection or setInitialMatchSelectionFile."
324
                << std::endl;
325
        return;
326
    }
327

    
328
    static jmethodID atmID = nullptr;
329

    
330
    if (atmID == nullptr) {
331
        atmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
332
                                                                        "applyTemplatesReturningFile",
333
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
334
    }
335

    
336
    if (!atmID) {
337
        std::cerr << "Error: " << getDllname() << ".applyTemplatesReturningFile" << " not found\n"
338
                  << std::endl;
339

    
340
    } else {
341
        JParameters comboArrays;
342
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
343
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atmID,
344
                                                                 SaxonProcessor::sxn_environ->env->NewStringUTF(
345
                                                                         cwdXE.c_str()), executableObject, selection,
346
                                                                 (output_filename != nullptr
347
                                                                  ? SaxonProcessor::sxn_environ->env->NewStringUTF(
348
                                                                                 output_filename) : nullptr),
349
                                                                 comboArrays.stringArray, comboArrays.objectArray);
350
        if (comboArrays.stringArray != nullptr) {
351
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
352
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
353
        }
354

    
355
    }
356
    return;
357

    
358
}
359

    
360
const char *XsltExecutable::applyTemplatesReturningString() {
361

    
362
    if (selection == nullptr) {
363
        std::cerr
364
                << "Error: The initial match selection has not been set. Please set it using setInitialMatchSelection or setInitialMatchSelectionFile."
365
                << std::endl;
366
        return nullptr;
367
    }
368

    
369

    
370
    static jmethodID atsmID = nullptr;
371

    
372
    if (atsmID == nullptr) {
373
        atsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
374
                                                                             "applyTemplatesReturningString",
375
                                                                             "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)[B");
376
    }
377
    if (!atsmID) {
378
        std::cerr << "Error: " << getDllname() << "applyTemplatesAsString" << " not found\n"
379
                  << std::endl;
380

    
381
    } else {
382
        JParameters comboArrays;
383
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
384

    
385
        jbyteArray result = nullptr;
386
        jobject obj = (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atsmID,
387
                                                                                SaxonProcessor::sxn_environ->env->NewStringUTF(
388
                                                                                        cwdXE.c_str()), executableObject,selection,
389
                comboArrays.stringArray, comboArrays.objectArray));
390

    
391
        if (obj) {
392
            result = (jbyteArray) obj;
393
        }
394
        if (comboArrays.stringArray != nullptr) {
395
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
396
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
397
        }
398
        if (result) {
399
            jboolean isCopy = false;
400
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
401
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
402

    
403
            const char *str = new char[num_bytes];
404
            memcpy ((void *) str, b , num_bytes );
405

    
406
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
407
            return str;
408
        }
409
    }
410
    return nullptr;
411

    
412

    
413
}
414

    
415
XdmValue *XsltExecutable::applyTemplatesReturningValue() {
416

    
417
    if (selection == nullptr) {
418
        std::cerr
419
                << "Error: The initial match selection has not been set. Please set it using setInitialMatchSelection or setInitialMatchSelectionFile."
420
                << std::endl;
421
        return nullptr;
422
    }
423

    
424

    
425
    static jmethodID atsvmID = nullptr;
426
    if (atsvmID == nullptr) {
427
        atsvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
428
                                                                                 "applyTemplatesReturningValue",
429
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
430
    }
431
    if (!atsvmID) {
432
        std::cerr << "Error: " << getDllname() << "applyTemplatesAsValue" << " not found\n"
433
                  << std::endl;
434

    
435
    } else {
436
        JParameters comboArrays;
437
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
438

    
439

    
440
        // jstring result = nullptr;
441
        jobject result = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atsvmID,
442
                                                                                             SaxonProcessor::sxn_environ->env->NewStringUTF(
443
                                                                                                     cwdXE.c_str()),
444
                                                                                             executableObject,
445
                                                                                             selection,
446
                                                                                             comboArrays.stringArray,
447
                                                                                             comboArrays.objectArray));
448
        /*if(obj) {
449
            result = (jobject)obj;
450
        }*/
451
        if (comboArrays.stringArray != nullptr) {
452
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
453
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
454
        }
455
        if (result) {
456
            jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env,
457
                                                   "net/sf/saxon/s9api/XdmAtomicValue");
458
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
459
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
460
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
461
            XdmValue *value = nullptr;
462
            XdmItem *xdmItem = nullptr;
463

    
464

    
465
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
466
                xdmItem = new XdmAtomicValue(result);
467

    
468
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
469
                return xdmItem;
470

    
471
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
472
                xdmItem = new XdmNode(result);
473
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
474
                return xdmItem;
475
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
476
                xdmItem = new XdmFunctionItem(result);
477
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
478
                return xdmItem;
479
            } else {
480
                value = new XdmValue(result, true);
481
                for (int z = 0; z < value->size(); z++) {
482
                }
483
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
484
                return value;
485
            }
486
        }
487
    }
488
    return nullptr;
489

    
490
}
491

    
492

    
493
void XsltExecutable::callFunctionReturningFile(const char *functionName, XdmValue **arguments, int argument_length,
494
                                               const char *outfile) {
495

    
496

    
497
    static jmethodID afmID = nullptr;
498

    
499
    if (afmID == nullptr) {
500
        afmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
501
                                                                                "callFunctionReturningFile",
502
                                                                                "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)V");
503
    }
504

    
505
    if (!afmID) {
506
        std::cerr << "Error: " << getDllname() << "callFunctionReturningFile" << " not found\n"
507
                  << std::endl;
508
        return;
509
    } else {
510
        JParameters comboArrays;
511
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
512

    
513
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
514

    
515
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, afmID,
516
                                                                 SaxonProcessor::sxn_environ->env->NewStringUTF(
517
                                                                         cwdXE.c_str()),
518
                                                                 executableObject,
519
                                                                 (functionName != nullptr ?
520
                                                                  SaxonProcessor::sxn_environ->env->NewStringUTF(
521
                                                                          functionName) :
522
                                                                  nullptr), argumentJArray,
523
                                                                 (outfile != nullptr ?
524
                                                                  SaxonProcessor::sxn_environ->env->NewStringUTF(
525
                                                                          outfile) :
526
                                                                  nullptr),
527
                                                                 comboArrays.stringArray, comboArrays.objectArray);
528
        if (comboArrays.stringArray != nullptr) {
529
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
530
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
531
        }
532
        if (argumentJArray != nullptr) {
533
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(argumentJArray);
534
        }
535

    
536
    }
537
    return;
538

    
539

    
540
}
541

    
542
const char *
543
XsltExecutable::callFunctionReturningString(const char *functionName, XdmValue **arguments, int argument_length) {
544

    
545

    
546
    static jmethodID afsmID = nullptr;
547

    
548
    if(afsmID == nullptr) {
549
        (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
550
                                                                        "callFunctionReturningString",
551
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)[B");
552
    }
553
    if (!afsmID) {
554
        std::cerr << "Error: " << getDllname() << "callFunctionReturningString" << " not found\n"
555
                  << std::endl;
556

    
557
    } else {
558
        JParameters comboArrays;
559
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
560
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
561

    
562
        jbyteArray result = nullptr;
563
        jobject obj = (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, afsmID,
564
                                                                                SaxonProcessor::sxn_environ->env->NewStringUTF(
565
                                                                                        cwdXE.c_str()), executableObject,
566
                                                                                        (functionName != nullptr
567
                                                                                         ? SaxonProcessor::sxn_environ->env->NewStringUTF(
568
                                                                                                        functionName)
569
                                                                                         : nullptr),
570
                                                                                argumentJArray, comboArrays.stringArray,
571
                                                                                comboArrays.objectArray));
572
        if (obj) {
573
            result = (jbyteArray) obj;
574
        }
575
        if (comboArrays.stringArray != nullptr) {
576
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
577
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
578
        }
579
        if (result) {
580
            jboolean isCopy = false;
581
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
582
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
583

    
584
            const char *str = new char[num_bytes];
585
            memcpy ((void *) str, b , num_bytes );
586

    
587
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
588
            return str;
589
        }
590
    }
591
    return nullptr;
592
}
593

    
594

    
595
XdmValue *
596
XsltExecutable::callFunctionReturningValue(const char *functionName, XdmValue **arguments, int argument_length) {
597

    
598

    
599
    static jmethodID cfvmID = nullptr;
600
    if (cfvmID == nullptr) {
601
        cfvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
602
                                                                                 "callFunctionReturningValue",
603
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
604
    }
605
    if (!cfvmID) {
606
        std::cerr << "Error: " << getDllname() << "callFunctionReturningValue" << " not found\n"
607
                  << std::endl;
608

    
609
    } else {
610
        JParameters comboArrays;
611
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
612
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
613

    
614
        jobject result = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, cfvmID,
615
                                                                                             SaxonProcessor::sxn_environ->env->NewStringUTF(
616
                                                                                                     cwdXE.c_str()),
617
                                                                                             executableObject,
618
                                                                                             (functionName != nullptr
619
                                                                                              ? SaxonProcessor::sxn_environ->env->NewStringUTF(
620
                                                                                                             functionName)
621
                                                                                              : nullptr),
622
                                                                                             argumentJArray,
623
                                                                                             comboArrays.stringArray,
624
                                                                                             comboArrays.objectArray));
625

    
626
        if (comboArrays.stringArray != nullptr) {
627
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
628
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
629
        }
630
        if (argumentJArray != nullptr) {
631
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(argumentJArray);
632
        }
633
        if (result) {
634
            jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env,
635
                                                   "net/sf/saxon/s9api/XdmAtomicValue");
636
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
637
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
638
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
639
            XdmValue *value = nullptr;
640
            XdmItem *xdmItem = nullptr;
641

    
642

    
643
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
644
                xdmItem = new XdmAtomicValue(result);
645
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
646
                return xdmItem;
647
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
648
                xdmItem = new XdmNode(result);
649
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
650
                return xdmItem;
651

    
652
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
653
                xdmItem = new XdmFunctionItem(result);
654
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
655
                return xdmItem;
656
            } else {
657
                value = new XdmValue(result, true);
658
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
659
                return value;
660
            }
661
            value = new XdmValue();
662
            value->addUnderlyingValue(result);
663
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
664
            return value;
665
        }
666
    }
667
    return nullptr;
668

    
669
}
670

    
671

    
672
void XsltExecutable::callTemplateReturningFile(const char *templateName, const char *outfile) {
673

    
674

    
675
    static jmethodID ctmID = nullptr;
676

    
677
    if(ctmID == nullptr) {
678
        ctmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
679
                                                                        "callTemplateReturningFile",
680
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
681
    }
682
    if (!ctmID) {
683
        std::cerr << "Error: " << getDllname() << "callTemplateReturningFile" << " not found\n"
684
                  << std::endl;
685

    
686
    } else {
687
        JParameters comboArrays;
688
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
689
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctmID,
690
                                                                 SaxonProcessor::sxn_environ->env->NewStringUTF(
691
                                                                         cwdXE.c_str()),
692
                                                                 executableObject,
693
                                                                 (templateName != nullptr
694
                                                                  ? SaxonProcessor::sxn_environ->env->NewStringUTF(
695
                                                                                 templateName) : nullptr),
696
                                                                 (outfile != nullptr
697
                                                                  ? SaxonProcessor::sxn_environ->env->NewStringUTF(
698
                                                                                 outfile) : nullptr),
699
                                                                 comboArrays.stringArray, comboArrays.objectArray);
700
        if (comboArrays.stringArray != nullptr) {
701
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
702
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
703
        }
704

    
705

    
706
    }
707

    
708
}
709

    
710

    
711
const char *XsltExecutable::callTemplateReturningString(const char *templateName) {
712

    
713

    
714
    jmethodID ctsmID = nullptr;
715

    
716
    if(ctsmID == nullptr) {
717
        ctsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
718
                                                                        "callTemplateReturningString",
719
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)[B");
720
    }
721
    if (!ctsmID) {
722
        std::cerr << "Error: " << getDllname() << "callTemplateReturningString" << " not found\n"
723
                  << std::endl;
724

    
725
    } else {
726
        JParameters comboArrays;
727
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
728

    
729

    
730
        jbyteArray result = nullptr;
731
        jobject obj = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctsmID,
732
                                                                                          SaxonProcessor::sxn_environ->env->NewStringUTF(
733
                                                                                                  cwdXE.c_str()),
734
                                                                                          executableObject,
735
                                                                                          (templateName != nullptr
736
                                                                                           ? SaxonProcessor::sxn_environ->env->NewStringUTF(
737
                                                                                                          templateName)
738
                                                                                           : nullptr),
739
                                                                                          comboArrays.stringArray,
740
                                                                                          comboArrays.objectArray));
741
        if (obj) {
742
            result = (jbyteArray) obj;
743
        }
744
        if (comboArrays.stringArray != nullptr) {
745
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
746
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
747
        }
748
        if (result) {
749
            jboolean isCopy = false;
750
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
751
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
752

    
753
            const char *str = new char[num_bytes];
754
            memcpy ((void *) str, b , num_bytes );
755

    
756
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
757
            return str;
758
        }
759
    }
760
    return nullptr;
761

    
762

    
763
}
764

    
765
XdmValue *XsltExecutable::callTemplateReturningValue(const char *templateName) {
766

    
767

    
768
    static jmethodID ctsvmID = nullptr;
769
    if (ctsvmID == nullptr) {
770
        ctsvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
771
                                                                                 "callTemplateReturningValue",
772
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
773
    }
774
    if (!ctsvmID) {
775
        std::cerr << "Error: " << getDllname() << "callTemplateReturningValue" << " not found\n"
776
                  << std::endl;
777

    
778
    } else {
779
        JParameters comboArrays;
780
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
781

    
782

    
783
        jstring result = nullptr;
784
        jobject obj = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctsvmID,
785
                                                                                          SaxonProcessor::sxn_environ->env->NewStringUTF(
786
                                                                                                  cwdXE.c_str()),
787
                                                                                          executableObject,
788
                                                                                          (templateName != nullptr
789
                                                                                           ? SaxonProcessor::sxn_environ->env->NewStringUTF(
790
                                                                                                          templateName)
791
                                                                                           : nullptr),
792
                                                                                          comboArrays.stringArray,
793
                                                                                          comboArrays.objectArray));
794
        if (obj) {
795
            result = (jstring) obj;
796
        }
797
        if (comboArrays.stringArray != nullptr) {
798
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
799
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
800
        }
801
        if (result) {
802
            jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env,
803
                                                   "net/sf/saxon/s9api/XdmAtomicValue");
804
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
805
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
806
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
807
            XdmValue *value = nullptr;
808

    
809
            XdmItem *xdmItem = nullptr;
810
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
811
                xdmItem = new XdmAtomicValue(result);
812
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
813
                return xdmItem;
814

    
815
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
816
                xdmItem = new XdmNode(result);
817
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
818
                return xdmItem;
819
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
820
                xdmItem = new XdmFunctionItem(result);
821
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
822
                return xdmItem;
823
            } else {
824
                value = new XdmValue(result, true);
825
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
826
                return value;
827
            }
828
            value = new XdmValue();
829
            value->addUnderlyingValue(result);
830
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
831
            return value;
832
        }
833
    }
834
    return nullptr;
835
}
836

    
837

    
838
XdmValue *XsltExecutable::transformFileToValue(const char *sourcefile) {
839

    
840
    if (sourcefile == nullptr) {
841

    
842
        return nullptr;
843
    }
844

    
845

    
846
    static jmethodID tfvMID = nullptr;
847

    
848
    if (tfvMID == nullptr) {
849
        tfvMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
850
                                                                                 "transformToValue",
851
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/option/cpp/Xslt30Processor;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
852
    }
853
    if (!tfvMID) {
854
        std::cerr << "Error: " << getDllname() << ".transformtoValue" << " not found\n"
855
                  << std::endl;
856

    
857
    } else {
858
        JParameters comboArrays;
859
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
860

    
861
        jobject result = (jobject) (
862
                SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, tfvMID,
863
                                                                         SaxonProcessor::sxn_environ->env->NewStringUTF(
864
                                                                                 cwdXE.c_str()), nullptr, executableObject,
865
                                                                         (sourcefile != nullptr
866
                                                                          ? SaxonProcessor::sxn_environ->env->NewStringUTF(
867
                                                                                         sourcefile) : nullptr),
868
                                                                         comboArrays.stringArray,
869
                                                                         comboArrays.objectArray));
870
        if (comboArrays.stringArray != nullptr) {
871
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
872
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
873
        }
874
        if (result) {
875
            jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env,
876
                                                   "net/sf/saxon/s9api/XdmAtomicValue");
877
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
878
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
879
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
880
            jclass mapItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
881
                                                    "net/sf/saxon/s9api/XdmMap");
882
            jclass arrayItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
883
                                               "net/sf/saxon/s9api/XdmArray");
884
            XdmValue *value = nullptr;
885
            XdmItem *xdmItem = nullptr;
886

    
887

    
888
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
889
                xdmItem = new XdmAtomicValue(result);
890
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
891
                return xdmItem;
892

    
893
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
894
                xdmItem = new XdmNode(result);
895
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
896
                return xdmItem;
897

    
898
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
899
                xdmItem = new XdmFunctionItem(result);
900
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
901
                return xdmItem;
902
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, mapItemClass) == JNI_TRUE) {
903
                xdmItem = new XdmMap(result);
904
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
905
                return xdmItem;
906
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, arrayItemClass) == JNI_TRUE) {
907
                xdmItem = new XdmArray(result);
908
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
909
                return xdmItem;
910
            } else {
911
                value = new XdmValue(result, true);
912
                return value;
913
            }
914
            value = new XdmValue();
915
            value->addUnderlyingValue(result);
916

    
917
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
918
            return value;
919
        }
920
    }
921
    return nullptr;
922

    
923
}
924

    
925

    
926
void XsltExecutable::transformFileToFile(const char *source, const char *outputfile) {
927

    
928

    
929
    static jmethodID tffMID = nullptr;
930

    
931
    if (tffMID == nullptr) {
932
        tffMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
933
                                                                                 "transformToFile",
934
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/option/cpp/Xslt30Processor;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
935
    }
936
    if (!tffMID) {
937
        std::cerr << "Error: " << getDllname() << "transformToFile" << " not found\n"
938
                  << std::endl;
939

    
940
    } else {
941
        JParameters comboArrays;
942
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
943

    
944
        SaxonProcessor::sxn_environ->env->CallStaticVoidMethod(cppClass, tffMID,
945
                                                               SaxonProcessor::sxn_environ->env->NewStringUTF(
946
                                                                       cwdXE.c_str()), nullptr, executableObject,
947
                                                                       (source != nullptr
948
                                                                        ? SaxonProcessor::sxn_environ->env->NewStringUTF(
949
                                                                                       source) : nullptr), nullptr,
950
                                                               (outputfile != nullptr
951
                                                                ? SaxonProcessor::sxn_environ->env->NewStringUTF(
952
                                                                               outputfile) : nullptr),
953
                                                               comboArrays.stringArray, comboArrays.objectArray);
954
        if (comboArrays.stringArray != nullptr) {
955
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
956
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
957
        }
958
    }
959

    
960
}
961

    
962

    
963
void XsltExecutable::setupXslMessage(bool create, const char * filename) {
964
    if (create) {
965

    
966
        static jmethodID messageID =   nullptr;
967
        if(messageID == nullptr) {
968
            messageID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(messageListenerClass,
969
                                                                                  "<init>",
970
                                                                                  "(Ljava/lang/String;Ljava/lang/String;)V");
971
        }
972
        if (!messageID) {
973
            std::cerr << "Error: "<<"SaxonCMessageListener" << " in " <<getDllname() << " not found\n"
974
                      << std::endl;
975

    
976
        }
977

    
978
        if (filename == nullptr) {
979
            saxonMessageListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
980
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF("-:on"));
981
            //setProperty("m", "on");
982
        } else {
983
            saxonMessageListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
984
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
985
        }
986
    } else {
987
        setProperty("m", "off");
988
    }
989

    
990

    
991
}
992

    
993
XdmValue * XsltExecutable::getXslMessages(){
994

    
995
    if(saxonMessageListenerObj) {
996
        static jmethodID getmessageID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(messageListenerClass,
997
                                                                                                  "getXslMessages",
998
                                                                                                  "()[Lnet/sf/saxon/s9api/XdmNode;");
999
        if (!getmessageID) {
1000
            std::cerr << "Error: " << getDllname() << ".getXslMessages" << " not found\n"
1001
                      << std::endl;
1002

    
1003
        } else {
1004
            jobjectArray results = (jobjectArray) (
1005
                    SaxonProcessor::sxn_environ->env->CallObjectMethod(saxonMessageListenerObj, getmessageID));
1006
            int sizex = SaxonProcessor::sxn_environ->env->GetArrayLength(results);
1007

    
1008
            if (sizex > 0) {
1009
                XdmValue *value = new XdmValue();
1010

    
1011
                for (int p = 0; p < sizex; ++p) {
1012
                    jobject resulti = SaxonProcessor::sxn_environ->env->GetObjectArrayElement(results, p);
1013
                    value->addUnderlyingValue(resulti);
1014
                }
1015
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(results);
1016
                return value;
1017
            }
1018
        }
1019
    }
1020
    return NULL;
1021

    
1022

    
1023
}
1024

    
1025

    
1026
const char *XsltExecutable::transformFileToString(const char *source) {
1027

    
1028

    
1029
    static jmethodID tftMID = tftMID;
1030
    if (tftMID == nullptr) {
1031
        tftMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
1032
                                                                                 "transformToString",
1033
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/option/cpp/Xslt30Processor;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)[B");
1034
    }
1035
    if (!tftMID) {
1036
        std::cerr << "Error: " << getDllname() << "transformToString" << " not found\n"
1037
                  << std::endl;
1038

    
1039
    } else {
1040
        JParameters comboArrays;
1041
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
1042

    
1043
        jbyteArray result = nullptr;
1044
        jobject obj = SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, tftMID,
1045
                                                                               SaxonProcessor::sxn_environ->env->NewStringUTF(
1046
                                                                                       cwdXE.c_str()), nullptr,
1047
                                                                               executableObject,
1048
                                                                               (source != nullptr
1049
                                                                                ? SaxonProcessor::sxn_environ->env->NewStringUTF(
1050
                                                                                               source) : nullptr),
1051
                                                                               nullptr,
1052
                                                                               comboArrays.stringArray,
1053
                                                                               comboArrays.objectArray);
1054
        if (comboArrays.stringArray != nullptr) {
1055
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
1056
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
1057
        }
1058
        if (obj) {
1059
            result = (jbyteArray) obj;
1060
        }
1061
        if (result) {
1062

    
1063
            jboolean isCopy = false;
1064
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
1065
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
1066

    
1067
            const char *str = new char[num_bytes];
1068
            memcpy ((void *) str, b , num_bytes );
1069

    
1070
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
1071
            return str;
1072
        }
1073
    }
1074
    return nullptr;
1075
}
1076

    
1077

    
1078
const char *XsltExecutable::transformToString(XdmNode *source) {
1079

    
1080
    if (source != nullptr) {
1081
        source->incrementRefCount();
1082
        parameters["node"] = source;
1083
    }
1084
    return transformFileToString(nullptr);
1085
}
1086

    
1087

    
1088
XdmValue *XsltExecutable::transformToValue(XdmNode *source) {
1089

    
1090
    if (source != nullptr) {
1091
        source->incrementRefCount();
1092
        parameters["node"] = source;
1093
    }
1094
    return transformFileToValue(nullptr);
1095
}
1096

    
1097
void XsltExecutable::transformToFile(XdmNode *source) {
1098

    
1099
    if (source != nullptr) {
1100
        source->incrementRefCount();
1101
        parameters["node"] = source;
1102
    }
1103
    transformFileToFile(nullptr, nullptr);
1104
}
1105

    
1106
const char *XsltExecutable::getErrorMessage() {
1107
    SaxonApiException *exception = SaxonProcessor::checkForExceptionCPP(SaxonProcessor::sxn_environ->env, cppClass,
1108
                                                                        nullptr);
1109
    if (exception == nullptr) { return nullptr; }
1110
    return exception->getMessage();
1111
}
1112

    
1113

    
1114
SaxonApiException *XsltExecutable::getException() {
1115
    return SaxonProcessor::checkForExceptionCPP(SaxonProcessor::sxn_environ->env, cppClass, nullptr);
1116
}
(39-39/55)