Project

Profile

Help

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

he / src / main / c / Saxon.C.API / XsltExecutable.cpp @ 55b80284

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
#ifdef MEM_DEBUG
18
#define new new(__FILE__, __LINE__)
19
#endif
20

    
21
XsltExecutable::XsltExecutable(jobject exObject, std::string curr) {
22

    
23

    
24

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

    
31
    messageListenerClass = lookForClass(SaxonProcessor::sxn_environ->env,
32
                                               "net/sf/saxon/option/cpp/SaxonCMessageListener");
33

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

    
38
#endif
39
    tunnel = false;
40
    selection = nullptr;
41
    selectionV = nullptr;
42
    saxonMessageListenerObj = nullptr;
43
    executableObject = SaxonProcessor::sxn_environ->env->NewGlobalRef(exObject);
44
    cwdXE = curr;
45
}
46

    
47
XsltExecutable::~XsltExecutable() {
48
    clearProperties();
49
    clearParameters();
50

    
51
    if(selection) {
52
        SaxonProcessor::sxn_environ->env->DeleteGlobalRef(selection);
53
        selection = nullptr;
54
    }
55
    SaxonProcessor::sxn_environ->env->DeleteGlobalRef(executableObject);
56
    SaxonProcessor::sxn_environ->env->ExceptionClear(); // This is as a precaution to avoid crashing out if JNI gets into an unclean state.
57
}
58

    
59

    
60
XsltExecutable::XsltExecutable(const XsltExecutable &other) {
61

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

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

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

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

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

    
95
}
96

    
97

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

    
102

    
103
void XsltExecutable::setGlobalContextItem(XdmItem *value) {
104
    if (value != nullptr) {
105
        value->incrementRefCount();
106
        parameters["node"] = value;
107
    }
108
}
109

    
110
void XsltExecutable::setGlobalContextFromFile(const char *ifile) {
111
    if (ifile != nullptr) {
112
        setProperty("s", ifile);
113
    }
114
}
115

    
116
void XsltExecutable::setInitialMatchSelection(XdmValue *_selection) {
117
    if (_selection != nullptr) {
118
        _selection->incrementRefCount();
119
        selectionV = _selection;
120
        selection = SaxonProcessor::sxn_environ->env->NewGlobalRef(_selection->getUnderlyingValue());
121
    }
122
}
123

    
124

    
125
void XsltExecutable::setInitialMatchSelectionAsFile(const char *filename) {
126
    if (filename != nullptr) {
127
        selection = SaxonProcessor::sxn_environ->env->NewGlobalRef(SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
128

    
129
    }
130
}
131

    
132
void XsltExecutable::setOutputFile(const char *ofile) {
133
    setProperty("o", ofile);
134
}
135

    
136
void XsltExecutable::setBaseOutputURI(const char *baseURI) {
137
    if (baseURI != nullptr) {
138
        setProperty("baseoutput", baseURI);
139
    }
140
}
141

    
142

    
143
void XsltExecutable::setParameter(const char *name, XdmValue *value) {
144
    if (value != nullptr && name != nullptr) {
145
        value->incrementRefCount();
146
        int s = parameters.size();
147
        std::string skey = "param:" + std::string(name);
148
        parameters[skey] = value;
149
        if (s == parameters.size()) {
150
            std::map<std::string, XdmValue *>::iterator it;
151
            it = parameters.find(skey);
152
            if (it != parameters.end()) {
153
                XdmValue *valuei = it->second;
154
                if(valuei != nullptr) {
155
                    valuei->decrementRefCount();
156
                    parameters.erase(skey);
157
                    parameters[skey] = value;
158
                }
159
            }
160
        }
161
    }
162
}
163

    
164
void XsltExecutable::setInitialTemplateParameters(std::map<std::string, XdmValue *> _itparameters, bool _tunnel) {
165
    for (std::map<std::string, XdmValue *>::iterator itr = _itparameters.begin(); itr != _itparameters.end(); itr++) {
166
        parameters["itparam:" + std::string(itr->first)] = itr->second;
167
        itr->second->incrementRefCount();
168
    }
169
    tunnel = _tunnel;
170
    if (tunnel) {
171
        setProperty("tunnel", "true");
172
    }
173
}
174

    
175
XdmValue *XsltExecutable::getParameter(const char *name) {
176
    std::map<std::string, XdmValue *>::iterator it;
177
    it = parameters.find("param:" + std::string(name));
178
    if (it != parameters.end())
179
        return it->second;
180
    else {
181
        it = parameters.find("sparam:" + std::string(name));
182
        if (it != parameters.end())
183
            return it->second;
184
    }
185
    return nullptr;
186
}
187

    
188
bool XsltExecutable::removeParameter(const char *name) {
189
    return (bool) (parameters.erase("param:" + std::string(name)));
190
}
191

    
192

    
193
void XsltExecutable::setResultAsRawValue(bool option) {
194
    if (option) {
195
        setProperty("outvalue", "yes");
196
    }
197
}
198

    
199
XsltExecutable * XsltExecutable::clone() {
200
    XsltExecutable * executable = new XsltExecutable(*this);
201
    return executable;
202

    
203
}
204

    
205
void XsltExecutable::setProperty(const char *name, const char *value) {
206
    if (name != nullptr) {
207
        int s = properties.size();
208

    
209
        std::string skey = std::string(name);
210
        properties.insert(std::pair<std::string, std::string>(skey, std::string((value == nullptr ? "" : value))));
211

    
212
        if (s == properties.size()) {
213
            std::map<std::string, std::string>::iterator it;
214
            it = properties.find(skey);
215
            if (it != properties.end()) {
216
                properties.erase(skey);
217
                properties[skey] = std::string((value == nullptr ? "" : value));
218
            }
219
        }
220
    }
221
}
222

    
223
const char *XsltExecutable::getProperty(const char *name) {
224
    std::map<std::string, std::string>::iterator it;
225
    it = properties.find(std::string(name));
226
    if (it != properties.end())
227
        return it->second.c_str();
228
    return nullptr;
229
}
230

    
231
void XsltExecutable::clearParameters(bool delValues) {
232
    if (delValues) {
233
        for (std::map<std::string, XdmValue *>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
234

    
235
            XdmValue *value = itr->second;
236
            if(value != nullptr) {
237
#ifdef DEBUG
238
                std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
239
#endif
240
                    delete value;
241
                    value = nullptr;
242
            }
243
        }
244
    }
245
    parameters.clear();
246
}
247

    
248
void XsltExecutable::clearProperties() {
249
    properties.clear();
250

    
251
}
252

    
253

    
254
std::map<std::string, XdmValue *> &XsltExecutable::getParameters() {
255
    std::map<std::string, XdmValue *> &ptr = parameters;
256
    return ptr;
257
}
258

    
259
std::map<std::string, std::string> &XsltExecutable::getProperties() {
260
    std::map<std::string, std::string> &ptr = properties;
261
    return ptr;
262
}
263

    
264
void XsltExecutable::exceptionClear() {
265
    SaxonProcessor::sxn_environ->env->ExceptionClear();
266
}
267

    
268
void XsltExecutable::setcwd(const char *dir) {
269
    if (dir != nullptr) {
270
        cwdXE = std::string(dir);
271
    }
272
}
273

    
274

    
275
void XsltExecutable::exportStylesheet(const char *filename) {
276

    
277

    
278
    static jmethodID exportmID = nullptr;
279

    
280
    if (!exportmID) {
281
        exportmID = SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass, "save",
282
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;)V");
283
    }
284

    
285
    if (filename == nullptr) {
286
        std::cerr << "Error: Error: export file name is nullptr" << std::endl;
287
        return;
288
    }
289
    SaxonProcessor::sxn_environ->env->CallStaticVoidMethod(cppClass, exportmID,
290
                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(
291
                                                                   cwdXE.c_str()),
292
                                                           executableObject,
293
                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
294

    
295
}
296

    
297
void XsltExecutable::applyTemplatesReturningFile(const char *output_filename) {
298

    
299
    if (selection == nullptr) {
300
        std::cerr
301
                << "Error: The initial match selection has not been set. Please set it using setInitialMatchSelection or setInitialMatchSelectionFile."
302
                << std::endl;
303
        return;
304
    }
305

    
306
    static jmethodID atmID = nullptr;
307

    
308
    if (atmID == nullptr) {
309
        atmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
310
                                                                        "applyTemplatesReturningFile",
311
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
312
    }
313

    
314
    if (!atmID) {
315
        std::cerr << "Error: " << getDllname() << ".applyTemplatesReturningFile" << " not found\n"
316
                  << std::endl;
317
        SaxonProcessor::sxn_environ->env->ExceptionClear();
318
    } else {
319
        JParameters comboArrays;
320
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
321
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atmID,
322
                                                                 SaxonProcessor::sxn_environ->env->NewStringUTF(
323
                                                                         cwdXE.c_str()), executableObject, selection,
324
                                                                 (output_filename != nullptr
325
                                                                  ? SaxonProcessor::sxn_environ->env->NewStringUTF(
326
                                                                                 output_filename) : nullptr),
327
                                                                 comboArrays.stringArray, comboArrays.objectArray);
328
        if (comboArrays.stringArray != nullptr) {
329
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
330
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
331
        }
332

    
333
    }
334
    return;
335

    
336
}
337

    
338
const char *XsltExecutable::applyTemplatesReturningString() {
339

    
340
    if (selection == nullptr) {
341
        std::cerr
342
                << "Error: The initial match selection has not been set. Please set it using setInitialMatchSelection or setInitialMatchSelectionFile."
343
                << std::endl;
344
        return nullptr;
345
    }
346

    
347

    
348
    static jmethodID atsmID = nullptr;
349

    
350
    if (atsmID == nullptr) {
351
        atsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
352
                                                                             "applyTemplatesReturningString",
353
                                                                             "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)[B");
354
    }
