SaxonC 13.0.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 "saxonc/XsdSchema.h"
16#include <string>
17
18class SaxonProcessor;
20class XdmValue;
21class XdmItem;
22
26class SAXONC_EXPORT XQueryProcessor {
27public:
33
39 XQueryProcessor(SaxonProcessor *p, std::string cwd = "");
40
45 XQueryProcessor(const XQueryProcessor &other);
46
53
55
61 void setContextItem(XdmItem *value);
62
67 void setOutputFile(const char *outfile);
68
73 void setContextItemFromFile(const char *filename);
74
84 void setParameter(const char *name, XdmValue *value, bool withParam=true);
85
90 void setLanguageVersion(const char *version);
91
103 void setStreaming(bool option);
104
112 bool isStreaming() const;
113
119 bool removeParameter(const char *name);
120
131 void setProperty(const char *name, const char *value);
132
138 const char * getProperty(const char *name);
139
147 void clearParameters(bool deleteValues = false);
148
152 void clearProperties();
153
164 void setUpdating(bool updating);
165
166
176
177 void useSchema(XsdSchema * schema);
178
193 void setSchemaAware(bool schemaAware);
194
195 bool isSchemaAware();
196
206 void executeQueryToFile(const char *infilename, const char *ofilename,
207 const char *query, const char *encoding = nullptr);
208
218 XdmValue *executeQueryToValue(const char *infilename, const char *query,
219 const char *encoding = nullptr);
220
232 const char *executeQueryToString(const char *infilename, const char *query,
233 const char *encoding = nullptr);
234
243
253 const char *runQueryToString();
254
262 void runQueryToFile();
263
281 void declareNamespace(const char *prefix, const char *uri);
282
289 XdmValue *getParameter(const char *name, bool withParam=true);
290
295 std::map<std::string, XdmValue *> &getParameters();
296
301 std::map<std::string, std::string> &getProperties();
302
308 void setQueryFile(const char *filename);
309
315 void setQueryContent(const char *content);
316
322 void setQueryBaseURI(const char *baseURI);
323
328 const char * getQueryBaseURI();
329
334 void setcwd(const char *cwd);
335
341 const char * getcwd();
342
347
348private:
349 bool streaming;
350 std::string cwdXQ;
351 int64_t procRef;
352 int64_t cppXQ;
353 int64_t schemaRef;
354 std::map<std::string, XdmValue *>
355 parameters;
357 std::map<std::string, std::string>
358 properties;
360};
361
362#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: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 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:217
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:181
SaxonApiException.
Definition SaxonApiException.h:25
The SaxonProcessor class acts as a factory for generating XQuery, XPath, Schema and XSLT compilers.
Definition SaxonProcessor.h:137
void setOutputFile(const char *outfile)
Set the output file where the query result is sent.
Definition XQueryProcessor.cpp:164
void setcwd(const char *cwd)
Set the current working directory.
Definition XQueryProcessor.cpp:282
void setQueryBaseURI(const char *baseURI)
Set the static base URI for the query.
Definition XQueryProcessor.cpp:292
void clearParameters(bool deleteValues=false)
Clear parameter values set.
Definition XQueryProcessor.cpp:220
void setQueryFile(const char *filename)
Compile a query file.
Definition XQueryProcessor.cpp:453
void setStreaming(bool option)
Say whether the query should be compiled and evaluated to use streaming.
Definition XQueryProcessor.cpp:458
bool isStreaming() const
Ask whether the streaming option has been set.
Definition XQueryProcessor.cpp:467
const char * getQueryBaseURI()
Get the static base URI for the query.
Definition XQueryProcessor.cpp:296
void runQueryToFile()
Execute a query as already configured for this XQueryProcessor, and save the result to file.
Definition XQueryProcessor.cpp:449
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:137
void setContextItem(XdmItem *value)
Set the initial context item for the query as an XdmItem.
Definition XQueryProcessor.cpp:122
XdmValue * runQueryToValue()
Execute a query as already configured for this XQueryProcessor, returning the result as an XdmValue.
Definition XQueryProcessor.cpp:445
std::map< std::string, std::string > & getProperties()
Get all configuration properties specified on the processor as a std::map.
Definition XQueryProcessor.cpp:116
void clearProperties()
Clear configuration property values set.
Definition XQueryProcessor.cpp:277
void setLanguageVersion(const char *version)
Set the XQuery language version for the XQuery compiler.
Definition XQueryProcessor.cpp:469
XdmValue * executeQueryToValue(const char *infilename, const char *query, const char *encoding=nullptr)
Execute a query, returning the result as an XdmValue.
Definition XQueryProcessor.cpp:352
void setUpdating(bool updating)
Say whether the query is allowed to be updating.
Definition XQueryProcessor.cpp:300
const char * runQueryToString()
Execute a query as already configured for this XQueryProcessor, returning the result as a string.
Definition XQueryProcessor.cpp:441
std::map< std::string, XdmValue * > & getParameters()
Get all parameters as a std::map.
Definition XQueryProcessor.cpp:111
void setContextItemFromFile(const char *filename)
Set the context item for the query as a source document.
Definition XQueryProcessor.cpp:159
void setQueryContent(const char *content)
Compile a query supplied as a string.
Definition XQueryProcessor.cpp:473
const char * getcwd()
Get the current working directory set on this XQueryProcessor.
Definition XQueryProcessor.cpp:288
void setSchemaAware(bool schemaAware)
Say that the query must be compiled to be schema-aware, even if it contains no import schema declarat...
Definition XQueryProcessor.cpp:247
void useSchema(XsdSchema *schema)
Set the XsdSchema to be used with this XQueryProcessor.
Definition XQueryProcessor.cpp:239
bool removeParameter(const char *name)
Remove a parameter (name, value) pair.
Definition XQueryProcessor.cpp:193
XQueryProcessor()
Default constructor.
Definition XQueryProcessor.cpp:17
XQueryProcessor * clone()
Create a clone of this XQueryProcessor object with the same internal state, which can be used in sepa...
Definition XQueryProcessor.cpp:107
SaxonProcessor * getSaxonProcessor()
Get the SaxonProcessor which created this XQueryProcessor.
Definition XQueryProcessor.cpp:45
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