Project

Profile

Help

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

he / src / main / c / Saxon.C.API / XsltExecutable.cpp @ 146cfacb

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
    if (selectionV != nullptr) {
48
        selectionV->decrementRefCount();
49
        if (selectionV->getRefCount() == 0) {
50
            delete selectionV;
51
        }
52
    } else {
53
        if (selection) {
54
            SaxonProcessor::sxn_environ->env->DeleteGlobalRef(selection);
55
        }
56
    }
57
    SaxonProcessor::sxn_environ->env->DeleteGlobalRef(executableObject);
58

    
59
}
60

    
61

    
62
XsltExecutable::XsltExecutable(const XsltExecutable &other) {
63

    
64
    /*
65
     * Look for class.
66
     */
67
    cppClass = lookForClass(SaxonProcessor::sxn_environ->env,
68
                            "net/sf/saxon/option/cpp/Xslt30Processor");
69

    
70
    executableObject = other.executableObject;
71
    selectionV = other.selectionV;
72
    if (selectionV != nullptr) {
73
        setInitialMatchSelection(other.selectionV);
74
    } else {
75
        selection = other.selection;
76
    }
77
    tunnel = other.tunnel;
78

    
79
    std::map<std::string, XdmValue *>::const_iterator paramIter = other.parameters.begin();
80
    while (paramIter != other.parameters.end()) {
81

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

    
91
    std::map<std::string, std::string>::const_iterator propIter = other.properties.begin();
92
    while (propIter != other.properties.end()) {
93
        properties[propIter->first] = propIter->second;
94
        propIter++;
95
    }
96

    
97
}
98

    
99

    
100
bool XsltExecutable::exceptionOccurred() {
101
    return SaxonProcessor::sxn_environ->env->ExceptionCheck();
102
}
103

    
104
const char *XsltExecutable::getErrorCode() {
105
    SaxonApiException *exception = SaxonProcessor::checkForExceptionCPP(SaxonProcessor::sxn_environ->env, cppClass,
106
                                                                        nullptr);
107
    if (exception == nullptr) { return nullptr; }
108
    return exception->getErrorCode();
109
}
110

    
111

    
112
void XsltExecutable::setGlobalContextItem(XdmItem *value) {
113
    if (value != nullptr) {
114
        value->incrementRefCount();
115
        parameters["node"] = value;
116
    }
117
}
118

    
119
void XsltExecutable::setGlobalContextFromFile(const char *ifile) {
120
    if (ifile != nullptr) {
121
        setProperty("s", ifile);
122
    }
123
}
124

    
125
void XsltExecutable::setInitialMatchSelection(XdmValue *_selection) {
126
    if (_selection != nullptr) {
127
        _selection->incrementRefCount();
128
        selectionV = _selection;
129
        selection = SaxonProcessor::sxn_environ->env->NewGlobalRef(_selection->getUnderlyingValue());
130
    }
131
}
132

    
133

    
134
void XsltExecutable::setInitialMatchSelectionAsFile(const char *filename) {
135
    if (filename != nullptr) {
136
        selection = SaxonProcessor::sxn_environ->env->NewGlobalRef(SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
137

    
138
    }
139
}
140

    
141
void XsltExecutable::setOutputFile(const char *ofile) {
142
    setProperty("o", ofile);
143
}
144

    
145
void XsltExecutable::setBaseOutputURI(const char *baseURI) {
146
    if (baseURI != nullptr) {
147
        setProperty("baseoutput", baseURI);
148
    }
149
}
150

    
151

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

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

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

    
200
bool XsltExecutable::removeParameter(const char *name) {
201
    return (bool) (parameters.erase("param:" + std::string(name)));
202
}
203

    
204

    
205
void XsltExecutable::setResultAsRawValue(bool option) {
206
    if (option) {
207
        setProperty("outvalue", "yes");
208
    }
209
}
210

    
211
XsltExecutable * XsltExecutable::clone() {
212
    XsltExecutable * executable = new XsltExecutable(*this);
213
    return executable;
214

    
215
}
216

    
217
void XsltExecutable::setProperty(const char *name, const char *value) {
218
    if (name != nullptr) {
219
        int s = properties.size();
220

    
221
        std::string skey = std::string(name);
222
        properties.insert(std::pair<std::string, std::string>(skey, std::string((value == nullptr ? "" : value))));
223

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

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

    
243
void XsltExecutable::clearParameters(bool delValues) {
244
    if (delValues) {
245
        for (std::map<std::string, XdmValue *>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
246

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

    
259
        SaxonProcessor::sxn_environ->env->DeleteGlobalRef(selection);
260
        selection = nullptr;
261
    } else {
262
        for (std::map<std::string, XdmValue *>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
263

    
264
            XdmValue *value = itr->second;
265
            if(value != nullptr) {
266
                value->decrementRefCount();
267
            }
268

    
269
        }
270

    
271
        selection = nullptr;
272
    }
273
    parameters.clear();
274

    
275

    
276
}
277

    
278
void XsltExecutable::clearProperties() {
279
    properties.clear();
280

    
281
}
282

    
283

    
284
std::map<std::string, XdmValue *> &XsltExecutable::getParameters() {
285
    std::map<std::string, XdmValue *> &ptr = parameters;
286
    return ptr;
287
}
288

    
289
std::map<std::string, std::string> &XsltExecutable::getProperties() {
290
    std::map<std::string, std::string> &ptr = properties;
291
    return ptr;
292
}
293

    
294
void XsltExecutable::exceptionClear() {
295
    SaxonProcessor::sxn_environ->env->ExceptionClear();
296
}
297

    
298
void XsltExecutable::setcwd(const char *dir) {
299
    if (dir != nullptr) {
300
        cwdXE = std::string(dir);
301
    }
302
}
303

    
304

    
305
void XsltExecutable::exportStylesheet(const char *filename) {
306

    
307

    
308
    static jmethodID exportmID = nullptr;
309

    
310
    if (!exportmID) {
311
        exportmID = SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass, "save",
312
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;)V");
313
    }
314

    
315
    if (filename == nullptr) {
316
        std::cerr << "Error: Error: export file name is nullptr" << std::endl;
317
        return;
318
    }
319
    SaxonProcessor::sxn_environ->env->CallStaticVoidMethod(cppClass, exportmID,
320
                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(
321
                                                                   cwdXE.c_str()),
322
                                                           executableObject,
323
                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
324

    
325
}
326

    
327
void XsltExecutable::applyTemplatesReturningFile(const char *output_filename) {
328

    
329
    if (selection == nullptr) {
330
        std::cerr
331
                << "Error: The initial match selection has not been set. Please set it using setInitialMatchSelection or setInitialMatchSelectionFile."
332
                << std::endl;
333
        return;
334
    }
335

    
336
    static jmethodID atmID = nullptr;
337

    
338
    if (atmID == nullptr) {
339
        atmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
340
                                                                        "applyTemplatesReturningFile",
341
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
342
    }
343

    
344
    if (!atmID) {
345
        std::cerr << "Error: " << getDllname() << ".applyTemplatesReturningFile" << " not found\n"
346
                  << std::endl;
347

    
348
    } else {
349
        JParameters comboArrays;
350
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
351
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atmID,
352
                                                                 SaxonProcessor::sxn_environ->env->NewStringUTF(
353
                                                                         cwdXE.c_str()), executableObject, selection,
354
                                                                 (output_filename != nullptr
355
                                                                  ? SaxonProcessor::sxn_environ->env->NewStringUTF(
356
                                                                                 output_filename) : nullptr),
357
                                                                 comboArrays.stringArray, comboArrays.objectArray);
358
        if (comboArrays.stringArray != nullptr) {
359
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
360
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
361
        }
362

    
363
    }
364
    return;
365

    
366
}
367

    
368
const char *XsltExecutable::applyTemplatesReturningString() {
369

    
370
    if (selection == nullptr) {
371
        std::cerr
372
                << "Error: The initial match selection has not been set. Please set it using setInitialMatchSelection or setInitialMatchSelectionFile."
373
                << std::endl;
374
        return nullptr;
375
    }
376

    
377

    
378
    static jmethodID atsmID = nullptr;
379

    
380
    if (atsmID == nullptr) {
381
        atsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
382
                                                                             "applyTemplatesReturningString",
383
                                                                             "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)[B");
384
    }
385
    if (!atsmID) {
386
        std::cerr << "Error: " << getDllname() << "applyTemplatesAsString" << " not found\n"
387
                  << std::endl;
388

    
389
    } else {
390
        JParameters comboArrays;
391
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
392

    
393
        jbyteArray result = nullptr;
394
        jobject obj = (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atsmID,
395
                                                                                SaxonProcessor::sxn_environ->env->NewStringUTF(
396
                                                                                        cwdXE.c_str()), executableObject,selection,
397
                comboArrays.stringArray, comboArrays.objectArray));
398

    
399
        if (obj) {
400
            result = (jbyteArray) obj;
401
        }
402
        if (comboArrays.stringArray != nullptr) {
403
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
404
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
405
        }
406
        if (result) {
407
            jboolean isCopy = false;
408
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
409
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
410

    
411
            const char *str = new char[num_bytes];
412
            memcpy ((void *) str, b , num_bytes );
413

    
414
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
415
            return str;
416
        }
417
    }
418
    return nullptr;
419

    
420

    
421
}
422

    
423
XdmValue *XsltExecutable::applyTemplatesReturningValue() {
424

    
425
    if (selection == nullptr) {
426
        std::cerr
427
                << "Error: The initial match selection has not been set. Please set it using setInitialMatchSelection or setInitialMatchSelectionFile."
428
                << std::endl;
429
        return nullptr;
430
    }
431

    
432

    
433
    static jmethodID atsvmID = nullptr;
434
    if (atsvmID == nullptr) {
435
        atsvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
436
                                                                                 "applyTemplatesReturningValue",
437
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
438
    }
439
    if (!atsvmID) {
440
        std::cerr << "Error: " << getDllname() << "applyTemplatesAsValue" << " not found\n"
441
                  << std::endl;
442

    
443
    } else {
444
        JParameters comboArrays;
445
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
446

    
447

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

    
472

    
473
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
474
                xdmItem = new XdmAtomicValue(result);
475

    
476
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
477
                return xdmItem;
478

    
479
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
480
                xdmItem = new XdmNode(result);
481
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
482
                return xdmItem;
483
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
484
                xdmItem = new XdmFunctionItem(result);
485
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
486
                return xdmItem;
487
            } else {
488
                value = new XdmValue(result, true);
489
                for (int z = 0; z < value->size(); z++) {
490
                }
491
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
492
                return value;
493
            }
494
        }
495
    }
496
    return nullptr;
497

    
498
}
499

    
500

    
501
void XsltExecutable::callFunctionReturningFile(const char *functionName, XdmValue **arguments, int argument_length,
502
                                               const char *outfile) {
503

    
504

    
505
    static jmethodID afmID = nullptr;
506

    
507
    if (afmID == nullptr) {
508
        afmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
509
                                                                                "callFunctionReturningFile",
510
                                                                                "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)V");
511
    }
