SaxonC 12.5
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
163 void setParameter(const char *name, XdmValue *value, bool withParam=true);
164
171 bool removeParameter(const char *name);
172
174
181 void setProperty(const char *name, const char *value);
182
185
196 void declareNamespace(const char *prefix, const char *uri);
197
200
209 void declareVariable(const char *name);
210
213
223 void setLanguageVersion(const char *version);
224
226
235 void setBackwardsCompatible(bool option);
236
238
247 void setCaching(bool caching);
248
250
255 void
256 setUnprefixedElementMatchingPolicy(UnprefixedElementMatchingPolicy policy);
257
263 UnprefixedElementMatchingPolicy convertEnumPolicy(int n) {
264 return static_cast<UnprefixedElementMatchingPolicy>(n);
265 }
266
268
271 UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy();
272
274
288 void importSchemaNamespace(const char *uri);
289
296 XdmValue *getParameter(const char *name, bool withParam=true);
297
301 std::map<std::string, XdmValue *> &getParameters();
302
306 std::map<std::string, std::string> &getProperties();
307
315 void clearParameters(bool deleteValues = false);
316
320 void clearProperties();
321
322
330 // const char* checkException();
331
338 bool exceptionOccurred();
339
341 void exceptionClear();
342
344
348 const char *getErrorMessage();
349
351
356 const char *getErrorCode();
357
359
365
366private:
367 void createException(const char *message = nullptr);
368
369
370 SaxonProcessor *proc;
372 std::string cwdXP;
373 char *xp_baseURI;
374 // jclass cppClass; /*!< Reference to the XPathProcessor Java class under JNI
375 // */
376 int64_t cppXP;
377 std::map<std::string, XdmValue *>
378 parameters;
380 std::map<std::string, std::string>
381 properties;
384 *exception;
385 UnprefixedElementMatchingPolicy unprefixedElementPolicy;
386};
387
388#endif /* SAXON_XPATH_H */
Definition SaxonApiException.h:23
Definition SaxonProcessor.h:117
Definition XPathProcessor.h:63
UnprefixedElementMatchingPolicy convertEnumPolicy(int n)
Definition XPathProcessor.h:263
void setContextItem(XdmItem *item)
Definition XPathProcessor.cpp:189
std::map< std::string, XdmValue * > & getParameters()
Definition XPathProcessor.cpp:403
bool exceptionOccurred()
Definition XPathProcessor.cpp:438
SaxonApiException * getException()
Get the SaxonApiException object created when we have an error.
Definition XPathProcessor.cpp:436
const char * getBaseURI()
Definition XPathProcessor.cpp:300
bool removeParameter(const char *name)
Definition XPathProcessor.cpp:358
bool effectiveBooleanValue(const char *xpathStr, const char *encoding=nullptr)
Definition XPathProcessor.cpp:309
void setContextFile(const char *filename)
Definition XPathProcessor.cpp:204
void setBackwardsCompatible(bool option)
Say whether XPath 1.0 backwards compatibility mode is to be used.
Definition XPathProcessor.cpp:258
const char * getErrorMessage()
Get the first error message if there are any errors.
Definition XPathProcessor.cpp:429
UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy()
! Get the policy for matching unprefixed element names in XPath expressions
Definition XPathProcessor.cpp:225
void setParameter(const char *name, XdmValue *value, bool withParam=true)
Definition XPathProcessor.cpp:342
void setBaseURI(const char *uriStr)
Definition XPathProcessor.cpp:290
void clearProperties()
Definition XPathProcessor.cpp:399
void setcwd(const char *cwd)
Definition XPathProcessor.cpp:401
void exceptionClear()
Clear any exception thrown.
Definition XPathProcessor.cpp:413
XdmValue * getParameter(const char *name, bool withParam=true)
Definition XPathProcessor.cpp:333
void setLanguageVersion(const char *version)
Definition XPathProcessor.cpp:266
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:362
void declareVariable(const char *name)
Definition XPathProcessor.cpp:248
const char * getErrorCode()
Get the first error code if there are any errors.
Definition XPathProcessor.cpp:422
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:274
std::map< std::string, std::string > & getProperties()
Definition XPathProcessor.cpp:408
void clearParameters(bool deleteValues=false)
Definition XPathProcessor.cpp:381
void setUnprefixedElementMatchingPolicy(UnprefixedElementMatchingPolicy policy)
Set the policy for matching unprefixed element names in XPath expressions.
Definition XPathProcessor.cpp:213
void declareNamespace(const char *prefix, const char *uri)
Definition XPathProcessor.cpp:235
XPathProcessor()
Default constructor.
Definition XPathProcessor.cpp:17
void importSchemaNamespace(const char *uri)
Import a schema namespace.
Definition XPathProcessor.cpp:282
Definition XdmItem.h:30
Definition XdmValue.h:42