355
    if (!atsmID) {
356
        std::cerr << "Error: " << getDllname() << "applyTemplatesAsString" << " not found\n"
357
                  << std::endl;
358
        SaxonProcessor::sxn_environ->env->ExceptionClear();
359
    } else {
360
        JParameters comboArrays;
361
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
362

    
363
        jbyteArray result = nullptr;
364
        jobject obj = (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atsmID,
365
                                                                                SaxonProcessor::sxn_environ->env->NewStringUTF(
366
                                                                                        cwdXE.c_str()), executableObject,selection,
367
                comboArrays.stringArray, comboArrays.objectArray));
368

    
369
        if (obj) {
370
            result = (jbyteArray) obj;
371
        }
372
        if (comboArrays.stringArray != nullptr) {
373
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
374
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
375
        }
376
        if (result) {
377
            jboolean isCopy = false;
378
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
379
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
380

    
381
            const char *str = new char[num_bytes];
382
            memcpy ((void *) str, b , num_bytes );
383

    
384
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
385
            return str;
386
        }
387
    }
388
    return nullptr;
389

    
390

    
391
}
392

    
393
XdmValue *XsltExecutable::applyTemplatesReturningValue() {
394

    
395
    if (selection == nullptr) {
396
        std::cerr
397
                << "Error: The initial match selection has not been set. Please set it using setInitialMatchSelection or setInitialMatchSelectionFile."
398
                << std::endl;
399
        return nullptr;
400
    }
401

    
402

    
403
    static jmethodID atsvmID = nullptr;
404
    if (atsvmID == nullptr) {
405
        atsvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
406
                                                                                 "applyTemplatesReturningValue",
407
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
408
    }
409
    if (!atsvmID) {
410
        std::cerr << "Error: " << getDllname() << "applyTemplatesAsValue" << " not found\n"
411
                  << std::endl;
412
        SaxonProcessor::sxn_environ->env->ExceptionClear();
413
    } else {
414
        JParameters comboArrays;
415
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
416

    
417

    
418
        // jstring result = nullptr;
419
        jobject result = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, atsvmID,
420
                                                                                             SaxonProcessor::sxn_environ->env->NewStringUTF(
421
                                                                                                     cwdXE.c_str()),
422
                                                                                             executableObject,
423
                                                                                             selection,
424
                                                                                             comboArrays.stringArray,
425
                                                                                             comboArrays.objectArray));