512

    
513
    if (!afmID) {
514
        std::cerr << "Error: " << getDllname() << "callFunctionReturningFile" << " not found\n"
515
                  << std::endl;
516
        return;
517
    } else {
518
        JParameters comboArrays;
519
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
520

    
521
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
522

    
523
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, afmID,
524
                                                                 SaxonProcessor::sxn_environ->env->NewStringUTF(
525
                                                                         cwdXE.c_str()),
526
                                                                 executableObject,
527
                                                                 (functionName != nullptr ?
528
                                                                  SaxonProcessor::sxn_environ->env->NewStringUTF(
529
                                                                          functionName) :
530
                                                                  nullptr), argumentJArray,
531
                                                                 (outfile != nullptr ?
532
                                                                  SaxonProcessor::sxn_environ->env->NewStringUTF(
533
                                                                          outfile) :
534
                                                                  nullptr),
535
                                                                 comboArrays.stringArray, comboArrays.objectArray);
536
        if (comboArrays.stringArray != nullptr) {
537
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
538
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
539
        }
540
        if (argumentJArray != nullptr) {
541
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(argumentJArray);
542
        }
543

    
544
    }
545
    return;
546

    
547

    
548
}
549

    
550
const char *
551
XsltExecutable::callFunctionReturningString(const char *functionName, XdmValue **arguments, int argument_length) {
552

    
553

    
554
    static jmethodID afsmID = nullptr;
555

    
556
    if(afsmID == nullptr) {
557
        (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
558
                                                                        "callFunctionReturningString",
559
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)[B");
560
    }
561
    if (!afsmID) {
562
        std::cerr << "Error: " << getDllname() << "callFunctionReturningString" << " not found\n"
563
                  << std::endl;
564

    
565
    } else {
566
        JParameters comboArrays;
567
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
568
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
569

    
570
        jbyteArray result = nullptr;
571
        jobject obj = (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, afsmID,
572
                                                                                SaxonProcessor::sxn_environ->env->NewStringUTF(
573
                                                                                        cwdXE.c_str()), executableObject,
574
                                                                                        (functionName != nullptr
575
                                                                                         ? SaxonProcessor::sxn_environ->env->NewStringUTF(
576
                                                                                                        functionName)
577
                                                                                         : nullptr),
578
                                                                                argumentJArray, comboArrays.stringArray,
579
                                                                                comboArrays.objectArray));
580
        if (obj) {
581
            result = (jbyteArray) obj;
582
        }
583
        if (comboArrays.stringArray != nullptr) {
584
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
585
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
586
        }
587
        if (result) {
588
            jboolean isCopy = false;
589
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
590
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
591

    
592
            const char *str = new char[num_bytes];
593
            memcpy ((void *) str, b , num_bytes );
594

    
595
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
596
            return str;
597
        }
598
    }
599
    return nullptr;
600
}
601

    
602

    
603
XdmValue *
604
XsltExecutable::callFunctionReturningValue(const char *functionName, XdmValue **arguments, int argument_length) {
605

    
606

    
607
    static jmethodID cfvmID = nullptr;
608
    if (cfvmID == nullptr) {
609
        cfvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
610
                                                                                 "callFunctionReturningValue",
611
                                                                                 "(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;");
612
    }
