SaxonC 12.8.0
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
XQueryProcessor.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_XQUERY_H
11#define SAXON_XQUERY_H
12
13#include "saxonc_export.h"
14#include "saxonc/SaxonProcessor.h"
15#include <string>
16
17class SaxonProcessor;
19class XdmValue;
20class XdmItem;
21
25class SAXONC_EXPORT XQueryProcessor {
26public:
32
38 XQueryProcessor(SaxonProcessor *p, std::string cwd = "");
39
44 XQueryProcessor(const XQueryProcessor &other);
45
52
54
60 void setContextItem(XdmItem *value);
61
66 void setOutputFile(const char *outfile);
67
72 void setContextItemFromFile(const char *filename);
73
83 void setParameter(const char *name, XdmValue *value, bool withParam=true);
84
89 void setLanguageVersion(const char *version);
90
102 void setStreaming(bool option);
103
111 bool isStreaming();
112
118 bool removeParameter(const char *name);
119
130 void setProperty(const char *name, const char *value);
131
137 const char * getProperty(const char *name);
138
146 void clearParameters(bool deleteValues = false);
147
151 void clearProperties();
152
163 void setUpdating(bool updating);
164
174 void executeQueryToFile(const char *infilename, const char *ofilename,
175 const char *query, const char *encoding = nullptr);
176
186 XdmValue *executeQueryToValue(const char *infilename, const char *query,
187 const char *encoding = nullptr);
188
200 const char *executeQueryToString(const char *infilename, const char *query,
201 const char *encoding = nullptr);
202
211
221 const char *runQueryToString();
222
230 void runQueryToFile();
231
249 void declareNamespace(const char *prefix, const char *uri);
250
257 XdmValue *getParameter(const char *name, bool withParam=true);
258
263 std::map<std::string, XdmValue *> &getParameters();
264
269 std::map<std::string, std::string> &getProperties();
270
276 void setQueryFile(const char *filename);
277
283 void setQueryContent(const char *content);
284
290 void setQueryBaseURI(const char *baseURI);
291
296 const char * getQueryBaseURI();
297
302 void setcwd(const char *cwd);
303
309 const char * getcwd();
310
316 const char *checkException();
317
324 bool exceptionOccurred();
325
330 void exceptionClear();
331
338 const char *getErrorMessage();
339
347 const char *getErrorCode();
348
357
362
363private:
364 void createException(const char *message = nullptr);
365 bool streaming;
366 std::string cwdXQ;
367 SaxonProcessor *proc;
368
369 int64_t cppXQ;
370 std::map<std::string, XdmValue *>
371 parameters;
373 std::map<std::string, std::string>
374 properties;
376 SaxonApiException *exception;
377};
378
379#endif /* SAXON_XQUERY_H */
SAXONC_EXPORT void setParameter(sxnc_parameter **parameters, int *parLen, int *parCap, const char *name, sxnc_value *value)
Set a parameter.
Definition SaxonCGlue.c:160
SAXONC_EXPORT int64_t getParameter(sxnc_parameter *parameters, int parLen, const char *name)
Get a parameter from the list.
Definition SaxonCGlue.c:136
SAXONC_EXPORT void setProperty(sxnc_property **properties, int *propLen, int *propCap, const char *name, const char *value)
Set a property.
Definition SaxonCGlue.c:186
SAXONC_EXPORT char * getProperty(sxnc_property *properties, int propLen, const char *name)
Get a property from the list.
Definition SaxonCGlue.c:148
EXTERN_SAXONC SAXONC_EXPORT const char * version(sxnc_environment *environi, sxnc_processor *proc)
Get the Saxon version.
Definition SaxonCProcessor.c:6
SAXONC_EXPORT const char * executeQueryToString(sxnc_environment *environi, sxnc_processor *proc, char *cwd, sxnc_parameter *parameters, sxnc_property *properties, int parLen, int propLen)
Execute a query with the result returned as a string value (char pointer array).
Definition SaxonCProcessor.c:186
SAXONC_EXPORT void executeQueryToFile(sxnc_environment *environi, sxnc_processor *proc, char *cwd, char *outputfile, sxnc_parameter *parameters, sxnc_property *properties, int parLen, int propLen)
Execute a query with the result saved to file.
Definition SaxonCProcessor.c:157
SaxonApiException.
Definition SaxonApiException.h:24
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition SaxonProcessor.h:117
void setOutputFile(const char *outfile)
Set the output file where the query result is sent.
Definition XQueryProcessor.cpp:138
void setcwd(const char *cwd)
Set the current working directory.
Definition XQueryProcessor.cpp:217
void setQueryBaseURI(const char *baseURI)
Set the static base URI for the query.
Definition XQueryProcessor.cpp:227
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition XQueryProcessor.cpp:194
void setQueryFile(const char *filename)
Compile a query file.
Definition XQueryProcessor.cpp:342
const char * checkException()
Check for thrown exceptions.
Definition XQueryProcessor.cpp:393
void setStreaming(bool option)
Say whether the query should be compiled and evaluated to use streaming.
Definition XQueryProcessor.cpp:347
bool exceptionOccurred()
Deprecated.
Definition XQueryProcessor.cpp:375
const char * getQueryBaseURI()
Get the static base URI for the query.
Definition XQueryProcessor.cpp:231
void runQueryToFile()
Execute a query as already configured for this XQueryProcessor, and save the result to file.
Definition XQueryProcessor.cpp:338
const char * getErrorCode()
Deprecated.
Definition XQueryProcessor.cpp:379
void declareNamespace(const char *prefix, const char *uri)
Declare a namespace binding as part of the static context for queries compiled using this XQueryCompi...
Definition XQueryProcessor.cpp:111
void setContextItem(XdmItem *value)
Set the initial context item for the query as an XdmItem.
Definition XQueryProcessor.cpp:96
XdmValue * runQueryToValue()
Execute a query as already configured for this XQueryProcessor, returning the result as an XdmValue.
Definition XQueryProcessor.cpp:334
std::map< std::string, std::string > & getProperties()
Get all configuration properties specified on the processor as a std::map.
Definition XQueryProcessor.cpp:90
void clearProperties()
Clear configuration property values set.
Definition XQueryProcessor.cpp:212
void exceptionClear()
Deprecated.
Definition XQueryProcessor.cpp:367
void setLanguageVersion(const char *version)
Set the XQuery language version for the XQuery compiler.
Definition XQueryProcessor.cpp:358
XdmValue * executeQueryToValue(const char *infilename, const char *query, const char *encoding=nullptr)
Execute a query, returning the result as an XdmValue.
Definition XQueryProcessor.cpp:272
void setUpdating(bool updating)
Say whether the query is allowed to be updating.
Definition XQueryProcessor.cpp:235
const char * runQueryToString()
Execute a query as already configured for this XQueryProcessor, returning the result as a string.
Definition XQueryProcessor.cpp:330
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition XQueryProcessor.cpp:85
void setContextItemFromFile(const char *filename)
Set the context item for the query as a source document.
Definition XQueryProcessor.cpp:133
void setQueryContent(const char *content)
Compile a query supplied as a string.
Definition XQueryProcessor.cpp:362
bool isStreaming()
Ask whether the streaming option has been set.
Definition XQueryProcessor.cpp:356
const char * getcwd()
Get the current working directory set on this XQueryProcessor.
Definition XQueryProcessor.cpp:223
bool removeParameter(const char *name)
Remove a parameter (name, value) pair.
Definition XQueryProcessor.cpp:167
const char * getErrorMessage()
Deprecated.
Definition XQueryProcessor.cpp:386
SaxonApiException * getException()
Deprecated.
Definition XQueryProcessor.cpp:402
XQueryProcessor()
Default constructor.
Definition XQueryProcessor.cpp:14
XQueryProcessor * clone()
Create a clone of this XQueryProcessor object with the same internal state, which can be used in sepa...
Definition XQueryProcessor.cpp:81
SaxonProcessor * getSaxonProcessor()
Get the SaxonProcessor which created this XQueryProcessor.
Definition XQueryProcessor.h:361
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