426
        /*if(obj) {
427
            result = (jobject)obj;
428
        }*/
429
        if (comboArrays.stringArray != nullptr) {
430
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
431
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
432
        }
433
        if (result) {
434
            jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env,
435
                                                   "net/sf/saxon/s9api/XdmAtomicValue");
436
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
437
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
438
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
439
            XdmValue *value = nullptr;
440
            XdmItem *xdmItem = nullptr;
441

    
442

    
443
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
444
                xdmItem = new XdmAtomicValue(result);
445

    
446
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
447
                return xdmItem;
448

    
449
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
450
                xdmItem = new XdmNode(result);
451
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
452
                return xdmItem;
453
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
454
                xdmItem = new XdmFunctionItem(result);
455
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
456
                return xdmItem;
457
            } else {
458
                value = new XdmValue(result, true);
459
                for (int z = 0; z < value->size(); z++) {
460
                }
461
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
462
                return value;
463
            }
464
        }
465
    }
466
    return nullptr;
467

    
468
}
469

    
470

    
471
void XsltExecutable::callFunctionReturningFile(const char *functionName, XdmValue **arguments, int argument_length,
472
                                               const char *outfile) {
473

    
474

    
475
    static jmethodID afmID = nullptr;
476

    
477
    if (afmID == nullptr) {
478
        afmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
479
                                                                                "callFunctionReturningFile",
480
                                                                                "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)V");
481
    }