613
    if (!cfvmID) {
614
        std::cerr << "Error: " << getDllname() << "callFunctionReturningValue" << " not found\n"
615
                  << std::endl;
616

    
617
    } else {
618
        JParameters comboArrays;
619
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
620
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
621

    
622
        jobject result = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, cfvmID,
623
                                                                                             SaxonProcessor::sxn_environ->env->NewStringUTF(
624
                                                                                                     cwdXE.c_str()),
625
                                                                                             executableObject,
626
                                                                                             (functionName != nullptr
627
                                                                                              ? SaxonProcessor::sxn_environ->env->NewStringUTF(
628
                                                                                                             functionName)
629
                                                                                              : nullptr),
630
                                                                                             argumentJArray,
631
                                                                                             comboArrays.stringArray,
632
                                                                                             comboArrays.objectArray));
633

    
634
        if (comboArrays.stringArray != nullptr) {
635
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
636
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
637
        }
638
        if (argumentJArray != nullptr) {
639
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(argumentJArray);
640
        }
641
        if (result) {
642
            jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env,
643
                                                   "net/sf/saxon/s9api/XdmAtomicValue");
644
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
645
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
646
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
647
            XdmValue *value = nullptr;
648
            XdmItem *xdmItem = nullptr;
649

    
650

    
651
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
652
                xdmItem = new XdmAtomicValue(result);
