SaxonC 12.5
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
XsltExecutable.h
1
2// Copyright (c) 2022 - 2023 Saxonica Limited.
3// This Source Code Form is subject to the terms of the Mozilla Public License,
4// v. 2.0. If a copy of the MPL was not distributed with this file, You can
5// obtain one at http://mozilla.org/MPL/2.0/. This Source Code Form is
6// "Incompatible With Secondary Licenses", as defined by the Mozilla Public
7// License, v. 2.0.
9
10#ifndef SAXON_XSLT_EXEC_H
11#define SAXON_XSLT_EXEC_H
12
13#include "SaxonProcessor.h"
14//#include "XdmValue.h"
15#include <string>
16
17class SaxonProcessor;
19class Xslt30Processor;
20class XdmValue;
21class XdmItem;
22class XdmNode;
23class XdmFunctionItem;
24
30
31 friend class Xslt30Processor;
32
33public:
35
37 // static base URI for XSLT stylesheets when supplied as lexical string.
43 void setcwd(const char *cwd);
44
46
54 void setBaseOutputURI(const char *baseURI);
55
58
65 void setGlobalContextItem(XdmItem *value);
66
73 void setGlobalContextFromFile(const char *filename);
74
76
81
83
92 void setInitialMode(const char *modeName);
93
96
99 void setInitialMatchSelection(XdmValue *selection);
100
103
107 void setInitialMatchSelectionAsFile(const char *filename);
108
112 void setOutputFile(const char *outfile);
113
122 void setResultAsRawValue(bool option);
123
132 void setParameter(const char *name, XdmValue *value);
133
143 std::map<std::string, XdmValue *> &getResultDocuments();
144
151 XdmValue *getParameter(const char *name, bool withParam=true);
152
159 bool removeParameter(const char *name);
160
167 bool removeProperty(const char *name);
168
178 void setProperty(const char *name, const char *value);
179
209 void
210 setInitialTemplateParameters(std::map<std::string, XdmValue *> parameters,
211 bool tunnel);
212
218 const char *getProperty(const char *name);
219
221
228 std::map<std::string, XdmValue *> &getParameters();
229
231
235 std::map<std::string, std::string> &getProperties();
236
238
244 void clearParameters(bool deleteValues = false);
245
246
248 void clearProperties();
249
253 XdmValue **createXdmValueArray(int len) { return (new XdmValue *[len]); }
254
258 char **createCharArray(int len) { return (new char *[len]); }
259
261
266 void deleteXdmValueArray(XdmValue **arr, int len);
267
270
278 void setSaveXslMessage(bool show, const char *filename = nullptr);
279
282
295 void setCaptureResultDocuments(bool flag, bool rawResults = false);
296
298
311 void exportStylesheet(const char *filename);
312
314
321 void transformFileToFile(const char *sourcefile, const char *outputfile);
322
324
331 const char *transformFileToString(const char *sourcefile);
332
340 XdmValue *transformFileToValue(const char *sourcefile);
341
344
352 void applyTemplatesReturningFile(const char *outfile);
353
356
362 const char *applyTemplatesReturningString();
363
366
373
376
387 void callTemplateReturningFile(const char *templateName, const char *outfile);
388
391
401 const char *callTemplateReturningString(const char *templateName = nullptr);
402
405
415 XdmValue *callTemplateReturningValue(const char *templateName = nullptr);
416
418
429 void callFunctionReturningFile(const char *functionName, XdmValue **arguments,
430 int argument_length, const char *outfile);
431
433
443 const char *callFunctionReturningString(const char *functionName,
444 XdmValue **arguments,
445 int argument_length);
446
448
458 XdmValue *callFunctionReturningValue(const char *functionName,
459 XdmValue **arguments,
460 int argument_length);
461
463
471 const char *transformToString(XdmNode *source = nullptr);
472
474
483 XdmValue *transformToValue(XdmNode *source = nullptr);
484
486
493 void transformToFile(XdmNode *source = nullptr);
494
502
508 void clearXslMessages();
509
516 bool exceptionOccurred();
517
519
524
526
530 const char *getErrorMessage();
531
533 void exceptionClear();
534
535private:
537
541
543
547 XsltExecutable(SaxonProcessor *proc, int64_t exObject, std::string cwd,
548 std::string resources);
549
554 XsltExecutable(const XsltExecutable &other);
555
556
557 void setParameter(const char *name, XdmValue *value, bool withParam);
558
559
560 SaxonProcessor *proc;
561 // jclass cppClass;
562 // jclass messageListenerClass, resultDocumentClass;
563 int64_t procRef, executableRef, selectionRef, saxonMessageListenerRef,
564 saxonResultDocRef;
565 bool selectionStringFlag;
568 std::string cwdXE;
569 std::string resources_dir;
570 bool tunnel, jitCompilation, rawResultsFlag, exceptionFound;
571 std::map<std::string, XdmValue *>
572 parameters;
574 std::map<std::string, std::string>
575 properties;
577 std::map<std::string, XdmValue *> resultDocumentMap;
578};
579
580#endif /* SAXON_XSLT_EXEC_H */
Definition SaxonApiException.h:23
Definition SaxonProcessor.h:117
Definition XdmFunctionItem.h:25
Definition XdmItem.h:30
Definition XdmNode.h:56
Definition XdmValue.h:42
Definition Xslt30Processor.h:28
Definition XsltExecutable.h:29
XdmValue * applyTemplatesReturningValue()
Definition XsltExecutable.cpp:514
const char * callFunctionReturningString(const char *functionName, XdmValue **arguments, int argument_length)
Call a public user-defined function in the compiled stylesheet.
Definition XsltExecutable.cpp:626
void setInitialMatchSelectionAsFile(const char *filename)
Definition XsltExecutable.cpp:126
const char * transformFileToString(const char *sourcefile)
Perform a one shot transformation.
Definition XsltExecutable.cpp:1084
void exportStylesheet(const char *filename)
Produce a representation of the compiled stylesheet.
Definition XsltExecutable.cpp:390
XdmValue * getParameter(const char *name, bool withParam=true)
Definition XsltExecutable.cpp:283
const char * transformToString(XdmNode *source=nullptr)
Execute transformation to string. Properties supplied in advance.
Definition XsltExecutable.cpp:1141
void setCaptureResultDocuments(bool flag, bool rawResults=false)
Definition XsltExecutable.cpp:212
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition XsltExecutable.cpp:341
void transformToFile(XdmNode *source=nullptr)
Execute transformation to file. Properties supplied in advance.
Definition XsltExecutable.cpp:1157
void applyTemplatesReturningFile(const char *outfile)
Definition XsltExecutable.cpp:400
const char * callTemplateReturningString(const char *templateName=nullptr)
Definition XsltExecutable.cpp:800
XdmValue ** createXdmValueArray(int len)
Definition XsltExecutable.h:253
const char * getProperty(const char *name)
Definition XsltExecutable.cpp:332
SaxonApiException * getException()
Check for exception thrown and return the SaxonApiException object.
Definition XsltExecutable.cpp:1165
XdmValue * callFunctionReturningValue(const char *functionName, XdmValue **arguments, int argument_length)
Call a public user-defined function in the already compiled stylesheet.
Definition XsltExecutable.cpp:688
void clearProperties()
Clear property values set.
Definition XsltExecutable.cpp:359
void setInitialMatchSelection(XdmValue *selection)
Definition XsltExecutable.cpp:117
void exceptionClear()
Clear any exception thrown.
Definition XsltExecutable.cpp:379
bool removeParameter(const char *name)
Definition XsltExecutable.cpp:296
void setSaveXslMessage(bool show, const char *filename=nullptr)
Definition XsltExecutable.cpp:1011
void setGlobalContextFromFile(const char *filename)
Definition XsltExecutable.cpp:111
void setProperty(const char *name, const char *value)
Definition XsltExecutable.cpp:315
XsltExecutable * clone()
Create a clone object of this XsltExecutable object.
Definition XsltExecutable.cpp:310
XdmValue * transformToValue(XdmNode *source=nullptr)
Execute transformation to Xdm Value. Properties supplied in advance.
Definition XsltExecutable.cpp:1149
void setResultAsRawValue(bool option)
Definition XsltExecutable.cpp:300
const char * applyTemplatesReturningString()
Definition XsltExecutable.cpp:458
void setParameter(const char *name, XdmValue *value)
Definition XsltExecutable.cpp:168
std::map< std::string, XdmValue * > & getResultDocuments()
Definition XsltExecutable.cpp:244
void setcwd(const char *cwd)
set the current working directory (cwd). This method also applies to the
Definition XsltExecutable.cpp:384
XdmValue * getXslMessages()
Definition XsltExecutable.cpp:1046
void callTemplateReturningFile(const char *templateName, const char *outfile)
Definition XsltExecutable.cpp:751
XdmValue * transformFileToValue(const char *sourcefile)
Definition XsltExecutable.cpp:898
void transformFileToFile(const char *sourcefile, const char *outputfile)
Perform a one shot transformation.
Definition XsltExecutable.cpp:956
const char * getErrorMessage()
Get the first error message if there are any errors.
Definition XsltExecutable.cpp:1167
void setBaseOutputURI(const char *baseURI)
Set the base output URI.
Definition XsltExecutable.cpp:156
XdmValue * callTemplateReturningValue(const char *templateName=nullptr)
Definition XsltExecutable.cpp:847
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition XsltExecutable.cpp:374
void setOutputFile(const char *outfile)
Definition XsltExecutable.cpp:152
void setInitialMode(const char *modeName)
Set the initial mode for the transformation.
Definition XsltExecutable.cpp:162
char ** createCharArray(int len)
Definition XsltExecutable.h:258
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition XsltExecutable.cpp:369
void callFunctionReturningFile(const char *functionName, XdmValue **arguments, int argument_length, const char *outfile)
Call a public user-defined function in the already compiled stylesheet.
Definition XsltExecutable.cpp:565
void setGlobalContextItem(XdmItem *value)
Definition XsltExecutable.cpp:105
bool exceptionOccurred()
Definition XsltExecutable.cpp:103
void deleteXdmValueArray(XdmValue **arr, int len)
Utility method for Python API - internal use only.
Definition XsltExecutable.cpp:97
void clearXslMessages()
Definition XsltExecutable.cpp:1076
void setInitialTemplateParameters(std::map< std::string, XdmValue * > parameters, bool tunnel)
Definition XsltExecutable.cpp:197
bool removeProperty(const char *name)
Definition XsltExecutable.cpp:328