Project

Profile

Help

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

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

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" << 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 = _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
                valuei->decrementRefCount();
164
                if (valuei != nullptr && valuei->getRefCount() < 1) {
165
                    delete value;
166
                }
167
                parameters.erase(skey);
168
                parameters[skey] = value;
169
            }
170
        }
171
    }
172
}
173

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

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

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

    
202

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

    
209
XsltExecutable * XsltExecutable::clone() {
210
    XsltExecutable * executable = new XsltExecutable(*this);
211
    return executable;
212

    
213
}
214

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

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

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

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

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

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

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

    
260
            XdmValue *value = itr->second;
261
            value->decrementRefCount();
262

    
263
        }
264

    
265
        selection = nullptr;
266
    }
267
    parameters.clear();
268

    
269

    
270
}
271

    
272
void XsltExecutable::clearProperties() {
273
    properties.clear();
274

    
275
}
276

    
277

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

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

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

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

    
298

    
299
void XsltExecutable::exportStylesheet(const char *filename) {
300

    
301

    
302
    static jmethodID exportmID = nullptr;
303

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

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

    
319
}
320

    
321
void XsltExecutable::applyTemplatesReturningFile(const char *output_filename) {
322

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

    
330
    static jmethodID atmID = nullptr;
331

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

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

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

    
357
    }
358
    return;
359

    
360
}
361

    
362
const char *XsltExecutable::applyTemplatesReturningString() {
363

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

    
371

    
372
    static jmethodID atsmID = nullptr;
373

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

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

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

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

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

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

    
414

    
415
}
416

    
417
XdmValue *XsltExecutable::applyTemplatesReturningValue() {
418

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

    
426

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

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

    
441

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

    
466

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

    
470
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
471
                return xdmItem;
472

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

    
492
}
493

    
494

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

    
498

    
499
    static jmethodID afmID = nullptr;
500

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

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

    
515
        jobjectArray argumentJArray = SaxonProcessor::createJArray(arguments, argument_length);
516

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

    
538
    }
539
    return;
540

    
541

    
542
}
543

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

    
547

    
548
    static jmethodID afsmID = nullptr;
549

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

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

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

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

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

    
596

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

    
600

    
601
    static jmethodID cfvmID = nullptr;
602
    if (cfvmID == nullptr) {
603
        cfvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
604
                                                                                 "callFunctionReturningValue",
605
                                                                                 "(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;");
606
    }
607
    if (!cfvmID) {
608
        std::cerr << "Error: " << getDllname() << "callFunctionReturningValue" << " not found\n"
609
                  << std::endl;
610

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

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

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

    
644

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

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

    
671
}
672

    
673

    
674
void XsltExecutable::callTemplateReturningFile(const char *templateName, const char *outfile) {
675

    
676

    
677
    static jmethodID ctmID = nullptr;
678

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

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

    
707

    
708
    }
709

    
710
}
711

    
712

    
713
const char *XsltExecutable::callTemplateReturningString(const char *templateName) {
714

    
715

    
716
    jmethodID ctsmID = nullptr;
717

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

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

    
731

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

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

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

    
764

    
765
}
766

    
767
XdmValue *XsltExecutable::callTemplateReturningValue(const char *templateName) {
768

    
769

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

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

    
784

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

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

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

    
839

    
840
XdmValue *XsltExecutable::transformFileToValue(const char *sourcefile) {
841

    
842
    if (sourcefile == nullptr) {
843

    
844
        return nullptr;
845
    }
846

    
847

    
848
    static jmethodID tfvMID = nullptr;
849

    
850
    if (tfvMID == nullptr) {
851
        tfvMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
852
                                                                                 "transformToValue",
853
                                                                                 "(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;");
854
    }
855
    if (!tfvMID) {
856
        std::cerr << "Error: " << getDllname() << ".transformtoValue" << " not found\n"
857
                  << std::endl;
858

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

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

    
889

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

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

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

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

    
925
}
926

    
927

    
928
void XsltExecutable::transformFileToFile(const char *source, const char *outputfile) {
929

    
930

    
931
    static jmethodID tffMID = nullptr;
932

    
933
    if (tffMID == nullptr) {
934
        tffMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
935
                                                                                 "transformToFile",
936
                                                                                 "(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");
937
    }
938
    if (!tffMID) {
939
        std::cerr << "Error: " << getDllname() << "transformToFile" << " not found\n"
940
                  << std::endl;
941

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

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

    
962
}
963

    
964

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

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

    
978
        }
979

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

    
992

    
993
}
994

    
995
XdmValue * XsltExecutable::getXslMessages(){
996

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

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

    
1010
            if (sizex > 0) {
1011
                XdmValue *value = new XdmValue();
1012

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

    
1024

    
1025
}
1026

    
1027

    
1028
const char *XsltExecutable::transformFileToString(const char *source) {
1029

    
1030

    
1031
    static jmethodID tftMID = tftMID;
1032
    if (tftMID == nullptr) {
1033
        tftMID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
1034
                                                                                 "transformToString",
1035
                                                                                 "(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");
1036
    }
1037
    if (!tftMID) {
1038
        std::cerr << "Error: " << getDllname() << "transformToString" << " not found\n"
1039
                  << std::endl;
1040

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

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

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

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

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

    
1079

    
1080
const char *XsltExecutable::transformToString(XdmNode *source) {
1081

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

    
1089

    
1090
XdmValue *XsltExecutable::transformToValue(XdmNode *source) {
1091

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

    
1099
void XsltExecutable::transformToFile(XdmNode *source) {
1100

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

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

    
1115

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