SaxonC 12.10.0
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
XsltExecutable.h
1
2// Copyright (c) 2022 - 2025 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 "saxonc_export.h"
14#include "saxonc/SaxonProcessor.h"
15//#include "XdmValue.h"
16#include <string>
17
18class SaxonProcessor;
20class Xslt30Processor;
21class XdmValue;
22class XdmItem;
23class XdmNode;
24class XdmFunctionItem;
25
33class SAXONC_EXPORT XsltExecutable {
34
35 friend class Xslt30Processor;
36
37public:
38 ~XsltExecutable();
39
48 void setcwd(const char *cwd);
49
56 const char * getcwd();
57
67 void setBaseOutputURI(const char *baseURI);
68
76
77 void setGlobalContextItem(XdmItem *value);
78
85 void setGlobalContextFromFile(const char *filename);
86
91 XsltExecutable *clone();
92
102 void setInitialMode(const char *modeName);
103
109 void setInitialMatchSelection(XdmValue *selection);
110
117 void setInitialMatchSelectionAsFile(const char *filename);
118
123 void setOutputFile(const char *outfile);
124
133 void setResultAsRawValue(bool option);
134
143 void setParameter(const char *name, XdmValue *value);
144
154 std::map<std::string, XdmValue *> &getResultDocuments();
155
162 XdmValue *getParameter(const char *name, bool withParam=true);
163
170 bool removeParameter(const char *name);
171
178 bool removeProperty(const char *name);
179
189 void setProperty(const char *name, const char *value);
190
219
220 void
221 setInitialTemplateParameters(std::map<std::string, XdmValue *> parameters,
222 bool tunnel);
223
230 const char *getProperty(const char *name);
231
239 std::map<std::string, XdmValue *> &getParameters();
240
245 std::map<std::string, std::string> &getProperties();
246
254 void clearParameters(bool deleteValues = false);
255
259 void clearProperties();
260
261
265 char **createCharArray(int len) { return (new char *[len]); }
266
273 void deleteXdmValueArray(XdmValue **arr, int len);
274
284 void setSaveXslMessage(bool show, const char *filename = nullptr);
285
300 void setCaptureResultDocuments(bool flag, bool rawResults = false);
301
316 void exportStylesheet(const char *filename);
317
326 void transformFileToFile(const char *sourcefile, const char *outputfile);
327
336 const char *transformFileToString(const char *sourcefile);
337
346 XdmValue *transformFileToValue(const char *sourcefile);
347
359 void applyTemplatesReturningFile(const char *outfile);
360
372 const char *applyTemplatesReturningString();
373
384 XdmValue *applyTemplatesReturningValue();
385
400 void callTemplateReturningFile(const char *templateName, const char *outfile);
401
418 const char *callTemplateReturningString(const char *templateName = nullptr);
419
436 XdmValue *callTemplateReturningValue(const char *templateName = nullptr);
437
452 void callFunctionReturningFile(const char *functionName, XdmValue **arguments,
453 int argument_length, const char *outfile);
454
471 const char *callFunctionReturningString(const char *functionName,
472 XdmValue **arguments,
473 int argument_length);
474
491 XdmValue *callFunctionReturningValue(const char *functionName,
492 XdmValue **arguments,
493 int argument_length);
494
506 const char *transformToString(XdmNode *source = nullptr);
507
518 XdmValue *transformToValue(XdmNode *source = nullptr);
519
528 void transformToFile(XdmNode *source = nullptr);
529
537 XdmValue *getXslMessages();
538
544 void clearXslMessages();
545
552 bool exceptionOccurred();
553
559 SaxonApiException *getException();
560
567 const char *getErrorMessage();
568
573 void exceptionClear();
574
578 SaxonProcessor* getSaxonProcessor();
579
580
581private:
587
593 XsltExecutable(int64_t procRef, int64_t exObject, std::string cwd,
594 std::string resources);
595
600 XsltExecutable(const XsltExecutable &other);
601
602
603 void setParameter(const char *name, XdmValue *value, bool withParam);
604
605 //SaxonProcessor *proc; /*! Pointer to the SaxonProcessor object which created this XsltExecutable */
606 // jclass cppClass;
607 // jclass messageListenerClass, resultDocumentClass;
608 int64_t procRef, executableRef, selectionRef, saxonMessageListenerRef,
609 saxonResultDocRef;
610 bool selectionStringFlag;
613 std::string cwdXE;
614 std::string resources_dir;
615 bool jitCompilation, rawResultsFlag, exceptionFound;
616 std::map<std::string, XdmValue *>
617 parameters;
619 std::map<std::string, std::string>
620 properties;
622 std::map<std::string, XdmValue *> resultDocumentMap;
623};
624
625#endif /* SAXON_XSLT_EXEC_H */
SAXONC_EXPORT void setParameter(sxnc_parameter **parameters, int *parLen, int *parCap, const char *name, sxnc_value *value)
Set a parameter.
Definition SaxonCGlue.c:194
SAXONC_EXPORT int64_t getParameter(sxnc_parameter *parameters, int parLen, const char *name)
Get a parameter from the list.
Definition SaxonCGlue.c:170
SAXONC_EXPORT void setProperty(sxnc_property **properties, int *propLen, int *propCap, const char *name, const char *value)
Set a property.
Definition SaxonCGlue.c:220
SAXONC_EXPORT char * getProperty(sxnc_property *properties, int propLen, const char *name)
Get a property from the list.
Definition SaxonCGlue.c:182
SaxonApiException.
Definition SaxonApiException.h:24
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition SaxonProcessor.h:117
The class XdmFunctionItem represents a function item.
Definition XdmFunctionItem.h:26
The class XdmItem represents an item in a sequence, as defined by the XDM data model.
Definition XdmItem.h:31
This class represents a node in the XDM data model.
Definition XdmNode.h:57
An XdmValue represents a value in the XDM data model.
Definition XdmValue.h:33
An Xslt30Processor represents a factory to compile, load and execute stylesheets.
Definition Xslt30Processor.h:29
An XsltExecutable represents the compiled form of a stylesheet.
Definition XsltExecutable.h:33
void setInitialMatchSelectionAsFile(const char *filename)
Set the initial match selection for the transformation to be a specified file.
Definition XsltExecutable.cpp:160
void clearParameters(bool deleteValues=false)
Clear stylesheet parameter values set.
Definition XsltExecutable.cpp:369
const char * getcwd()
Get the current working directory (cwd).
Definition XsltExecutable.cpp:420
void clearProperties()
Clear configuration property values set.
Definition XsltExecutable.cpp:388
void setInitialMatchSelection(XdmValue *selection)
Set the initial match selection for the transformation to be a specified XDM value.
Definition XsltExecutable.cpp:151
bool removeParameter(const char *name)
Remove a parameter (name, value) pair set for a stylesheet parameter.
Definition XsltExecutable.cpp:324
void setGlobalContextFromFile(const char *filename)
Supply the context item to be used when evaluating global variables and parameters.
Definition XsltExecutable.cpp:141
XsltExecutable * clone()
Create a clone of this XsltExecutable object.
Definition XsltExecutable.cpp:338
void setResultAsRawValue(bool option)
Specify how transformation results are returned.
Definition XsltExecutable.cpp:328
std::map< std::string, XdmValue * > & getResultDocuments()
Obtain the secondary result documents resulting from the execution of the stylesheet,...
Definition XsltExecutable.cpp:267
void setcwd(const char *cwd)
Set the current working directory (cwd).
Definition XsltExecutable.cpp:414
void setBaseOutputURI(const char *baseURI)
Set the base output URI.
Definition XsltExecutable.cpp:178
std::map< std::string, std::string > & getProperties()
Get all configuration properties specified on the processor as a std::map.
Definition XsltExecutable.cpp:403
void setOutputFile(const char *outfile)
Set the output file where the transformation result is sent.
Definition XsltExecutable.cpp:174
void setInitialMode(const char *modeName)
Set the initial mode for the transformation.
Definition XsltExecutable.cpp:184
char ** createCharArray(int len)
Utility method for working with SaxonC on Python - internal use only.
Definition XsltExecutable.h:265
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition XsltExecutable.cpp:398
void setGlobalContextItem(XdmItem *value)
Supply the context item to be used when evaluating global variables and parameters.
Definition XsltExecutable.cpp:131
void setInitialTemplateParameters(std::map< std::string, XdmValue * > parameters, bool tunnel)
Set parameters to be passed to the initial template.
Definition XsltExecutable.cpp:223
bool removeProperty(const char *name)
Remove a configuration property (name, value) pair specific to the processor in use.
Definition XsltExecutable.cpp:356