482

    
483
    if (!afmID) {
484
        std::cerr << "Error: " << getDllname() << "callFunctionReturningFile" << " not found\n"
485
                  << std::endl;
486
        SaxonProcessor::sxn_environ->env->ExceptionClear();
487
        return;
488
    } else {
489
        JParameters comboArrays;
490
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
491

    
492
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
493

    
494
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, afmID,
495
                                                                 SaxonProcessor::sxn_environ->env->NewStringUTF(
496
                                                                         cwdXE.c_str()),
497
                                                                 executableObject,
498
                                                                 (functionName != nullptr ?
499
                                                                  SaxonProcessor::sxn_environ->env->NewStringUTF(
500
                                                                          functionName) :
501
                                                                  nullptr), argumentJArray,
502
                                                                 (outfile != nullptr ?
503
                                                                  SaxonProcessor::sxn_environ->env->NewStringUTF(
504
                                                                          outfile) :
505
                                                                  nullptr),
506
                                                                 comboArrays.stringArray, comboArrays.objectArray);
507
        if (comboArrays.stringArray != nullptr) {
508
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
509
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
510
        }
511
        if (argumentJArray != nullptr) {
512
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(argumentJArray);
513
        }
514

    
515
    }
516
    return;
517

    
518

    
519
}
520

    
521
const char *
522
XsltExecutable::callFunctionReturningString(const char *functionName, XdmValue **arguments, int argument_length) {
523

    
524

    
525
    static jmethodID afsmID = nullptr;
526

    
527
    if(afsmID == nullptr) {
528
        (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
529
                                                                        "callFunctionReturningString",
530
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/String;[Ljava/lang/Object;)[B");
531
    }
532
    if (!afsmID) {
533
        std::cerr << "Error: " << getDllname() << "callFunctionReturningString" << " not found\n"
534
                  << std::endl;
535
        SaxonProcessor::sxn_environ->env->ExceptionClear();
536
    } else {
537
        JParameters comboArrays;
538
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
539
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
540

    
541
        jbyteArray result = nullptr;
542
        jobject obj = (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, afsmID,
543
                                                                                SaxonProcessor::sxn_environ->env->NewStringUTF(
544
                                                                                        cwdXE.c_str()), executableObject,
545
                                                                                        (functionName != nullptr
546
                                                                                         ? SaxonProcessor::sxn_environ->env->NewStringUTF(
547
                                                                                                        functionName)
548
                                                                                         : nullptr),
549
                                                                                argumentJArray, comboArrays.stringArray,
550
                                                                                comboArrays.objectArray));
551
        if (obj) {
552
            result = (jbyteArray) obj;
553
        }
554
        if (comboArrays.stringArray != nullptr) {
555
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
556
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
557
        }
558
        if (result) {
559
            jboolean isCopy = false;
560
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
561
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
562

    
563
            const char *str = new char[num_bytes];
564
            memcpy ((void *) str, b , num_bytes );
565

    
566
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
567
            return str;
568
        }
569
    }
570
    return nullptr;
571
}
572

    
573

    
574
XdmValue *
575
XsltExecutable::callFunctionReturningValue(const char *functionName, XdmValue **arguments, int argument_length) {
576

    
577

    
578
    static jmethodID cfvmID = nullptr;
579
    if (cfvmID == nullptr) {
580
        cfvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
581
                                                                                 "callFunctionReturningValue",
582
                                                                                 "(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;");
583
    }
584
    if (!cfvmID) {
585
        std::cerr << "Error: " << getDllname() << "callFunctionReturningValue" << " not found\n"
586
                  << std::endl;
587
        SaxonProcessor::sxn_environ->env->ExceptionClear();
588
    } else {
589
        JParameters comboArrays;
590
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
591
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
592

    
593
        jobject result = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, cfvmID,
594
                                                                                             SaxonProcessor::sxn_environ->env->NewStringUTF(
595
                                                                                                     cwdXE.c_str()),
596
                                                                                             executableObject,
597
                                                                                             (functionName != nullptr
598
                                                                                              ? SaxonProcessor::sxn_environ->env->NewStringUTF(
599
                                                                                                             functionName)
600
                                                                                              : nullptr),
601
                                                                                             argumentJArray,
602
                                                                                             comboArrays.stringArray,
603
                                                                                             comboArrays.objectArray));
