SaxonC  11.6
Saxon Processor library for C/C++, PHP and Python
Xslt30Processor.h
1 // Copyright (c) 2022 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
7 
8 #ifndef SAXON_XSLT30_H
9 #define SAXON_XSLT30_H
10 
11 
12 #include "SaxonProcessor.h"
13 //#include "XdmValue.h"
14 #include <string>
15 
16 class SaxonProcessor;
17 class SaxonApiException;
18 class XsltExecutable;
19 class XdmValue;
20 class XdmItem;
21 class XdmNode;
22 
27 
28  friend class XsltExecutable;
29 
30 public:
31 
33 
37 
39 
43  Xslt30Processor(SaxonProcessor* proc, std::string cwd="");
44 
49  Xslt30Processor(const Xslt30Processor &other);
50 
51  ~Xslt30Processor();
52 
54 
58 
60 
66  void setcwd(const char* cwd);
67 
69 
76  void setBaseOutputURI(const char *baseURI);
77 
78 
79 
81 
96  void setJustInTimeCompilation(bool jit);
97 
98 
100 
109  void setParameter(const char* name, XdmValue* value);
110 
111 
112 
118  XdmValue* getParameter(const char* name);
119 
120 
127  bool removeParameter(const char* name);
128 
130 
136  std::map<std::string,XdmValue*>& getParameters();
137 
138 
140 
145  void clearParameters(bool deleteValues = false);
146 
147 
152  return (new XdmValue*[len]);
153  }
154 
158  char** createCharArray(int len){
159  return (new char*[len]);
160  }
161 
163 
168  void deleteXdmValueArray(XdmValue ** arr, int len){
169  for(int i =0; i< len; i++) {
170  //delete arr[i];
171  }
172  delete [] arr;
173  }
174 
175 
176 
178 
185  void transformFileToFile(const char* sourcefile, const char* stylesheetfile, const char* outputfile);
186 
188 
195  const char * transformFileToString(const char* sourcefile, const char* stylesheetfile);
196 
204  XdmValue * transformFileToValue(const char* sourcefile, const char* stylesheetfile);
205 
206 
208 
216  XsltExecutable * compileFromFile(const char* stylesheet);
217 
219 
228  XsltExecutable * compileFromString(const char* stylesheet);
229 
230 
231 
233  /* via the xml-stylesheet processing instruction (see
234  * http://www.w3.org/TR/xml-stylesheet/) with the document
235  * document specified in the source parameter, and that match
236  * the given criteria. If there are several suitable xml-stylesheet
237  * processing instructions, then the returned Source will identify
238  * a synthesized stylesheet module that imports all the referenced
239  * stylesheet module.*/
248  XsltExecutable * compileFromAssociatedFile(const char* sourceFile);
249 
250 
252 
258  void compileFromStringAndSave(const char* stylesheet, const char* filename);
259 
260 
262 
268  void compileFromFileAndSave(const char* xslFilename, const char* filename);
269 
270 
272 
277  void compileFromXdmNodeAndSave(XdmNode * node, const char* filename);
278 
280 
289 
290 
295  bool exceptionOccurred();
296 
297 
299 
305 
306 
308  void exceptionClear();
309 
310 
312 
316  const char * getErrorMessage();
317 
319 
323  const char * getErrorCode();
324 
325 
326 
327 
328 
329 
330 private:
331 
332  void createException(const char * message=nullptr);
333 
334 
343  void setProperty(const char* name, const char* value);
344 
346  void clearProperties();
347 
348  SaxonProcessor* proc;
349  jclass cppClass;
350  jobject cppXT;
351  std::string cwdXT;
352  bool jitCompilation;
353  std::map<std::string,XdmValue*> parameters;
354  std::map<std::string,std::string> properties;
355  SaxonApiException * exception;
356 
357 
358 };
359 
360 
361 #endif /* SAXON_XSLT30_H */
Definition: SaxonApiException.h:19
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition: SaxonProcessor.h:119
Definition: XdmItem.h:29
Definition: XdmNode.h:31
Definition: XdmValue.h:50
Definition: Xslt30Processor.h:26
XdmValue * getParameter(const char *name)
Definition: Xslt30Processor.cpp:150
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition: Xslt30Processor.cpp:188
bool removeParameter(const char *name)
Definition: Xslt30Processor.cpp:158
XdmValue ** createXdmValueArray(int len)
Definition: Xslt30Processor.h:151
XsltExecutable * compileFromString(const char *stylesheet)
compile a stylesheet received as a string.
Definition: Xslt30Processor.cpp:322
bool exceptionOccurred()
Definition: Xslt30Processor.cpp:119
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:624
SaxonProcessor * getSaxonProcessor()
Get the SaxonProcessor object.
Definition: Xslt30Processor.h:57
SaxonApiException * getException()
Get the SaxonApiException object created when we have an error.
Definition: Xslt30Processor.cpp:209
XsltExecutable * compileFromFile(const char *stylesheet)
compile a stylesheet file.
Definition: Xslt30Processor.cpp:456
void setcwd(const char *cwd)
set the current working directory (cwd).
Definition: Xslt30Processor.cpp:203
const char * transformFileToString(const char *sourcefile, const char *stylesheetfile)
Perform a one shot transformation.
Definition: Xslt30Processor.cpp:673
void compileFromXdmNodeAndSave(XdmNode *node, const char *filename)
compile a stylesheet received as an XdmNode.
Definition: Xslt30Processor.cpp:228
void compileFromStringAndSave(const char *stylesheet, const char *filename)
compile a stylesheet received as a string and save to an exported file (SEF).
Definition: Xslt30Processor.cpp:259
void setParameter(const char *name, XdmValue *value)
Set the value of a stylesheet parameter.
Definition: Xslt30Processor.cpp:135
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition: Xslt30Processor.cpp:167
void deleteXdmValueArray(XdmValue **arr, int len)
Utility method for Python API - internal use only.
Definition: Xslt30Processor.h:168
const char * getErrorMessage()
Get the error message if there are any error.
Definition: Xslt30Processor.cpp:743
char ** createCharArray(int len)
Definition: Xslt30Processor.h:158
XdmValue * transformFileToValue(const char *sourcefile, const char *stylesheetfile)
Definition: Xslt30Processor.cpp:513
void setBaseOutputURI(const char *baseURI)
Set the base output URI.
Definition: Xslt30Processor.cpp:128
void setJustInTimeCompilation(bool jit)
Say whether just-in-time compilation of template rules should be used.
Definition: Xslt30Processor.cpp:162
void compileFromFileAndSave(const char *xslFilename, const char *filename)
compile a stylesheet received as a file and save to an exported file (SEF).
Definition: Xslt30Processor.cpp:293
XsltExecutable * compileFromXdmNode(XdmNode *node)
compile a stylesheet received as an XdmNode.
Definition: Xslt30Processor.cpp:364
const char * getErrorCode()
Get the ith error code if there are any error.
Definition: Xslt30Processor.cpp:123
XsltExecutable * compileFromAssociatedFile(const char *sourceFile)
Get the stylesheet associated.
Definition: Xslt30Processor.cpp:408
void exceptionClear()
Clear any exception thrown.
Definition: Xslt30Processor.cpp:194
Definition: XsltExecutable.h:30
void clearProperties()
Clear property values set.
Definition: XsltExecutable.cpp:430
void setProperty(const char *name, const char *value)
Definition: XsltExecutable.cpp:385