Saxon/C  1.1.2
Saxon Processor library for C/C++/PHP
 All Classes Functions Variables
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 
50  void setcwd(const char* cwd);
51 
52 
54 
57  void setSourceFromXdmValue(XdmItem * value);
58 
62  void setSourceFromFile(const char * filename);
63 
67  void setOutputFile(const char* outfile);
68 
75  void setParameter(const char* name, XdmValue*value);
76 
82  XdmValue* getParameter(const char* name);
83 
84 
91  bool removeParameter(const char* name);
92 
101  void setProperty(const char* name, const char* value);
102 
108  const char* getProperty(const char* name);
109 
111 
117  std::map<std::string,XdmValue*>& getParameters();
118 
120 
124  std::map<std::string,std::string>& getProperties();
125 
127 
132  void clearParameters(bool deleteValues=false);
133 
135  void clearProperties();
136 
141  XdmValue * getXslMessages();//TODO allow notification of message as they occur
142 
143 
145 
152  void transformFileToFile(const char* sourcefile, const char* stylesheetfile, const char* outputfile);
153 
155 
162  const char * transformFileToString(const char* sourcefile, const char* stylesheetfile);
163 
171  XdmValue * transformFileToValue(const char* sourcefile, const char* stylesheetfile);
172 
173 
175 
179  void compileFromFile(const char* stylesheet);
180 
182 
187  void compileFromString(const char* stylesheet);
188 
189 
191 
197  void compileFromStringAndSave(const char* stylesheet, const char* filename);
198 
199 
201 
207  void compileFromFileAndSave(const char* xslFilename, const char* filename);
208 
209 
211 
215  void compileFromXdmNode(XdmNode * node);
216 
217 
219 
223  void releaseStylesheet();
224 
225 
227 
232  const char * transformToString();
233 
235 
241 
243 
250  void transformToFile();
251 
256  bool exceptionOccurred();
257 
258 
260 
263  const char* checkException();
264 
265 
267  void exceptionClear();
268 
270 
274  int exceptionCount();
275 
277 
281  const char * getErrorMessage(int i);
282 
284 
288  const char * getErrorCode(int i);
289 
290 
291 
292 
294 
298 
299 
300 private:
301  SaxonProcessor* proc;
302  jclass cppClass;
303  jobject cppXT, stylesheetObject, xdmValuei;
304  std::string cwdXT;
305  std::string outputfile1;
306  std::string failure; //for testing
307  bool nodeCreated;
308  std::map<std::string,XdmValue*> parameters;
309  std::map<std::string,std::string> properties;
311 };
312 
313 
314 #endif /* SAXON_XSLT_H */
SaxonProcessor * getSaxonProcessor()
Get the SaxonProcessor object.
Definition: XsltProcessor.h:297
int exceptionCount()
Get number of errors reported during execution or evaluate of stylesheet.
Definition: XsltProcessor.cpp:177
void compileFromString(const char *stylesheet)
compile a stylesheet received as a string.
Definition: XsltProcessor.cpp:231
void setSourceFromXdmValue(XdmItem *value)
Set the source document from a XdmValue for the transformation.
Definition: XsltProcessor.cpp:63
void clearProperties()
Clear property values set.
Definition: XsltProcessor.cpp:140
void transformToFile()
Execute transformation to file. Properties supplied in advance.
Definition: XsltProcessor.cpp:671
XsltProcessor()
Default constructor.
Definition: XsltProcessor.cpp:15
void setSourceFromFile(const char *filename)
Definition: XsltProcessor.cpp:70
void compileFromFileAndSave(const char *xslFilename, const char *filename)
compile a stylesheet received as a fileand save to SEF file.
Definition: XsltProcessor.cpp:209
Definition: XdmNode.h:21
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition: XsltProcessor.cpp:146
const char * getErrorMessage(int i)
Get the ith error message if there are any error.
Definition: XsltProcessor.cpp:679
const char * getProperty(const char *name)
Definition: XsltProcessor.cpp:106
Definition: XdmValue.h:44
void compileFromStringAndSave(const char *stylesheet, const char *filename)
compile a stylesheet received as a string and save to SEF file.
Definition: XsltProcessor.cpp:186
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition: XsltProcessor.cpp:151
XdmValue * getXslMessages()
Definition: XsltProcessor.cpp:500
const char * checkException()
Check for exception thrown.
Definition: XsltProcessor.cpp:169
void compileFromXdmNode(XdmNode *node)
compile a stylesheet received as an XdmNode.
Definition: XsltProcessor.cpp:253
Definition: XsltProcessor.h:24
XdmValue * getParameter(const char *name)
Definition: XsltProcessor.cpp:88
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition: XsltProcessor.cpp:114
void transformFileToFile(const char *sourcefile, const char *stylesheetfile, const char *outputfile)
Perform a one shot transformation.
Definition: XsltProcessor.cpp:394
Definition: SaxonProcessor.h:290
Definition: XdmItem.h:15
const char * getErrorCode(int i)
Get the ith error code if there are any error.
Definition: XsltProcessor.cpp:58
void exceptionClear()
Clear any exception thrown.
Definition: XsltProcessor.cpp:156
void setParameter(const char *name, XdmValue *value)
Definition: XsltProcessor.cpp:81
bool exceptionOccurred()
Definition: XsltProcessor.cpp:54
void setOutputFile(const char *outfile)
Definition: XsltProcessor.cpp:76
XdmValue * transformToValue()
Execute transformation to Xdm Value. Properties supplied in advance.
Definition: XsltProcessor.cpp:663
void compileFromFile(const char *stylesheet)
compile a stylesheet file.
Definition: XsltProcessor.cpp:276
void setcwd(const char *cwd)
set the current working directory
Definition: XsltProcessor.cpp:165
XdmValue * transformFileToValue(const char *sourcefile, const char *stylesheetfile)
Definition: XsltProcessor.cpp:309
void releaseStylesheet()
Internal method to release cached stylesheet.
Definition: XsltProcessor.cpp:301
void setProperty(const char *name, const char *value)
Definition: XsltProcessor.cpp:100
const char * transformFileToString(const char *sourcefile, const char *stylesheetfile)
Perform a one shot transformation.
Definition: XsltProcessor.cpp:532
bool removeParameter(const char *name)
Definition: XsltProcessor.cpp:96
const char * transformToString()
Execute transformation to string. Properties supplied in advance.
Definition: XsltProcessor.cpp:654