653
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
654
                return xdmItem;
655
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
656
                xdmItem = new XdmNode(result);
657
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
658
                return xdmItem;
659

    
660
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
661
                xdmItem = new XdmFunctionItem(result);
662
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
663
                return xdmItem;
664
            } else {
665
                value = new XdmValue(result, true);
666
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
667
                return value;
668
            }
669
            value = new XdmValue();
670
            value->addUnderlyingValue(result);
671
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
672
            return value;
673
        }
674
    }
675
    return nullptr;
676

    
677
}
678

    
679

    
680
void XsltExecutable::callTemplateReturningFile(const char *templateName, const char *outfile) {
681

    
682

    
683
    static jmethodID ctmID = nullptr;
684

    
685
    if(ctmID == nullptr) {
686
        ctmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
687
                                                                        "callTemplateReturningFile",
688
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
689
    }
690
    if (!ctmID) {
691
        std::cerr << "Error: " << getDllname() << "callTemplateReturningFile" << " not found\n"
692
                  << std::endl;
693

    
694
    } else {
695
        JParameters comboArrays;
696
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
697
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctmID,
698
                                                                 SaxonProcessor::sxn_environ->env->NewStringUTF(
699
                                                                         cwdXE.c_str()),
700
                                                                 executableObject,
701
                                                                 (templateName != nullptr
702
                                                                  ? SaxonProcessor::sxn_environ->env->NewStringUTF(
703
                                                                                 templateName) : nullptr),
704
                                                                 (outfile != nullptr
705
                                                                  ? SaxonProcessor::sxn_environ->env->NewStringUTF(
706
                                                                                 outfile) : nullptr),
707
                                                                 comboArrays.stringArray, comboArrays.objectArray);
708
        if (comboArrays.stringArray != nullptr) {
709
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
710
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
711
        }
712

    
713

    
714
    }
