SaxonC 12.4
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
Xslt30Processor.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_XSLT30_H
11#define SAXON_XSLT30_H
12
13#include "SaxonProcessor.h"
14//#include "XdmValue.h"
15#include <string>
16
17class SaxonProcessor;
19class XsltExecutable;
20class XdmValue;
21class XdmItem;
22class XdmNode;
23
29
30 friend class XsltExecutable;
31
32public:
34
39
41
46 Xslt30Processor(SaxonProcessor *proc, std::string cwd = "");
47
52 Xslt30Processor(const Xslt30Processor &other);
53
55
57
61
63
70 void setcwd(const char *cwd);
71
73
81 void setBaseOutputURI(const char *baseURI);
82
84
100 void setJustInTimeCompilation(bool jit);
101
103
108 void setTargetEdition(const char *edition);
109
111
118 void setXsltLanguageVersion(const char *version);
119
121
135 void setFastCompilation(bool fast);
136
138
144 void setRelocatable(bool relocatable);
145
147
158 void setParameter(const char *name, XdmValue *value);
159
165 XdmValue *getParameter(const char *name);
166
173 bool removeParameter(const char *name);
174
176
183 std::map<std::string, XdmValue *> &getParameters();
184
186
192 void clearParameters(bool deleteValues = false);
193
197 XdmValue **createXdmValueArray(int len) { return (new XdmValue *[len]); }
198
202 char **createCharArray(int len) { return (new char *[len]); }
203
205
210 void deleteXdmValueArray(XdmValue **arr, int len) {
211 for (int i = 0; i < len; i++) {
212 // delete arr[i];
213 }
214 delete[] arr;
215 }
216
218
226 void transformFileToFile(const char *sourcefile, const char *stylesheetfile,
227 const char *outputfile);
228
230
238 const char *transformFileToString(const char *sourcefile,
239 const char *stylesheetfile);
240
249 XdmValue *transformFileToValue(const char *sourcefile,
250 const char *stylesheetfile);
251
253
261 void importPackage(const char *packageFile);
262
264
274 XsltExecutable *compileFromFile(const char *stylesheet);
275
277
290 XsltExecutable *compileFromString(const char *stylesheet,
291 const char *encoding = nullptr);
292
294 /* via the xml-stylesheet processing instruction (see
295 * http://www.w3.org/TR/xml-stylesheet/) with the document
296 * document specified in the source parameter, and that match
297 * the given criteria. If there are several suitable xml-stylesheet
298 * processing instructions, then the returned Source will identify
299 * a synthesized stylesheet module that imports all the referenced
300 * stylesheet module.*/
311 XsltExecutable *compileFromAssociatedFile(const char *sourceFile);
312
315
322 void compileFromStringAndSave(const char *stylesheet, const char *filename,
323 const char *encoding = nullptr);
324
327
334 void compileFromFileAndSave(const char *xslFilename, const char *filename);
335
337
343 void compileFromXdmNodeAndSave(XdmNode *node, const char *filename);
344
346
357
364 bool exceptionOccurred();
365
367
373
375 void exceptionClear();
376
378
382 const char *getErrorMessage();
383
385
390 const char *getErrorCode();
391
392private:
393 void createException(const char *message = nullptr);
394
404 void setProperty(const char *name, const char *value);
405
407 void clearProperties();
408
409 SaxonProcessor *proc;
410 int64_t cppXT;
411 int64_t importPackageValue;
412 std::string cwdXT;
413 bool jitCompilation;
414 std::map<std::string, XdmValue *>
415 parameters;
417 std::map<std::string, std::string>
418 properties;
420 SaxonApiException *exception;
421};
422
423#endif /* SAXON_XSLT30_H */
Definition SaxonApiException.h:23
Definition SaxonProcessor.h:117
Definition XdmItem.h:30
Definition XdmNode.h:56
Definition XdmValue.h:42
Definition Xslt30Processor.h:28
XdmValue * getParameter(const char *name)
Definition Xslt30Processor.cpp:140
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition Xslt30Processor.cpp:202
bool removeParameter(const char *name)
Definition Xslt30Processor.cpp:148
bool exceptionOccurred()
Definition Xslt30Processor.cpp:115
char ** createCharArray(int len)
Definition Xslt30Processor.h:202
SaxonProcessor * getSaxonProcessor()
Get the SaxonProcessor object.
Definition Xslt30Processor.h:60
void compileFromStringAndSave(const char *stylesheet, const char *filename, const char *encoding=nullptr)
Definition Xslt30Processor.cpp:237
Xslt30Processor()
Default constructor.
Definition Xslt30Processor.cpp:21
void transformFileToFile(const char *sourcefile, const char *stylesheetfile, const char *outputfile)
Perform a one shot transformation.
Definition Xslt30Processor.cpp:492
SaxonApiException * getException()
Get the SaxonApiException object created when we have an error.
Definition Xslt30Processor.cpp:217
XsltExecutable * compileFromFile(const char *stylesheet)
compile a stylesheet file.
Definition Xslt30Processor.cpp:410
void importPackage(const char *packageFile)
Import a library package.
Definition Xslt30Processor.cpp:256
void setcwd(const char *cwd)
set the current working directory (cwd).
Definition Xslt30Processor.cpp:211
XdmValue ** createXdmValueArray(int len)
Definition Xslt30Processor.h:197
XsltExecutable * compileFromString(const char *stylesheet, const char *encoding=nullptr)
compile a stylesheet received as a string.
Definition Xslt30Processor.cpp:292
const char * transformFileToString(const char *sourcefile, const char *stylesheetfile)
Perform a one shot transformation.
Definition Xslt30Processor.cpp:537
void compileFromXdmNodeAndSave(XdmNode *node, const char *filename)
compile a stylesheet received as an XdmNode.
Definition Xslt30Processor.cpp:221
void setTargetEdition(const char *edition)
Set the target edition.
Definition Xslt30Processor.cpp:178
void setXsltLanguageVersion(const char *version)
Set the XSLT (and XPath) language level to be supported by the processor.
Definition Xslt30Processor.cpp:172
void setParameter(const char *name, XdmValue *value)
Set the value of a stylesheet parameter.
Definition Xslt30Processor.cpp:125
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition Xslt30Processor.cpp:184
void deleteXdmValueArray(XdmValue **arr, int len)
Utility method for Python API - internal use only.
Definition Xslt30Processor.h:210
const char * getErrorMessage()
Get the first error message if there are any errors.
Definition Xslt30Processor.cpp:584
void setFastCompilation(bool fast)
Request fast compilation.
Definition Xslt30Processor.cpp:156
XdmValue * transformFileToValue(const char *sourcefile, const char *stylesheetfile)
Definition Xslt30Processor.cpp:450
void setBaseOutputURI(const char *baseURI)
Set the base output URI.
Definition Xslt30Processor.cpp:119
void setJustInTimeCompilation(bool jit)
Say whether just-in-time compilation of template rules should be used.
Definition Xslt30Processor.cpp:152
void compileFromFileAndSave(const char *xslFilename, const char *filename)
Definition Xslt30Processor.cpp:271
XsltExecutable * compileFromXdmNode(XdmNode *node)
compile a stylesheet received as an XdmNode.
Definition Xslt30Processor.cpp:335
const char * getErrorCode()
Get the first error code if there are any errors.
Definition Xslt30Processor.cpp:117
XsltExecutable * compileFromAssociatedFile(const char *sourceFile)
Get the stylesheet associated.
Definition Xslt30Processor.cpp:375
void exceptionClear()
Clear any exception thrown.
Definition Xslt30Processor.cpp:207
void setRelocatable(bool relocatable)
Indicate package deployable to a different location.
Definition Xslt30Processor.cpp:164
Definition XsltExecutable.h:29