604

    
605
        if (comboArrays.stringArray != nullptr) {
606
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
607
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
608
        }
609
        if (argumentJArray != nullptr) {
610
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(argumentJArray);
611
        }
612
        if (result) {
613
            jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env,
614
                                                   "net/sf/saxon/s9api/XdmAtomicValue");
615
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
616
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
617
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
618
            XdmValue *value = nullptr;
619
            XdmItem *xdmItem = nullptr;
620

    
621

    
622
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
623
                xdmItem = new XdmAtomicValue(result);
624
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
625
                return xdmItem;
626
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
627
                xdmItem = new XdmNode(result);
628
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
629
                return xdmItem;
630

    
631
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
632
                xdmItem = new XdmFunctionItem(result);
633
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
634
                return xdmItem;
635
            } else {
636
                value = new XdmValue(result, true);
637
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
638
                return value;
639
            }
640
            value = new XdmValue();
641
            value->addUnderlyingValue(result);
642
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
643
            return value;
644
        }
645
    }
646
    return nullptr;
647

    
648
}
649

    
650

    
651
void XsltExecutable::callTemplateReturningFile(const char *templateName, const char *outfile) {
652

    
653

    
654
    static jmethodID ctmID = nullptr;
655

    
656
    if(ctmID == nullptr) {
657
        ctmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
658
                                                                        "callTemplateReturningFile",
659
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
660
    }
661
    if (!ctmID) {
662
        std::cerr << "Error: " << getDllname() << "callTemplateReturningFile" << " not found\n"
663
                  << std::endl;
664
        SaxonProcessor::sxn_environ->env->ExceptionClear();
665
    } else {
666
        JParameters comboArrays;
667
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
668
        SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctmID,
669
                                                                 SaxonProcessor::sxn_environ->env->NewStringUTF(
670
                                                                         cwdXE.c_str()),
671
                                                                 executableObject,
672
                                                                 (templateName != nullptr
673
                                                                  ? SaxonProcessor::sxn_environ->env->NewStringUTF(
674
                                                                                 templateName) : nullptr),
675
                                                                 (outfile != nullptr
676
                                                                  ? SaxonProcessor::sxn_environ->env->NewStringUTF(
677
                                                                                 outfile) : nullptr),
678
                                                                 comboArrays.stringArray, comboArrays.objectArray);
679
        if (comboArrays.stringArray != nullptr) {
680
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
681
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
682
        }
683

    
684

    
685
    }
686

    
687
}
688

    
689

    
690
const char *XsltExecutable::callTemplateReturningString(const char *templateName) {
691

    
692

    
693
    jmethodID ctsmID = nullptr;
694

    
695
    if(ctsmID == nullptr) {
696
        ctsmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
697
                                                                        "callTemplateReturningString",
698
                                                                        "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)[B");
699
    }
700
    if (!ctsmID) {
701
        std::cerr << "Error: " << getDllname() << "callTemplateReturningString" << " not found\n"
702
                  << std::endl;
703
        SaxonProcessor::sxn_environ->env->ExceptionClear();
704
    } else {
705
        JParameters comboArrays;
706
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
707

    
708

    
709
        jbyteArray result = nullptr;
710
        jobject obj = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctsmID,
711
                                                                                          SaxonProcessor::sxn_environ->env->NewStringUTF(
712
                                                                                                  cwdXE.c_str()),
713
                                                                                          executableObject,
714
                                                                                          (templateName != nullptr
715
                                                                                           ? SaxonProcessor::sxn_environ->env->NewStringUTF(
716
                                                                                                          templateName)
717
                                                                                           : nullptr),
718
                                                                                          comboArrays.stringArray,
719
                                                                                          comboArrays.objectArray));
720
        if (obj) {
721
            result = (jbyteArray) obj;
722
        }