715

    
716
}
717

    
718

    
719
const char *XsltExecutable::callTemplateReturningString(const char *templateName) {
720

    
721

    
722
    jmethodID ctsmID = nullptr;
723

    
724
    if(ctsmID == nullptr) {
725
        ctsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
726
                                                                        "callTemplateReturningString",
727
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)[B");
728
    }
729
    if (!ctsmID) {
730
        std::cerr << "Error: " << getDllname() << "callTemplateReturningString" << " not found\n"
731
                  << std::endl;
732

    
733
    } else {
734
        JParameters comboArrays;
735
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
736

    
737

    
738
        jbyteArray result = nullptr;
739
        jobject obj = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctsmID,
740
                                                                                          SaxonProcessor::sxn_environ->env->NewStringUTF(
741
                                                                                                  cwdXE.c_str()),
742
                                                                                          executableObject,
743
                                                                                          (templateName != nullptr
744
                                                                                           ? SaxonProcessor::sxn_environ->env->NewStringUTF(
745
                                                                                                          templateName)
746
                                                                                           : nullptr),
747
                                                                                          comboArrays.stringArray,
748
                                                                                          comboArrays.objectArray));
749
        if (obj) {
750
            result = (jbyteArray) obj;
751
        }
752
        if (comboArrays.stringArray != nullptr) {
753
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
754
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
755
        }
756
        if (result) {
757
            jboolean isCopy = false;
758
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
759
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
760

    
761
            const char *str = new char[num_bytes];
762
            memcpy ((void *) str, b , num_bytes );
763

    
764
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
765
            return str;
766
        }
767
    }
768
    return nullptr;
769

    
770

    
771
}
772

    
773
XdmValue *XsltExecutable::callTemplateReturningValue(const char *templateName) {
774

    
775

    
776
    static jmethodID ctsvmID = nullptr;
777
    if (ctsvmID == nullptr) {
778
        ctsvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
779
                                                                                 "callTemplateReturningValue",
780
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
781
    }
782
    if (!ctsvmID) {
783
        std::cerr << "Error: " << getDllname() << "callTemplateReturningValue" << " not found\n"
784
                  << std::endl;
785

    
786
    } else {
787
        JParameters comboArrays;
788
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
789

    
790

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

    
817
            XdmItem *xdmItem = nullptr;
818
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
819
                xdmItem = new XdmAtomicValue(result);
820
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
821
                return xdmItem;
822

    
823
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
824
                xdmItem = new XdmNode(result);
825
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
826
                return xdmItem;
827
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
828
                xdmItem = new XdmFunctionItem(result);
829
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
830
                return xdmItem;
831
            } else {
832
                value = new XdmValue(result, true);
833
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
834
                return value;
835
            }
836
            value = new XdmValue();
837
            value->addUnderlyingValue(result);
838
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
839
            return value;
840
        }
