Saxon/C  1.2.1
Saxon Processor library for C/C++, PHP and Python
XQueryProcessor.h
1 // Copyright (c) 2013 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_XQUERY_H
9 #define SAXON_XQUERY_H
10 
11 
12 
13 #include "SaxonProcessor.h"
14 //#include "XdmValue.h"
15 #include <string>
16 
17 
18 
19 class SaxonProcessor;
20 class XdmValue;
21 class XdmItem;
22 
27 public:
28 
31 
33 
37  XQueryProcessor(SaxonProcessor *p, std::string cwd="");
38 
39  ~XQueryProcessor(){
42  }
43 
45 
48  void setContextItem(XdmItem * value);
49 
53  void setOutputFile(const char* outfile);
54 
58  void setContextItemFromFile(const char * filename);
59 
66  void setParameter(const char * name, XdmValue*value);
67 
68 
76  bool removeParameter(const char * name);
77 
86  void setProperty(const char * name, const char * value);
87 
94  void clearParameters(bool deleteValues=false);
95 
99  void clearProperties();
100 
101 
109  void setUpdating(bool updating);
110 
111 
113 
120  void executeQueryToFile(const char * infilename, const char * ofilename, const char * query);
121 
123 
129  XdmValue * executeQueryToValue(const char * infilename, const char * query);
130 
131 
133 
138  const char * executeQueryToString(const char * infilename, const char * query);
139 
141 
147 
154  const char * runQueryToString();
155 
156 
158 
164  void runQueryToFile();
165 
167 
181  void declareNamespace(const char *prefix, const char * uri);
182 
183 
185 
188  std::map<std::string,XdmValue*>& getParameters();
189 
191 
194  std::map<std::string,std::string>& getProperties();
195 
197 
200  void setQueryFile(const char* filename);
201 
203 
206  void setQueryContent(const char* content);
207 
209 
212  void setQueryBaseURI(const char * baseURI);
213 
217  void setcwd(const char* cwd);
218 
219 
221 
224  const char* checkException();
225 
230  bool exceptionOccurred();
231 
233  void exceptionClear();
234 
236 
240  int exceptionCount();
241 
242 
244 
248  const char * getErrorMessage(int i);
249 
250 
252 
256  const char * getErrorCode(int i);
257 
258 
259 private:
260  std::string cwdXQ;
261  SaxonProcessor * proc;
262  jclass cppClass;
263  jobject cppXQ;
264  //std::string outputfile1; /*!< output file where result will be saved */
265  bool queryFileExists;
266  std::string failure; //for testing
267  std::map<std::string,XdmValue*> parameters;
268  std::map<std::string,std::string> properties;
269 };
270 
271 #endif /* SAXON_XQUERY_H */
void setParameter(const char *name, XdmValue *value)
Definition: XQueryProcessor.cpp:101
void declareNamespace(const char *prefix, const char *uri)
Declare a namespace binding.
Definition: XQueryProcessor.cpp:59
Definition: XQueryProcessor.h:26
void setContextItemFromFile(const char *filename)
Definition: XQueryProcessor.cpp:83
const char * getErrorMessage(int i)
Get the ith error message if there are any error.
Definition: XQueryProcessor.cpp:448
void setQueryFile(const char *filename)
Compile a query supplied as a file name.
Definition: XQueryProcessor.cpp:412
const char * executeQueryToString(const char *infilename, const char *query)
Perform the Query to a string representation.
Definition: XQueryProcessor.cpp:336
void setQueryContent(const char *content)
Compile a query supplied as a string.
Definition: XQueryProcessor.cpp:418
const char * getErrorCode(int i)
Get the i&#39;th error code if there are any error.
Definition: XQueryProcessor.cpp:443
int exceptionCount()
Get number of errors reported during execution of the query.
Definition: XQueryProcessor.cpp:463
XQueryProcessor()
Default constructor.
Definition: XQueryProcessor.cpp:7
XdmValue * executeQueryToValue(const char *infilename, const char *query)
Perform the Query to a XdmValue representation.
Definition: XQueryProcessor.cpp:247
Definition: XdmValue.h:46
void clearProperties()
Definition: XQueryProcessor.cpp:159
bool removeParameter(const char *name)
Definition: XQueryProcessor.cpp:116
void exceptionClear()
Clear any exception thrown.
Definition: XQueryProcessor.cpp:426
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition: XQueryProcessor.cpp:37
const char * runQueryToString()
Definition: XQueryProcessor.cpp:398
void setQueryBaseURI(const char *baseURI)
Set the static base URI for the query.
Definition: XQueryProcessor.cpp:169
Definition: SaxonProcessor.h:296
Definition: XdmItem.h:15
std::map< std::string, std::string > & getProperties()
Get all properties as a std::map.
Definition: XQueryProcessor.cpp:42
void setUpdating(bool updating)
Definition: XQueryProcessor.cpp:174
void setcwd(const char *cwd)
Definition: XQueryProcessor.cpp:165
XdmValue * runQueryToValue()
Execute the Query cached.
Definition: XQueryProcessor.cpp:404
void setOutputFile(const char *outfile)
Definition: XQueryProcessor.cpp:90
void clearParameters(bool deleteValues=false)
Definition: XQueryProcessor.cpp:134
void setContextItem(XdmItem *value)
Set the initial context item for the query.
Definition: XQueryProcessor.cpp:51
void runQueryToFile()
Execute the Query cached to file.
Definition: XQueryProcessor.cpp:408
bool exceptionOccurred()
Definition: XQueryProcessor.cpp:437
const char * checkException()
Check for exception thrown.
Definition: XQueryProcessor.cpp:453
void setProperty(const char *name, const char *value)
Definition: XQueryProcessor.cpp:125
void executeQueryToFile(const char *infilename, const char *ofilename, const char *query)
Perform the Query to file.
Definition: XQueryProcessor.cpp:191