SaxonC 12.4
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
XPathProcessor.h
1
2// Copyright (c) 2022 - 2023 Saxonica Limited.
3// This Source Code Form is subject to the terms of the Mozilla Public License,
4// v. 2.0. If a copy of the MPL was not distributed with this file, You can
5// obtain one at http://mozilla.org/MPL/2.0/. This Source Code Form is
6// "Incompatible With Secondary Licenses", as defined by the Mozilla Public
7// License, v. 2.0.
9
10#ifndef SAXON_XPATH_H
11#define SAXON_XPATH_H
12
13#include "SaxonProcessor.h"
14//#include "XdmValue.h"
15//#include "XdmItem.h"
16
17#include <string>
18
19class SaxonProcessor;
21class XdmValue;
22class XdmItem;
23
24enum class UnprefixedElementMatchingPolicy {
25
33 DEFAULT_NAMESPACE = 0,
39 ANY_NAMESPACE = 1,
57 DEFAULT_NAMESPACE_OR_NONE = 2
58};
59
64public:
66
70
72
74
79 XPathProcessor(SaxonProcessor *proc, std::string cwd = "");
80
85 XPathProcessor(const XPathProcessor &other);
86
89
96 void setBaseURI(const char *uriStr);
97
100
103 const char *getBaseURI();
104
106
113 XdmValue *evaluate(const char *xpathStr, const char *encoding = nullptr);
114
117
127 XdmItem *evaluateSingle(const char *xpathStr, const char *encoding = nullptr);
128
131 void setContextItem(XdmItem *item);
132
136 void setcwd(const char *cwd);
137
140 void setContextFile(const char *filename);
141
144
150 bool effectiveBooleanValue(const char *xpathStr,
151 const char *encoding = nullptr);
152
161 void setParameter(const char *name, XdmValue *value);
162
169 bool removeParameter(const char *name);
170
172
179 void setProperty(const char *name, const char *value);
180
183
194 void declareNamespace(const char *prefix, const char *uri);
195
198
207 void declareVariable(const char *name);
208
211
221 void setLanguageVersion(const char *version);
222
224
233 void setBackwardsCompatible(bool option);
234
236
245 void setCaching(bool caching);
246
248
253 void
254 setUnprefixedElementMatchingPolicy(UnprefixedElementMatchingPolicy policy);
255
256 UnprefixedElementMatchingPolicy convertEnumPolicy(int n) {
257 return static_cast<UnprefixedElementMatchingPolicy>(n);
258 }
259
261
264 UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy();
265
267
281 void importSchemaNamespace(const char *uri);
282
286 std::map<std::string, XdmValue *> &getParameters();
287
291 std::map<std::string, std::string> &getProperties();
292
300 void clearParameters(bool deleteValues = false);
301
305 void clearProperties();
306
314 // const char* checkException();
315
322 bool exceptionOccurred();
323
325 void exceptionClear();
326
328
332 const char *getErrorMessage();
333
335
340 const char *getErrorCode();
341
343
349
350private:
351 void createException(const char *message = nullptr);
352
353 void setParameter(const char *name, XdmValue *value, bool withParam);
354
355 SaxonProcessor *proc;
357 std::string cwdXP;
358 char *xp_baseURI;
359 // jclass cppClass; /*!< Reference to the XPathProcessor Java class under JNI
360 // */
361 int64_t cppXP;
362 std::map<std::string, XdmValue *>
363 parameters;
365 std::map<std::string, std::string>
366 properties;
369 *exception;
370 UnprefixedElementMatchingPolicy unprefixedElementPolicy;
371};
372
373#endif /* SAXON_XPATH_H */
Definition SaxonApiException.h:23
Definition SaxonProcessor.h:117
Definition XPathProcessor.h:63
void setContextItem(XdmItem *item)
Definition XPathProcessor.cpp:189
std::map< std::string, XdmValue * > & getParameters()
Definition XPathProcessor.cpp:397
bool exceptionOccurred()
Definition XPathProcessor.cpp:432
SaxonApiException * getException()
Get the SaxonApiException object created when we have an error.
Definition XPathProcessor.cpp:430
const char * getBaseURI()
Definition XPathProcessor.cpp:301
bool removeParameter(const char *name)
Definition XPathProcessor.cpp:353
bool effectiveBooleanValue(const char *xpathStr, const char *encoding=nullptr)
Definition XPathProcessor.cpp:310
void setContextFile(const char *filename)
Definition XPathProcessor.cpp:205
void setBackwardsCompatible(bool option)
Say whether XPath 1.0 backwards compatibility mode is to be used.
Definition XPathProcessor.cpp:259
const char * getErrorMessage()
Get the first error message if there are any errors.
Definition XPathProcessor.cpp:423
UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy()
! Get the policy for matching unprefixed element names in XPath expressions
Definition XPathProcessor.cpp:226
void setBaseURI(const char *uriStr)
Definition XPathProcessor.cpp:291
void clearProperties()
Definition XPathProcessor.cpp:393
void setcwd(const char *cwd)
Definition XPathProcessor.cpp:395
void exceptionClear()
Clear any exception thrown.
Definition XPathProcessor.cpp:407
void setLanguageVersion(const char *version)
Definition XPathProcessor.cpp:267
XdmValue * evaluate(const char *xpathStr, const char *encoding=nullptr)
Compile and evaluate an XPath expression.
Definition XPathProcessor.cpp:106
void setProperty(const char *name, const char *value)
Set a property specific to the processor in use.
Definition XPathProcessor.cpp:357
void declareVariable(const char *name)
Definition XPathProcessor.cpp:249
const char * getErrorCode()
Get the first error code if there are any errors.
Definition XPathProcessor.cpp:416
XdmItem * evaluateSingle(const char *xpathStr, const char *encoding=nullptr)
Definition XPathProcessor.cpp:134
void setCaching(bool caching)
Say whether the compiler should maintain a cache of compiled expressions.
Definition XPathProcessor.cpp:275
std::map< std::string, std::string > & getProperties()
Definition XPathProcessor.cpp:402
void clearParameters(bool deleteValues=false)
Definition XPathProcessor.cpp:375
void setUnprefixedElementMatchingPolicy(UnprefixedElementMatchingPolicy policy)
Set the policy for matching unprefixed element names in XPath expressions.
Definition XPathProcessor.cpp:214
void setParameter(const char *name, XdmValue *value)
Definition XPathProcessor.cpp:349
void declareNamespace(const char *prefix, const char *uri)
Definition XPathProcessor.cpp:236
XPathProcessor()
Default constructor.
Definition XPathProcessor.cpp:17
void importSchemaNamespace(const char *uri)
Import a schema namespace.
Definition XPathProcessor.cpp:283
Definition XdmItem.h:30
Definition XdmValue.h:42