723
        if (comboArrays.stringArray != nullptr) {
724
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
725
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
726
        }
727
        if (result) {
728
            jboolean isCopy = false;
729
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
730
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
731

    
732
            const char *str = new char[num_bytes];
733
            memcpy ((void *) str, b , num_bytes );
734

    
735
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
736
            return str;
737
        }
738
    }
739
    return nullptr;
740

    
741

    
742
}
743

    
744
XdmValue *XsltExecutable::callTemplateReturningValue(const char *templateName) {
745

    
746

    
747
    static jmethodID ctsvmID = nullptr;
748
    if (ctsvmID == nullptr) {
749
        ctsvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
750
                                                                                 "callTemplateReturningValue",
751
                                                                                 "(Ljava/lang/String;Lnet/sf/saxon/s9api/XsltExecutable;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
752
    }
753
    if (!ctsvmID) {
754
        std::cerr << "Error: " << getDllname() << "callTemplateReturningValue" << " not found\n"
755
                  << std::endl;
756
        SaxonProcessor::sxn_environ->env->ExceptionClear();
757
    } else {
758
        JParameters comboArrays;
759
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
760

    
761

    
762
        jstring result = nullptr;
763
        jobject obj = (jobject) (SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, ctsvmID,
764
                                                                                          SaxonProcessor::sxn_environ->env->NewStringUTF(
765
                                                                                                  cwdXE.c_str()),
766
                                                                                          executableObject,
767
                                                                                          (templateName != nullptr
768
                                                                                           ? SaxonProcessor::sxn_environ->env->NewStringUTF(
769
                                                                                                          templateName)
770
                                                                                           : nullptr),
771
                                                                                          comboArrays.stringArray,
772
                                                                                          comboArrays.objectArray));
773
        if (obj) {
774
            result = (jstring) obj;
775
        }
776
        if (comboArrays.stringArray != nullptr) {
777
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
778
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
779
        }
780
        if (result) {
781
            jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env,
782
                                                   "net/sf/saxon/s9api/XdmAtomicValue");
783
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
784
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
785
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
786
            XdmValue *value = nullptr;
787

    
788
            XdmItem *xdmItem = nullptr;
789
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
790
                xdmItem = new XdmAtomicValue(result);
791
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
792
                return xdmItem;
793

    
794
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
795
                xdmItem = new XdmNode(result);
796
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
797
                return xdmItem;
798
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
799
                xdmItem = new XdmFunctionItem(result);
800
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
801
                return xdmItem;
802
            } else {
803
                value = new XdmValue(result, true);
804
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
805
                return value;
806
            }
807
            value = new XdmValue();
808
            value->addUnderlyingValue(result);
809
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
810
            return value;
811
        }
812
    }
813
    return nullptr;
814
}
815

    
816

    
817
XdmValue *XsltExecutable::transformFileToValue(const char *sourcefile) {
818

    
819
    if (sourcefile == nullptr) {
820

    
821
        return nullptr;
822
    }
823

    
824

    
825
    static jmethodID tfvMID = nullptr;
826

    
827
    if (tfvMID == nullptr) {
828
        tfvMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
829
                                                                                 "transformToValue",
830
                                                                                 "(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;");
831
    }
832
    if (!tfvMID) {
833
        std::cerr << "Error: " << getDllname() << ".transformtoValue" << " not found\n"
834
                  << std::endl;
835
        SaxonProcessor::sxn_environ->env->ExceptionClear();
836
    } else {
837
        JParameters comboArrays;
838
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
839

    
840
        jobject result = (jobject) (
841
                SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, tfvMID,
842
                                                                         SaxonProcessor::sxn_environ->env->NewStringUTF(
843
                                                                                 cwdXE.c_str()), nullptr, executableObject,
844
                                                                         (sourcefile != nullptr
845
                                                                          ? SaxonProcessor::sxn_environ->env->NewStringUTF(
846
                                                                                         sourcefile) : nullptr),
847
                                                                         comboArrays.stringArray,
848
                                                                         comboArrays.objectArray));
849
        if (comboArrays.stringArray != nullptr) {
850
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
851
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
852
        }
853
        if (result) {
854
            jclass atomicValueClass = lookForClass(SaxonProcessor::sxn_environ->env,
855
                                                   "net/sf/saxon/s9api/XdmAtomicValue");
856
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
857
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
858
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
859
            jclass mapItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
860
                                                    "net/sf/saxon/s9api/XdmMap");
