Saxon/C  1.2.1
Saxon Processor library for C/C++, PHP and Python
XsltProcessor.h
1 // Copyright (c) 2015 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_XSLT_H
9 #define SAXON_XSLT_H
10 
11 
12 #include "SaxonProcessor.h"
13 //#include "XdmValue.h"
14 #include <string>
15 
16 class SaxonProcessor;
17 class XdmValue;
18 class XdmItem;
19 class XdmNode;
20 
25 
26 public:
27 
29 
32  XsltProcessor();
33 
35 
39  XsltProcessor(SaxonProcessor* proc, std::string cwd="");
40 
41  ~XsltProcessor(){
44  }
45 
47 
51 
53 
56  void setcwd(const char* cwd);
57 
58 
59 
61 
64  void setSourceFromXdmNode(XdmNode * value);
65 
69  void setSourceFromFile(const char * filename);
70 
74  void setOutputFile(const char* outfile);
75 
76 
92  void setJustInTimeCompilation(bool jit);
93 
100  void setParameter(const char* name, XdmValue*value);
101 
107  XdmValue* getParameter(const char* name);
108 
109 
116  bool removeParameter(const char* name);
117 
126  void setProperty(const char* name, const char* value);
127 
133  const char* getProperty(const char* name);
134 
136 
142  std::map<std::string,XdmValue*>& getParameters();
143 
145 
149  std::map<std::string,std::string>& getProperties();
150 
152 
157  void clearParameters(bool deleteValues=false);
158 
160  void clearProperties();
161 
166  XdmValue * getXslMessages();//TODO allow notification of message as they occur
167 
168 
170 
177  void transformFileToFile(const char* sourcefile, const char* stylesheetfile, const char* outputfile);
178 
180 
187  const char * transformFileToString(const char* sourcefile, const char* stylesheetfile);
188 
196  XdmValue * transformFileToValue(const char* sourcefile, const char* stylesheetfile);
197 
198 
200 
204  void compileFromFile(const char* stylesheet);
205 
207 
212  void compileFromString(const char* stylesheet);
213 
214 
216 
222  void compileFromStringAndSave(const char* stylesheet, const char* filename);
223 
224 
226 
232  void compileFromFileAndSave(const char* xslFilename, const char* filename);
233 
234 
236 
241  void compileFromXdmNodeAndSave(XdmNode * node, const char* filename);
242 
244 
248  void compileFromXdmNode(XdmNode * node);
249 
250 
252 
256  void releaseStylesheet();
257 
258 
260 
265  const char * transformToString();
266 
268 
274 
276 
283  void transformToFile();
284 
289  bool exceptionOccurred();
290 
291 
293 
296  const char* checkException();
297 
298 
300  void exceptionClear();
301 
303 
307  int exceptionCount();
308 
310 
314  const char * getErrorMessage(int i);
315 
317 
321  const char * getErrorCode(int i);
322 
323 
324 
325 private:
326  SaxonProcessor* proc;
327  jclass cppClass;
328  jobject cppXT, stylesheetObject, xdmValuei;
329  std::string cwdXT;
330  std::string outputfile1;
331  std::string failure; //for testing
332  bool nodeCreated;
333  std::map<std::string,XdmValue*> parameters;
334  std::map<std::string,std::string> properties;
336 };
337 
338 
339 #endif /* SAXON_XSLT_H */
SaxonProcessor * getSaxonProcessor()
Get the SaxonProcessor object.
Definition: XsltProcessor.h:50
int exceptionCount()
Get number of errors reported during execution or evaluate of stylesheet.
Definition: XsltProcessor.cpp:192
void compileFromString(const char *stylesheet)
compile a stylesheet received as a string.
Definition: XsltProcessor.cpp:269
void clearProperties()
Clear property values set.
Definition: XsltProcessor.cpp:153
void transformToFile()
Execute transformation to file. Properties supplied in advance.
Definition: XsltProcessor.cpp:700
XsltProcessor()
Default constructor.
Definition: XsltProcessor.cpp:15
void setSourceFromFile(const char *filename)
Definition: XsltProcessor.cpp:67
void compileFromFileAndSave(const char *xslFilename, const char *filename)
compile a stylesheet received as a file and save to an exported file (SEF).
Definition: XsltProcessor.cpp:247
Definition: XdmNode.h:21
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition: XsltProcessor.cpp:159
const char * getErrorMessage(int i)
Get the ith error message if there are any error.
Definition: XsltProcessor.cpp:708
const char * getProperty(const char *name)
Definition: XsltProcessor.cpp:119
Definition: XdmValue.h:46
void compileFromStringAndSave(const char *stylesheet, const char *filename)
compile a stylesheet received as a string and save to an exported file (SEF).
Definition: XsltProcessor.cpp:224
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition: XsltProcessor.cpp:164
void compileFromXdmNodeAndSave(XdmNode *node, const char *filename)
compile a stylesheet received as an XdmNode.
Definition: XsltProcessor.cpp:200
XdmValue * getXslMessages()
Definition: XsltProcessor.cpp:535
const char * checkException()
Check for exception thrown.
Definition: XsltProcessor.cpp:184
void compileFromXdmNode(XdmNode *node)
compile a stylesheet received as an XdmNode.
Definition: XsltProcessor.cpp:291
Definition: XsltProcessor.h:24
XdmValue * getParameter(const char *name)
Definition: XsltProcessor.cpp:85
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition: XsltProcessor.cpp:127
void transformFileToFile(const char *sourcefile, const char *stylesheetfile, const char *outputfile)
Perform a one shot transformation.
Definition: XsltProcessor.cpp:434
Definition: SaxonProcessor.h:296
Definition: XdmItem.h:15
void setJustInTimeCompilation(bool jit)
Definition: XsltProcessor.cpp:97
const char * getErrorCode(int i)
Get the ith error code if there are any error.
Definition: XsltProcessor.cpp:55
void exceptionClear()
Clear any exception thrown.
Definition: XsltProcessor.cpp:169
void setParameter(const char *name, XdmValue *value)
Definition: XsltProcessor.cpp:78
bool exceptionOccurred()
Definition: XsltProcessor.cpp:51
void setOutputFile(const char *outfile)
Definition: XsltProcessor.cpp:73
XdmValue * transformToValue()
Execute transformation to Xdm Value. Properties supplied in advance.
Definition: XsltProcessor.cpp:692
void compileFromFile(const char *stylesheet)
compile a stylesheet file.
Definition: XsltProcessor.cpp:314
void setSourceFromXdmNode(XdmNode *value)
Set the source document from an XdmNode for the transformation.
Definition: XsltProcessor.cpp:60
void setcwd(const char *cwd)
set the current working directory
Definition: XsltProcessor.cpp:178
XdmValue * transformFileToValue(const char *sourcefile, const char *stylesheetfile)
Definition: XsltProcessor.cpp:347
void releaseStylesheet()
Internal method to release cached stylesheet.
Definition: XsltProcessor.cpp:339
void setProperty(const char *name, const char *value)
Definition: XsltProcessor.cpp:113
const char * transformFileToString(const char *sourcefile, const char *stylesheetfile)
Perform a one shot transformation.
Definition: XsltProcessor.cpp:567
bool removeParameter(const char *name)
Definition: XsltProcessor.cpp:93
const char * transformToString()
Execute transformation to string. Properties supplied in advance.
Definition: XsltProcessor.cpp:683