SaxonC 12.4
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
150 XdmValue *getParameter(const char *name);
151
158 bool removeParameter(const char *name);
159
166 bool removeProperty(const char *name);
167
177 void setProperty(const char *name, const char *value);
178
208 void
209 setInitialTemplateParameters(std::map<std::string, XdmValue *> parameters,
210 bool tunnel);
211
217 const char *getProperty(const char *name);
218
220
227 std::map<std::string, XdmValue *> &getParameters();
228
230
234 std::map<std::string, std::string> &getProperties();
235
237
243 void clearParameters(bool deleteValues = false);
244
246 void clearProperties();
247
251 XdmValue **createXdmValueArray(int len) { return (new XdmValue *[len]); }
252
256 char **createCharArray(int len) { return (new char *[len]); }
257
259
264 void deleteXdmValueArray(XdmValue **arr, int len);
265
268
276 void setSaveXslMessage(bool show, const char *filename = nullptr);
277
280
293 void setCaptureResultDocuments(bool flag, bool rawResults = false);
294
296
309 void exportStylesheet(const char *filename);
310
312
319 void transformFileToFile(const char *sourcefile, const char *outputfile);
320
322
329 const char *transformFileToString(const char *sourcefile);
330
338 XdmValue *transformFileToValue(const char *sourcefile);
339
342
350 void applyTemplatesReturningFile(const char *outfile);
351
354
360 const char *applyTemplatesReturningString();
361
364
371
374
385 void callTemplateReturningFile(const char *templateName, const char *outfile);
386
389
399 const char *callTemplateReturningString(const char *templateName = nullptr);
400
403
413 XdmValue *callTemplateReturningValue(const char *templateName = nullptr);
414
416
427 void callFunctionReturningFile(const char *functionName, XdmValue **arguments,
428 int argument_length, const char *outfile);
429
431
441 const char *callFunctionReturningString(const char *functionName,
442 XdmValue **arguments,
443 int argument_length);
444
446
456 XdmValue *callFunctionReturningValue(const char *functionName,
457 XdmValue **arguments,
458 int argument_length);
459
461
469 const char *transformToString(XdmNode *source = nullptr);
470
472
481 XdmValue *transformToValue(XdmNode *source = nullptr);
482
484
491 void transformToFile(XdmNode *source = nullptr);
492
500
507 bool exceptionOccurred();
508
510
515
517
521 const char *getErrorMessage();
522
524 void exceptionClear();
525
526private:
528
532
534
538 XsltExecutable(SaxonProcessor *proc, int64_t exObject, std::string cwd,
539 std::string resources);
540
545 XsltExecutable(const XsltExecutable &other);
546
547 SaxonProcessor *proc;
548 // jclass cppClass;
549 // jclass messageListenerClass, resultDocumentClass;
550 int64_t procRef, executableRef, selectionRef, saxonMessageListenerRef,
551 saxonResultDocRef;
552 bool selectionStringFlag;
555 std::string cwdXE;
556 std::string resources_dir;
557 bool tunnel, jitCompilation, rawResultsFlag, exceptionFound;
558 std::map<std::string, XdmValue *>
559 parameters;
561 std::map<std::string, std::string>
562 properties;
564 std::map<std::string, XdmValue *> resultDocumentMap;
565};
566
567#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:501
const char * callFunctionReturningString(const char *functionName, XdmValue **arguments, int argument_length)
Call a public user-defined function in the compiled stylesheet.
Definition XsltExecutable.cpp:613
void setInitialMatchSelectionAsFile(const char *filename)
Definition XsltExecutable.cpp:134
const char * transformFileToString(const char *sourcefile)
Perform a one shot transformation.
Definition XsltExecutable.cpp:1052
void exportStylesheet(const char *filename)
Produce a representation of the compiled stylesheet.
Definition XsltExecutable.cpp:377
const char * transformToString(XdmNode *source=nullptr)
Execute transformation to string. Properties supplied in advance.
Definition XsltExecutable.cpp:1101
void setCaptureResultDocuments(bool flag, bool rawResults=false)
Definition XsltExecutable.cpp:199
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition XsltExecutable.cpp:327
void transformToFile(XdmNode *source=nullptr)
Execute transformation to file. Properties supplied in advance.
Definition XsltExecutable.cpp:1117
void applyTemplatesReturningFile(const char *outfile)
Definition XsltExecutable.cpp:387
const char * callTemplateReturningString(const char *templateName=nullptr)
Definition XsltExecutable.cpp:787
XdmValue ** createXdmValueArray(int len)
Definition XsltExecutable.h:251
XdmValue * getParameter(const char *name)
Definition XsltExecutable.cpp:270
const char * getProperty(const char *name)
Definition XsltExecutable.cpp:319
SaxonApiException * getException()
Check for exception thrown and return the SaxonApiException object.
Definition XsltExecutable.cpp:1125
XdmValue * callFunctionReturningValue(const char *functionName, XdmValue **arguments, int argument_length)
Call a public user-defined function in the already compiled stylesheet.
Definition XsltExecutable.cpp:675
void clearProperties()
Clear property values set.
Definition XsltExecutable.cpp:346
void setInitialMatchSelection(XdmValue *selection)
Definition XsltExecutable.cpp:124
void exceptionClear()
Clear any exception thrown.
Definition XsltExecutable.cpp:366
bool removeParameter(const char *name)
Definition XsltExecutable.cpp:283
void setSaveXslMessage(bool show, const char *filename=nullptr)
Definition XsltExecutable.cpp:989
void setGlobalContextFromFile(const char *filename)
Definition XsltExecutable.cpp:118
void setProperty(const char *name, const char *value)
Definition XsltExecutable.cpp:302
XsltExecutable * clone()
Create a clone object of this XsltExecutable object.
Definition XsltExecutable.cpp:297
XdmValue * transformToValue(XdmNode *source=nullptr)
Execute transformation to Xdm Value. Properties supplied in advance.
Definition XsltExecutable.cpp:1109
void setResultAsRawValue(bool option)
Definition XsltExecutable.cpp:287
const char * applyTemplatesReturningString()
Definition XsltExecutable.cpp:445
void setParameter(const char *name, XdmValue *value)
Definition XsltExecutable.cpp:171
std::map< std::string, XdmValue * > & getResultDocuments()
Definition XsltExecutable.cpp:231
void setcwd(const char *cwd)
set the current working directory (cwd). This method also applies to the
Definition XsltExecutable.cpp:371
XdmValue * getXslMessages()
Definition XsltExecutable.cpp:1023
void callTemplateReturningFile(const char *templateName, const char *outfile)
Definition XsltExecutable.cpp:738
XdmValue * transformFileToValue(const char *sourcefile)
Definition XsltExecutable.cpp:885
void transformFileToFile(const char *sourcefile, const char *outputfile)
Perform a one shot transformation.
Definition XsltExecutable.cpp:941
const char * getErrorMessage()
Get the first error message if there are any errors.
Definition XsltExecutable.cpp:1127
void setBaseOutputURI(const char *baseURI)
Set the base output URI.
Definition XsltExecutable.cpp:159
XdmValue * callTemplateReturningValue(const char *templateName=nullptr)
Definition XsltExecutable.cpp:834
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition XsltExecutable.cpp:361
void setOutputFile(const char *outfile)
Definition XsltExecutable.cpp:155
void setInitialMode(const char *modeName)
Set the initial mode for the transformation.
Definition XsltExecutable.cpp:165
char ** createCharArray(int len)
Definition XsltExecutable.h:256
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition XsltExecutable.cpp:356
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:552
void setGlobalContextItem(XdmItem *value)
Definition XsltExecutable.cpp:112
bool exceptionOccurred()
Definition XsltExecutable.cpp:110
void deleteXdmValueArray(XdmValue **arr, int len)
Utility method for Python API - internal use only.
Definition XsltExecutable.cpp:97
void setInitialTemplateParameters(std::map< std::string, XdmValue * > parameters, bool tunnel)
Definition XsltExecutable.cpp:186
bool removeProperty(const char *name)
Definition XsltExecutable.cpp:315