861
            jclass arrayItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
862
                                               "net/sf/saxon/s9api/XdmArray");
863
            XdmValue *value = nullptr;
864
            XdmItem *xdmItem = nullptr;
865

    
866

    
867
            if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, atomicValueClass) == JNI_TRUE) {
868
                xdmItem = new XdmAtomicValue(result);
869
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
870
                return xdmItem;
871

    
872
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, nodeClass) == JNI_TRUE) {
873
                xdmItem = new XdmNode(result);
874
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
875
                return xdmItem;
876

    
877
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, functionItemClass) == JNI_TRUE) {
878
                xdmItem = new XdmFunctionItem(result);
879
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
880
                return xdmItem;
881
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, mapItemClass) == JNI_TRUE) {
882
                xdmItem = new XdmMap(result);
883
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
884
                return xdmItem;
885
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, arrayItemClass) == JNI_TRUE) {
886
                xdmItem = new XdmArray(result);
887
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
888
                return xdmItem;
889
            } else {
890
                value = new XdmValue(result, true);
891
                return value;
892
            }
893
            value = new XdmValue();
894
            value->addUnderlyingValue(result);
895

    
896
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
897
            return value;
898
        }
899
    }
900
    return nullptr;
901

    
902
}
903

    
904

    
905
void XsltExecutable::transformFileToFile(const char *source, const char *outputfile) {
906

    
907

    
908
    static jmethodID tffMID = nullptr;
909

    
910
    if (tffMID == nullptr) {
911
        tffMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
912
                                                                                 "transformToFile",
913
                                                                                 "(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");
914
    }
915
    if (!tffMID) {
916
        std::cerr << "Error: " << getDllname() << "transformToFile" << " not found\n"
917
                  << std::endl;
918
        SaxonProcessor::sxn_environ->env->ExceptionClear();
919
    } else {
920
        JParameters comboArrays;
921
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
922

    
923
        SaxonProcessor::sxn_environ->env->CallStaticVoidMethod(cppClass, tffMID,
924
                                                               SaxonProcessor::sxn_environ->env->NewStringUTF(
925
                                                                       cwdXE.c_str()), nullptr, executableObject,
926
                                                                       (source != nullptr
927
                                                                        ? SaxonProcessor::sxn_environ->env->NewStringUTF(
928
                                                                                       source) : nullptr), nullptr,
929
                                                               (outputfile != nullptr
930
                                                                ? SaxonProcessor::sxn_environ->env->NewStringUTF(
931
                                                                               outputfile) : nullptr),
932
                                                               comboArrays.stringArray, comboArrays.objectArray);
933
        if (comboArrays.stringArray != nullptr) {
934
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
935
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
936
        }
937
    }
938

    
939
}
940

    
941

    
942
void XsltExecutable::setupXslMessage(bool create, const char * filename) {
943
    if (create) {
944

    
945
        static jmethodID messageID =   nullptr;
946
        if(messageID == nullptr) {
947
            messageID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(messageListenerClass,
948
                                                                                  "<init>",
949
                                                                                  "(Ljava/lang/String;Ljava/lang/String;)V");
950
        }
951
        if (!messageID) {
952
            std::cerr << "Error: SaxonCMessageListener" << " in " <<getDllname() << " not found\n"
953
                      << std::endl;
954
            SaxonProcessor::sxn_environ->env->ExceptionClear();
955
        }
956

    
957
        jobject tempListenerObj;
958
        if (filename == nullptr) {
959
            tempListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
960
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF("-:on"));
961
            //setProperty("m", "on");
962
        } else {
963
            tempListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
964
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
965
        }
966
        if(tempListenerObj) {
967
            saxonMessageListenerObj = SaxonProcessor::sxn_environ->env->NewGlobalRef(tempListenerObj);
968
        } else {
969
            std::cerr << "Error: Failed to create SaxonCMessageListener" <<  std::endl;
970
        }
971
    } else {
972
        setProperty("m", "off");
973
    }
