Saxon/C  1.2.1
Saxon Processor library for C/C++, PHP and Python
XPathProcessor.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_XPATH_H
9 #define SAXON_XPATH_H
10 
11 
12 
13 #include "SaxonProcessor.h"
14 //#include "XdmValue.h"
15 //#include "XdmItem.h"
16 
17 #include <string>
18 
19 class SaxonProcessor;
20 class XdmValue;
21 class XdmItem;
22 
27 public:
28 
30 
34 
35  ~XPathProcessor(){
37  clearParameters(false);
38  //delete contextItem;
39  }
40 
42 
46  XPathProcessor(SaxonProcessor* proc, std::string cwd="");
47 
49 
55  void setBaseURI(const char * uriStr);
56 
58 
62  XdmValue * evaluate(const char * xpathStr);
63 
64 
66 
70  XdmItem * evaluateSingle(const char * xpathStr);
71 
72  void setContextItem(XdmItem * item);
73 
77  void setcwd(const char* cwd);
78 
80  void setContextFile(const char * filename); //TODO: setContextItemFromFile
81 
83 
86  bool effectiveBooleanValue(const char * xpathStr);
87 
94  void setParameter(const char * name, XdmValue*value);
95 
96 
103  bool removeParameter(const char * name);
104 
106 
112  void setProperty(const char * name, const char * value);
113 
115 
125  void declareNamespace(const char *prefix, const char * uri);
126 
127 #if CVERSION_API_NO >= 121
128 
129 
130 
132 
140  void setBackwardsCompatible(bool option);
141 
142 
144 
154  void setCaching(bool caching);
155 
156 
158 
171  void importSchemaNamespace(const char * uri);
172 
173 #endif
174 
177  std::map<std::string,XdmValue*>& getParameters();
178 
182  std::map<std::string,std::string>& getProperties();
183 
190  void clearParameters(bool deleteValues=false);
191 
195  void clearProperties();
196 
202  // const char* checkException();
203 
208  bool exceptionOccurred();
209 
211  void exceptionClear();
212 
214 
218  int exceptionCount();
219 
221 
225  const char * getErrorMessage(int i);
226 
227 
229 
233  const char * getErrorCode(int i);
234 
236 
239  const char* checkException();
240 
241 
242 private:
243  SaxonProcessor * proc;
244  XdmItem * contextItem;
245  std::string cwdXP;
246  jclass cppClass;
247  jobject cppXP;
248  std::map<std::string,XdmValue*> parameters;
249  std::map<std::string,std::string> properties;
251 };
252 
253 
254 
255 
256 #endif /* SAXON_XPATH_H */
XPathProcessor()
Default constructor.
Definition: XPathProcessor.cpp:7
void declareNamespace(const char *prefix, const char *uri)
Declare a namespace binding as part of the static context for XPath expressions compiled using this X...
Definition: XPathProcessor.cpp:249
std::map< std::string, std::string > & getProperties()
Definition: XPathProcessor.cpp:424
const char * getErrorMessage(int i)
Get the ith error message if there are any error.
Definition: XPathProcessor.cpp:451
void setcwd(const char *cwd)
Definition: XPathProcessor.cpp:415
void importSchemaNamespace(const char *uri)
Import a schema namespace.
Definition: XPathProcessor.cpp:289
bool effectiveBooleanValue(const char *xpathStr)
Evaluate the XPath expression, returning the effective boolean value of the result.
Definition: XPathProcessor.cpp:320
void clearParameters(bool deleteValues=false)
Definition: XPathProcessor.cpp:394
XdmItem * evaluateSingle(const char *xpathStr)
Compile and evaluate an XPath expression. The result is expected to be a single XdmItem.
Definition: XPathProcessor.cpp:139
void setParameter(const char *name, XdmValue *value)
Definition: XPathProcessor.cpp:374
bool exceptionOccurred()
Definition: XPathProcessor.cpp:456
void setBackwardsCompatible(bool option)
Say whether XPath 1.0 backwards compatibility mode is to be used.
Definition: XPathProcessor.cpp:272
void setCaching(bool caching)
Say whether the compiler should maintain a cache of compiled expressions.
Definition: XPathProcessor.cpp:280
Definition: XdmValue.h:46
int exceptionCount()
Get number of errors reported during evaluation of the XPath.
Definition: XPathProcessor.cpp:439
std::map< std::string, XdmValue * > & getParameters()
Definition: XPathProcessor.cpp:419
void exceptionClear()
Clear any exception thrown.
Definition: XPathProcessor.cpp:429
Definition: SaxonProcessor.h:296
Definition: XdmItem.h:15
XdmValue * evaluate(const char *xpathStr)
Compile and evaluate an XPath expression.
Definition: XPathProcessor.cpp:43
const char * getErrorCode(int i)
Get the ith error code if there are any error.
Definition: XPathProcessor.cpp:446
void setBaseURI(const char *uriStr)
Set the static base URI for XPath expressions compiled using this XPathCompiler.
Definition: XPathProcessor.cpp:299
Definition: XPathProcessor.h:26
void setProperty(const char *name, const char *value)
Set a property specific to the processor in use.
Definition: XPathProcessor.cpp:385
const char * checkException()
Check for exception thrown.
Definition: XPathProcessor.cpp:462
bool removeParameter(const char *name)
Definition: XPathProcessor.cpp:381
void setContextFile(const char *filename)
Set the context item from file.
Definition: XPathProcessor.cpp:242
void clearProperties()
Definition: XPathProcessor.cpp:410