841
    }
842
    return nullptr;
843
}
844

    
845

    
846
XdmValue *XsltExecutable::transformFileToValue(const char *sourcefile) {
847

    
848
    if (sourcefile == nullptr) {
849

    
850
        return nullptr;
851
    }
852

    
853

    
854
    static jmethodID tfvMID = nullptr;
855

    
856
    if (tfvMID == nullptr) {
857
        tfvMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
858
                                                                                 "transformToValue",
859
                                                                                 "(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;");
860
    }
861
    if (!tfvMID) {
862
        std::cerr << "Error: " << getDllname() << ".transformtoValue" << " not found\n"
863
                  << std::endl;
864

    
865
    } else {
866
        JParameters comboArrays;
867
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
868

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

    
895

    
896
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
897
                xdmItem = new XdmAtomicValue(result);
898
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
899
                return xdmItem;
900

    
901
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
902
                xdmItem = new XdmNode(result);
903
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
904
                return xdmItem;
905

    
906
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
907
                xdmItem = new XdmFunctionItem(result);
908
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
909
                return xdmItem;
910
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, mapItemClass) == JNI_TRUE) {
911
                xdmItem = new XdmMap(result);
912
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
913
                return xdmItem;
914
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, arrayItemClass) == JNI_TRUE) {
915
                xdmItem = new XdmArray(result);
916
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
917
                return xdmItem;
918
            } else {
919
                value = new XdmValue(result, true);
920
                return value;
921
            }
922
            value = new XdmValue();
923
            value->addUnderlyingValue(result);
924

    
925
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
926
            return value;
927
        }
928
    }
929
    return nullptr;
930

    
931
}
932

    
933

    
934
void XsltExecutable::transformFileToFile(const char *source, const char *outputfile) {
935

    
936

    
937
    static jmethodID tffMID = nullptr;
938

    
939
    if (tffMID == nullptr) {
940
        tffMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
941
                                                                                 "transformToFile",
942
                                                                                 "(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");
943
    }
944
    if (!tffMID) {
945
        std::cerr << "Error: " << getDllname() << "transformToFile" << " not found\n"
946
                  << std::endl;
947

    
948
    } else {
949
        JParameters comboArrays;
950
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
951

    
952
        SaxonProcessor::sxn_environ->env->CallStaticVoidMethod(cppClass, tffMID,
953
                                                               SaxonProcessor::sxn_environ->env->NewStringUTF(
954
                                                                       cwdXE.c_str()), nullptr, executableObject,
955
                                                                       (source != nullptr
956
                                                                        ? SaxonProcessor::sxn_environ->env->NewStringUTF(
957
                                                                                       source) : nullptr), nullptr,
958
                                                               (outputfile != nullptr
959
                                                                ? SaxonProcessor::sxn_environ->env->NewStringUTF(
960
                                                                               outputfile) : nullptr),
961
                                                               comboArrays.stringArray, comboArrays.objectArray);
962
        if (comboArrays.stringArray != nullptr) {
963
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
964
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
965
        }
966
    }
967

    
968
}
969

    
970

    
971
void XsltExecutable::setupXslMessage(bool create, const char * filename) {
972
    if (create) {
973

    
974
        static jmethodID messageID =   nullptr;
975
        if(messageID == nullptr) {
976
            messageID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(messageListenerClass,
977
                                                                                  "<init>",
978
                                                                                  "(Ljava/lang/String;Ljava/lang/String;)V");
979
        }
980
        if (!messageID) {
981
            std::cerr << "Error: "<<"SaxonCMessageListener" << " in " <<getDllname() << " not found\n"
982
                      << std::endl;
983

    
984
        }
985

    
986
        if (filename == nullptr) {
987
            saxonMessageListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
988
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF("-:on"));
989
            //setProperty("m", "on");
990
        } else {
991
            saxonMessageListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
992
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
993
        }
994
    } else {
995
        setProperty("m", "off");
996
    }
