SaxonC 12.7.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
30class SAXONC_EXPORT XsltExecutable {
31
32 friend class Xslt30Processor;
33
34public:
36
45 void setcwd(const char *cwd);
46
53 const char * getcwd();
54
64 void setBaseOutputURI(const char *baseURI);
65
74 void setGlobalContextItem(XdmItem *value);
75
82 void setGlobalContextFromFile(const char *filename);
83
88 XsltExecutable *clone();
89
99 void setInitialMode(const char *modeName);
100
106 void setInitialMatchSelection(XdmValue *selection);
107
114 void setInitialMatchSelectionAsFile(const char *filename);
115
120 void setOutputFile(const char *outfile);
121
130 void setResultAsRawValue(bool option);
131
140 void setParameter(const char *name, XdmValue *value);
141
151 std::map<std::string, XdmValue *> &getResultDocuments();
152
159 XdmValue *getParameter(const char *name, bool withParam=true);
160
167 bool removeParameter(const char *name);
168
175 bool removeProperty(const char *name);
176
186 void setProperty(const char *name, const char *value);
187
217 void
218 setInitialTemplateParameters(std::map<std::string, XdmValue *> parameters,
219 bool tunnel);
220
227 const char *getProperty(const char *name);
228
236 std::map<std::string, XdmValue *> &getParameters();
237
242 std::map<std::string, std::string> &getProperties();
243
251 void clearParameters(bool deleteValues = false);
252
256 void clearProperties();
257
258
262 char **createCharArray(int len) { return (new char *[len]); }
263
270 void deleteXdmValueArray(XdmValue **arr, int len);
271
281 void setSaveXslMessage(bool show, const char *filename = nullptr);
282
297 void setCaptureResultDocuments(bool flag, bool rawResults = false);
298
313 void exportStylesheet(const char *filename);
314
323 void transformFileToFile(const char *sourcefile, const char *outputfile);
324
333 const char *transformFileToString(const char *sourcefile);
334
343 XdmValue *transformFileToValue(const char *sourcefile);
344
356 void applyTemplatesReturningFile(const char *outfile);
357
369 const char *applyTemplatesReturningString();
370
381 XdmValue *applyTemplatesReturningValue();
382
397 void callTemplateReturningFile(const char *templateName, const char *outfile);
398
415 const char *callTemplateReturningString(const char *templateName = nullptr);
416
433 XdmValue *callTemplateReturningValue(const char *templateName = nullptr);
434
449 void callFunctionReturningFile(const char *functionName, XdmValue **arguments,
450 int argument_length, const char *outfile);
451
468 const char *callFunctionReturningString(const char *functionName,
469 XdmValue **arguments,
470 int argument_length);
471
488 XdmValue *callFunctionReturningValue(const char *functionName,
489 XdmValue **arguments,
490 int argument_length);
491
503 const char *transformToString(XdmNode *source = nullptr);
504
515 XdmValue *transformToValue(XdmNode *source = nullptr);
516
525 void transformToFile(XdmNode *source = nullptr);
526
534 XdmValue *getXslMessages();
535
541 void clearXslMessages();
542
549 bool exceptionOccurred();
550
556 SaxonApiException *getException();
557
564 const char *getErrorMessage();
565
570 void exceptionClear();
571
576
577private:
583
589 XsltExecutable(SaxonProcessor *proc, int64_t exObject, std::string cwd,
590 std::string resources);
591
596 XsltExecutable(const XsltExecutable &other);
597
598
599 void setParameter(const char *name, XdmValue *value, bool withParam);
600
601
602 SaxonProcessor *proc;
603 // jclass cppClass;
604 // jclass messageListenerClass, resultDocumentClass;
605 int64_t procRef, executableRef, selectionRef, saxonMessageListenerRef,
606 saxonResultDocRef;
607 bool selectionStringFlag;
610 std::string cwdXE;
611 std::string resources_dir;
612 bool jitCompilation, rawResultsFlag, exceptionFound;
613 std::map<std::string, XdmValue *>
614 parameters;
616 std::map<std::string, std::string>
617 properties;
619 std::map<std::string, XdmValue *> resultDocumentMap;
620};
621
622#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:160
SAXONC_EXPORT int64_t getParameter(sxnc_parameter *parameters, int parLen, const char *name)
Get a parameter from the list.
Definition SaxonCGlue.c:136
SAXONC_EXPORT void setProperty(sxnc_property **properties, int *propLen, int *propCap, const char *name, const char *value)
Set a property.
Definition SaxonCGlue.c:186
SAXONC_EXPORT char * getProperty(sxnc_property *properties, int propLen, const char *name)
Get a property from the list.
Definition SaxonCGlue.c:148
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:43
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:30
SaxonProcessor * getSaxonProcessor()
Get the SaxonProcessor which created this XsltExecutable.
Definition XsltExecutable.h:575
char ** createCharArray(int len)
Utility method for working with SaxonC on Python - internal use only.
Definition XsltExecutable.h:262