974

    
975

    
976
}
977

    
978
XdmValue * XsltExecutable::getXslMessages(){
979

    
980
    if(saxonMessageListenerObj) {
981
        static jmethodID getmessageID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(messageListenerClass,
982
                                                                                                  "getXslMessages",
983
                                                                                                  "()[Lnet/sf/saxon/s9api/XdmNode;");
984
        if (!getmessageID) {
985
            std::cerr << "Error: " << getDllname() << ".getXslMessages" << " not found\n"
986
                      << std::endl;
987
            SaxonProcessor::sxn_environ->env->ExceptionClear();
988
        } else {
989
            jobjectArray results = (jobjectArray) (
990
                    SaxonProcessor::sxn_environ->env->CallObjectMethod(saxonMessageListenerObj, getmessageID));
991
            int sizex = SaxonProcessor::sxn_environ->env->GetArrayLength(results);
992

    
993
            if (sizex > 0) {
994
                XdmValue *value = new XdmValue();
995

    
996
                for (int p = 0; p < sizex; ++p) {
997
                    jobject resulti = SaxonProcessor::sxn_environ->env->GetObjectArrayElement(results, p);
998
                    value->addUnderlyingValue(resulti);
999
                }
1000
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(results);
1001
                return value;
1002
            }
1003
        }
1004
    }
1005
    return NULL;
1006

    
1007

    
1008
}
1009

    
1010

    
1011
const char *XsltExecutable::transformFileToString(const char *source) {
1012

    
1013

    
1014
    static jmethodID tftMID = tftMID;
1015
    if (tftMID == nullptr) {
1016
        tftMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
1017
                                                                                 "transformToString",
1018
                                                                                 "(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");
1019
    }
1020
    if (!tftMID) {
1021
        std::cerr << "Error: " << getDllname() << "transformToString" << " not found\n"
1022
                  << std::endl;
1023
        SaxonProcessor::sxn_environ->env->ExceptionClear();
1024
    } else {
1025
        JParameters comboArrays;
1026
        comboArrays = SaxonProcessor::createParameterJArray(parameters, properties);
1027

    
1028
        jbyteArray result = nullptr;
1029
        jobject obj = SaxonProcessor::sxn_environ->env->CallStaticObjectMethod(cppClass, tftMID,
1030
                                                                               SaxonProcessor::sxn_environ->env->NewStringUTF(
1031
                                                                                       cwdXE.c_str()), nullptr,
1032
                                                                               executableObject,
1033
                                                                               (source != nullptr
1034
                                                                                ? SaxonProcessor::sxn_environ->env->NewStringUTF(
1035
                                                                                               source) : nullptr),
1036
                                                                               nullptr,
1037
                                                                               comboArrays.stringArray,
1038
                                                                               comboArrays.objectArray);
1039
        if (comboArrays.stringArray != nullptr) {
1040
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.stringArray);
1041
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(comboArrays.objectArray);
1042
        }
1043
        if (obj) {
1044
            result = (jbyteArray) obj;
1045
        }
1046
        if (result) {
1047

    
1048
            jboolean isCopy = false;
1049
            jbyte* b = SaxonProcessor::sxn_environ->env->GetByteArrayElements(result, &isCopy);
1050
            jsize num_bytes = SaxonProcessor::sxn_environ->env->GetArrayLength(result);
1051

    
1052
            const char *str = new char[num_bytes];
1053
            memcpy ((void *) str, b , num_bytes );
1054

    
1055
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(obj);
1056
            return str;
1057
        }
1058
    }
1059
    return nullptr;
1060
}
1061

    
1062

    
1063
const char *XsltExecutable::transformToString(XdmNode *source) {
1064

    
1065
    if (source != nullptr) {
1066
        source->incrementRefCount();
1067
        parameters["node"] = source;
1068
    }
1069
    return transformFileToString(nullptr);
1070
}
1071

    
1072

    
1073
XdmValue *XsltExecutable::transformToValue(XdmNode *source) {
1074

    
1075
    if (source != nullptr) {
1076
        source->incrementRefCount();
1077
        parameters["node"] = source;
1078
    }
1079
    return transformFileToValue(nullptr);
1080
}
1081

    
1082
void XsltExecutable::transformToFile(XdmNode *source) {
1083

    
1084
    if (source != nullptr) {
1085
        source->incrementRefCount();
1086
        parameters["node"] = source;
1087
    }
1088
    transformFileToFile(nullptr, nullptr);
1089
}
1090

    
1091

    
1092
SaxonApiException *XsltExecutable::getException() {
1093
    return SaxonProcessor::checkForExceptionCPP(SaxonProcessor::sxn_environ->env, cppClass, nullptr);
1094
}
(40-40/56)