997

    
998

    
999
}
1000

    
1001
XdmValue * XsltExecutable::getXslMessages(){
1002

    
1003
    if(saxonMessageListenerObj) {
1004
        static jmethodID getmessageID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(messageListenerClass,
1005
                                                                                                  "getXslMessages",
1006
                                                                                                  "()[Lnet/sf/saxon/s9api/XdmNode;");
1007
        if (!getmessageID) {
1008
            std::cerr << "Error: " << getDllname() << ".getXslMessages" << " not found\n"
1009
                      << std::endl;
1010

    
1011
        } else {
1012
            jobjectArray results = (jobjectArray) (
1013
                    SaxonProcessor::sxn_environ->env->CallObjectMethod(saxonMessageListenerObj, getmessageID));
1014
            int sizex = SaxonProcessor::sxn_environ->env->GetArrayLength(results);
1015

    
1016
            if (sizex > 0) {
1017
                XdmValue *value = new XdmValue();
1018

    
1019
                for (int p = 0; p < sizex; ++p) {
1020
                    jobject resulti = SaxonProcessor::sxn_environ->env->GetObjectArrayElement(results, p);
1021
                    value->addUnderlyingValue(resulti);
1022
                }
1023
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(results);
1024
                return value;
1025
            }
1026
        }
1027
    }
1028
    return NULL;
1029

    
1030

    
1031
}
1032

    
1033

    
1034
const char *XsltExecutable::transformFileToString(const char *source) {
1035

    
1036

    
1037
    static jmethodID tftMID = tftMID;
1038
    if (tftMID == nullptr) {
1039
        tftMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
1040
                                                                                 "transformToString",
1041
                                                                                 "(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");
1042
    }
1043
    if (!tftMID) {
1044
        std::cerr << "Error: " << getDllname() << "transformToString" << " not found\n"
1045
                  << std::endl;
1046

    
1047
    } else {
1048
        JParameters comboArrays;
1049
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
1050

    
1051
        jbyteArray result = nullptr;
1052
        jobject obj = SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, tftMID,
1053
                                                                               SaxonProcessor::sxn_environ->env->NewStringUTF(
1054
                                                                                       cwdXE.c_str()), nullptr,
1055
                                                                               executableObject,
1056
                                                                               (source != nullptr
1057
                                                                                ? SaxonProcessor::sxn_environ->env->NewStringUTF(
1058
                                                                                               source) : nullptr),
1059
                                                                               nullptr,
1060
                                                                               comboArrays.stringArray,
1061
                                                                               comboArrays.objectArray);
1062
        if (comboArrays.stringArray != nullptr) {
1063
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
1064
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
1065
        }
1066
        if (obj) {
1067
            result = (jbyteArray) obj;
1068
        }
1069
        if (result) {
1070

    
1071
            jboolean isCopy = false;
1072
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
1073
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
1074

    
1075
            const char *str = new char[num_bytes];
1076
            memcpy ((void *) str, b , num_bytes );
1077

    
1078
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
1079
            return str;
1080
        }
1081
    }
1082
    return nullptr;
1083
}
1084

    
1085

    
1086
const char *XsltExecutable::transformToString(XdmNode *source) {
1087

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

    
1095

    
1096
XdmValue *XsltExecutable::transformToValue(XdmNode *source) {
1097

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

    
1105
void XsltExecutable::transformToFile(XdmNode *source) {
1106

    
1107
    if (source != nullptr) {
1108
        source->incrementRefCount();
1109
        parameters["node"] = source;
1110
    }
1111
    transformFileToFile(nullptr, nullptr);
1112
}
1113

    
1114
const char *XsltExecutable::getErrorMessage() {
1115
    SaxonApiException *exception = SaxonProcessor::checkForExceptionCPP(SaxonProcessor::sxn_environ->env, cppClass,
1116
                                                                        nullptr);
1117
    if (exception == nullptr) { return nullptr; }
1118
    return exception->getMessage();
1119
}
1120

    
1121

    
1122
SaxonApiException *XsltExecutable::getException() {
1123
    return SaxonProcessor::checkForExceptionCPP(SaxonProcessor::sxn_environ->env, cppClass, nullptr);
1124
}
(39-39/55)