SaxonC 13.0.0
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
XPathProcessor.h
1
2// Copyright (c) 2022 - 2025 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 "saxonc_export.h"
14#include "saxonc/SaxonProcessor.h"
15#include "saxonc/XsdSchema.h"
16//#include "XdmValue.h"
17//#include "XdmItem.h"
18
19
20#include <string>
21
22class SaxonProcessor;
24class XdmValue;
25class XdmItem;
26class XsdSchema;
27
28enum class SAXONC_EXPORT UnprefixedElementMatchingPolicy {
29
37 DEFAULT_NAMESPACE = 0,
43 ANY_NAMESPACE = 1,
61 DEFAULT_NAMESPACE_OR_NONE = 2
62};
63
67class SAXONC_EXPORT XPathProcessor {
68public:
75
77
84 XPathProcessor(SaxonProcessor *proc, std::string cwd = "");
85
90 XPathProcessor(const XPathProcessor &other);
91
101 void setBaseURI(const char *uriStr);
102
108 const char *getBaseURI();
109
120 XdmValue *evaluate(const char *xpathStr, const char *encoding = nullptr);
121
134 XdmItem *evaluateSingle(const char *xpathStr, const char *encoding = nullptr);
135
139 void setContextItem(XdmItem *item);
140
145 void setcwd(const char *cwd);
146
152 const char * getcwd();
153
156 void setContextFile(const char *filename);
157
166 bool effectiveBooleanValue(const char *xpathStr,
167 const char *encoding = nullptr);
168
178
179 void setParameter(const char *name, XdmValue *value, bool withParam=true);
180
187 bool removeParameter(const char *name);
188
197 void setProperty(const char *name, const char *value);
198
204 const char * getProperty(const char *name);
205
217 void declareNamespace(const char *prefix, const char *uri);
218
231 void declareVariable(const char *name);
232
244 void setLanguageVersion(const char *version);
245
256 void setBackwardsCompatible(bool option);
257
267
268 void setCaching(bool caching);
269
277 void
278 setUnprefixedElementMatchingPolicy(UnprefixedElementMatchingPolicy policy);
279
286 UnprefixedElementMatchingPolicy convertEnumPolicy(int n) {
287 return static_cast<UnprefixedElementMatchingPolicy>(n);
288 }
289
294 UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy();
295
311 void importSchemaNamespace(const char *uri);
312
313
323
324 void useSchema(XsdSchema * schema);
325
326
340 void setSchemaAware(bool schemaAware);
341
342 bool isSchemaAware();
343
350 XdmValue *getParameter(const char *name, bool withParam=true);
351
355 std::map<std::string, XdmValue *> &getParameters();
356
360 std::map<std::string, std::string> &getProperties();
361
369 void clearParameters(bool deleteValues = false);
370
374 void clearProperties();
375
379 SaxonProcessor* getSaxonProcessor() ;
380
381private:
382
383 int64_t procRef;
384 std::string cwdXP;
385 char *xp_baseURI;
386 // jclass cppClass; /*!< Reference to the XPathProcessor Java class under JNI
387 // */
388 int64_t cppXP;
389 std::map<std::string, XdmValue *>
390 parameters;
392 std::map<std::string, std::string>
393 properties;
395 UnprefixedElementMatchingPolicy unprefixedElementPolicy;
396};
397
398#endif /* SAXON_XPATH_H */
SAXONC_EXPORT void setParameter(sxnc_parameter **parameters, int *parLen, int *parCap, const char *name, sxnc_value *value)
Set a parameter.
Definition SaxonCGlue.c:202
SAXONC_EXPORT int64_t getParameter(sxnc_parameter *parameters, int parLen, const char *name)
Get a parameter from the list.
Definition SaxonCGlue.c:178
SAXONC_EXPORT void setProperty(sxnc_property **properties, int *propLen, int *propCap, const char *name, const char *value)
Set a property.
Definition SaxonCGlue.c:228
SAXONC_EXPORT char * getProperty(sxnc_property *properties, int propLen, const char *name)
Get a property from the list.
Definition SaxonCGlue.c:190
EXTERN_SAXONC SAXONC_EXPORT const char * version(sxnc_environment *environi, sxnc_processor *proc)
Get the Saxon version.
Definition SaxonCProcessor.c:6
SAXONC_EXPORT sxnc_value * evaluate(sxnc_environment *environi, sxnc_xpath *proc, char *cwd, char *xpathStr, char *encoding, sxnc_parameter *parameters, sxnc_property *properties, int parLen, int propLen)
Compile and evaluate an XPath expression, supplied as a character string, with properties and paramet...
Definition SaxonCXPath.c:82
SAXONC_EXPORT sxnc_value * evaluateSingle(sxnc_environment *environi, sxnc_xpath *proc, char *cwd, char *xpathStr, char *encoding, sxnc_parameter *parameters, sxnc_property *properties, int parLen, int propLen)
Compile and evaluate an XPath expression for which the result is expected to be a single XdmItem or N...
Definition SaxonCXPath.c:130
SAXONC_EXPORT bool effectiveBooleanValue(sxnc_environment *environi, sxnc_xpath *proc, char *cwd, char *xpathStr, char *encoding, sxnc_parameter *parameters, sxnc_property *properties, int parLen, int propLen)
Evaluate an XPath expression, returning the effective boolean value of the result.
Definition SaxonCXPath.c:186
SaxonApiException.
Definition SaxonApiException.h:25
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition SaxonProcessor.h:137
UnprefixedElementMatchingPolicy convertEnumPolicy(int n)
Convert an int into an UnprefixedElementMatchingPolicy.
Definition XPathProcessor.h:286
void setContextItem(XdmItem *item)
Set the context item for the expression.
Definition XPathProcessor.cpp:180
const char * getBaseURI()
Get the static base URI for XPath expressions compiled using this XPathProcessor.
Definition XPathProcessor.cpp:345
bool removeParameter(const char *name)
Remove a parameter (name, value) pair.
Definition XPathProcessor.cpp:401
void setContextFile(const char *filename)
Set the context item from file.
Definition XPathProcessor.cpp:195
void setBackwardsCompatible(bool option)
Say whether XPath 1.0 backwards compatibility mode is to be used.
Definition XPathProcessor.cpp:301
void setBaseURI(const char *uriStr)
Set the static base URI for XPath expressions compiled using this XPathProcessor.
Definition XPathProcessor.cpp:331
void setcwd(const char *cwd)
Set the current working directory.
Definition XPathProcessor.cpp:452
void setLanguageVersion(const char *version)
Say whether an XPath 2.0, XPath 3.0, XPath 3.1 or XPath 4.0 processor is required.
Definition XPathProcessor.cpp:309
const char * getcwd()
Get the current working directory set on this XPathProcessor.
Definition XPathProcessor.cpp:459
void declareVariable(const char *name)
Declare a variable as part of the static context for XPath expressions compiled using this XPathProce...
Definition XPathProcessor.cpp:288
void setCaching(bool caching)
Say whether the compiler should maintain a cache of compiled expressions.
Definition XPathProcessor.cpp:317
void setUnprefixedElementMatchingPolicy(UnprefixedElementMatchingPolicy policy)
Set the policy for matching unprefixed element names in XPath expressions.
Definition XPathProcessor.cpp:247
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:269
XPathProcessor()
Default constructor.
Definition XPathProcessor.cpp:18
The class XdmItem represents an item in a sequence, as defined by the XDM data model.
Definition XdmItem.h:31
An XdmValue represents a value in the XDM data model.
Definition XdmValue.h:33
Definition XsdSchema.h:26