SaxonC  11.6
Saxon Processor library for C/C++, PHP and Python
XPathProcessor.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_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 SaxonApiException;
21 class XdmValue;
22 class XdmItem;
23 
28 public:
29 
31 
35 
36  ~XPathProcessor();
37 
39 
43  XPathProcessor(SaxonProcessor* proc, std::string cwd="");
44 
49  XPathProcessor(const XPathProcessor &other);
50 
52 
58  void setBaseURI(const char * uriStr);
59 
61 
65  XdmValue * evaluate(const char * xpathStr);
66 
67 
69 
74  XdmItem * evaluateSingle(const char * xpathStr);
75 
78  void setContextItem(XdmItem * item);
79 
83  void setcwd(const char* cwd);
84 
86  void setContextFile(const char * filename); //TODO: setContextItemFromFile
87 
89 
92  bool effectiveBooleanValue(const char * xpathStr);
93 
100  void setParameter(const char * name, XdmValue*value);
101 
102 
109  bool removeParameter(const char * name);
110 
112 
118  void setProperty(const char * name, const char * value);
119 
121 
131  void declareNamespace(const char *prefix, const char * uri);
132 
133 
134 
136 
144  void declareVariable(const char * name);
145 
146 
148 
156  void setBackwardsCompatible(bool option);
157 
158 
160 
170  void setCaching(bool caching);
171 
172 
174 
187  void importSchemaNamespace(const char * uri);
188 
192  std::map<std::string,XdmValue*>& getParameters();
193 
197  std::map<std::string,std::string>& getProperties();
198 
205  void clearParameters(bool deleteValues=false);
206 
210  void clearProperties();
211 
217  // const char* checkException();
218 
223  bool exceptionOccurred();
224 
226  void exceptionClear();
227 
229 
233  const char * getErrorMessage();
234 
235 
237 
241  const char * getErrorCode();
242 
243 
245 
251 
252 private:
253 
254  void createException(const char * message=nullptr);
255 
256  void setParameter(const char * name, XdmValue*value, bool withParam);
257 
258  SaxonProcessor * proc;
259  std::string cwdXP;
260  jclass cppClass;
261  jobject cppXP;
262  std::map<std::string,XdmValue*> parameters;
263  std::map<std::string,std::string> properties;
264  SaxonApiException * exception;
265 };
266 
267 
268 
269 
270 #endif /* SAXON_XPATH_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: XPathProcessor.h:27
void setContextItem(XdmItem *item)
Definition: XPathProcessor.cpp:317
std::map< std::string, XdmValue * > & getParameters()
Definition: XPathProcessor.cpp:567
bool exceptionOccurred()
Definition: XPathProcessor.cpp:603
SaxonApiException * getException()
Get the SaxonApiException object created when we have an error.
Definition: XPathProcessor.cpp:598
bool removeParameter(const char *name)
Definition: XPathProcessor.cpp:520
void setContextFile(const char *filename)
Set the context item from file.
Definition: XPathProcessor.cpp:333
void setBackwardsCompatible(bool option)
Say whether XPath 1.0 backwards compatibility mode is to be used.
Definition: XPathProcessor.cpp:391
const char * getErrorMessage()
Get the ith error message if there are any error.
Definition: XPathProcessor.cpp:593
void setBaseURI(const char *uriStr)
Set the static base URI for XPath expressions compiled using this XPathCompiler.
Definition: XPathProcessor.cpp:418
XdmItem * evaluateSingle(const char *xpathStr)
Compile and evaluate an XPath expression. The result is expected to be a single XdmItem or nullptr.
Definition: XPathProcessor.cpp:210
void clearProperties()
Definition: XPathProcessor.cpp:558
void setcwd(const char *cwd)
Definition: XPathProcessor.cpp:563
void exceptionClear()
Clear any exception thrown.
Definition: XPathProcessor.cpp:577
void setProperty(const char *name, const char *value)
Set a property specific to the processor in use.
Definition: XPathProcessor.cpp:524
void declareVariable(const char *name)
Declare a variable as part of the static context for XPath expressions compiled using this XPathCompi...
Definition: XPathProcessor.cpp:367
const char * getErrorCode()
Get the ith error code if there are any error.
Definition: XPathProcessor.cpp:588
void setCaching(bool caching)
Say whether the compiler should maintain a cache of compiled expressions.
Definition: XPathProcessor.cpp:399
std::map< std::string, std::string > & getProperties()
Definition: XPathProcessor.cpp:572
void clearParameters(bool deleteValues=false)
Definition: XPathProcessor.cpp:541
bool effectiveBooleanValue(const char *xpathStr)
Evaluate the XPath expression, returning the effective boolean value of the result.
Definition: XPathProcessor.cpp:440
void setParameter(const char *name, XdmValue *value)
Definition: XPathProcessor.cpp:516
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:343
XPathProcessor()
Default constructor.
Definition: XPathProcessor.cpp:18
void importSchemaNamespace(const char *uri)
Import a schema namespace.
Definition: XPathProcessor.cpp:408
XdmValue * evaluate(const char *xpathStr)
Compile and evaluate an XPath expression.
Definition: XPathProcessor.cpp:106
Definition: XdmItem.h:29
Definition: XdmValue.h:50