![]() |
SaxonC 12.7.0
Saxon Processor library for C/C++, PHP and Python
|
An XQueryProcessor
represents a factory to compile, load and execute queries.
More...
#include <XQueryProcessor.h>
Public Member Functions | |
XQueryProcessor () | |
Default constructor. | |
XQueryProcessor (SaxonProcessor *p, std::string cwd="") | |
Constructor with the SaxonProcessor supplied. | |
XQueryProcessor (const XQueryProcessor &other) | |
XQueryProcessor copy constructor. | |
XQueryProcessor * | clone () |
Create a clone of this XQueryProcessor object with the same internal state, which can be used in separate threads. | |
void | setContextItem (XdmItem *value) |
Set the initial context item for the query as an XdmItem. | |
void | setOutputFile (const char *outfile) |
Set the output file where the query result is sent. | |
void | setContextItemFromFile (const char *filename) |
Set the context item for the query as a source document. | |
void | setParameter (const char *name, XdmValue *value, bool withParam=true) |
Set the value of a parameter used in the query. | |
void | setLanguageVersion (const char *version) |
Set the XQuery language version for the XQuery compiler. | |
void | setStreaming (bool option) |
Say whether the query should be compiled and evaluated to use streaming. | |
bool | isStreaming () |
Ask whether the streaming option has been set. | |
bool | removeParameter (const char *name) |
Remove a parameter (name, value) pair. | |
void | setProperty (const char *name, const char *value) |
Set a configuration property specific to the XQuery processor in use. | |
const char * | getProperty (const char *name) |
Get the value of a configuration property specified on the XQuery processor in use. | |
void | clearParameters (bool deleteValues=false) |
Clear parameter values set. | |
void | clearProperties () |
Clear configuration property values set. | |
void | setUpdating (bool updating) |
Say whether the query is allowed to be updating. | |
void | executeQueryToFile (const char *infilename, const char *ofilename, const char *query, const char *encoding=nullptr) |
Execute a query, and save the result to file. | |
XdmValue * | executeQueryToValue (const char *infilename, const char *query, const char *encoding=nullptr) |
Execute a query, returning the result as an XdmValue. | |
const char * | executeQueryToString (const char *infilename, const char *query, const char *encoding=nullptr) |
Execute a query, returning the result as a string. | |
XdmValue * | runQueryToValue () |
Execute a query as already configured for this XQueryProcessor, returning the result as an XdmValue. | |
const char * | runQueryToString () |
Execute a query as already configured for this XQueryProcessor, returning the result as a string. | |
void | runQueryToFile () |
Execute a query as already configured for this XQueryProcessor, and save the result to file. | |
void | declareNamespace (const char *prefix, const char *uri) |
Declare a namespace binding as part of the static context for queries compiled using this XQueryCompiler. | |
XdmValue * | getParameter (const char *name, bool withParam=true) |
Get the value of a parameter. | |
std::map< std::string, XdmValue * > & | getParameters () |
Get all parameters as a std::map. | |
std::map< std::string, std::string > & | getProperties () |
Get all configuration properties specified on the processor as a std::map. | |
void | setQueryFile (const char *filename) |
Compile a query file. | |
void | setQueryContent (const char *content) |
Compile a query supplied as a string. | |
void | setQueryBaseURI (const char *baseURI) |
Set the static base URI for the query. | |
const char * | getQueryBaseURI () |
Get the static base URI for the query. | |
void | setcwd (const char *cwd) |
Set the current working directory. | |
const char * | getcwd () |
Get the current working directory set on this XQueryProcessor. | |
const char * | checkException () |
Check for thrown exceptions. | |
bool | exceptionOccurred () |
Deprecated. | |
void | exceptionClear () |
Deprecated. | |
const char * | getErrorMessage () |
Deprecated. | |
const char * | getErrorCode () |
Deprecated. | |
SaxonApiException * | getException () |
Deprecated. | |
SaxonProcessor * | getSaxonProcessor () |
Get the SaxonProcessor which created this XQueryProcessor. | |
An XQueryProcessor
represents a factory to compile, load and execute queries.
XQueryProcessor::XQueryProcessor | ( | ) |
Default constructor.
Creates a Saxon-HE XQuery processor
XQueryProcessor::XQueryProcessor | ( | SaxonProcessor * | p, |
std::string | cwd = "" ) |
Constructor with the SaxonProcessor supplied.
p | - pointer to the SaxonProcessor object |
cwd | - the current working directory. Default is the empty string |
XQueryProcessor::XQueryProcessor | ( | const XQueryProcessor & | other | ) |
XQueryProcessor copy constructor.
other | - XQueryProcessor |
const char * XQueryProcessor::checkException | ( | ) |
Check for thrown exceptions.
void XQueryProcessor::clearParameters | ( | bool | deleteValues = false | ) |
Clear parameter values set.
Default behaviour (false) is to leave XdmValues in memory. Individual pointers to XdmValue objects have to be deleted in the calling program.
deleteValues | - if true then XdmValues are deleted |
XQueryProcessor * XQueryProcessor::clone | ( | ) |
Create a clone of this XQueryProcessor object with the same internal state, which can be used in separate threads.
void XQueryProcessor::declareNamespace | ( | const char * | prefix, |
const char * | uri ) |
Declare a namespace binding as part of the static context for queries compiled using this XQueryCompiler.
This binding may be overridden by a binding that appears in the query prolog. The namespace binding will form part of the static context of the query, but it will not be copied into result trees unless the prefix is actually used in an element or attribute name.
prefix | - the namespace prefix. If the value is a zero-length string, this method sets the default namespace for elements and types. |
uri | - the namespace URI. It is possible to specify a zero-length string to "undeclare" a namespace; in this case the prefix will not be available for use, except in the case where the prefix is also a zero length string, in which case the absence of a prefix implies that the name is in no namespace. |
SaxonApiException | if either the prefix or uri is nullptr |
void XQueryProcessor::exceptionClear | ( | ) |
Deprecated.
Clear any thrown exceptions
bool XQueryProcessor::exceptionOccurred | ( | ) |
Deprecated.
Checks for pending exceptions without creating a local reference to the exception object
void XQueryProcessor::executeQueryToFile | ( | const char * | infilename, |
const char * | ofilename, | ||
const char * | query, | ||
const char * | encoding = nullptr ) |
Execute a query, and save the result to file.
infilename | - the file name of the source document |
ofilename | - the file name where results will be stored |
query | - the query supplied as a string |
encoding | - the encoding of the query string. If not specified then the platform default encoding is used. |
SaxonApiException |
const char * XQueryProcessor::executeQueryToString | ( | const char * | infilename, |
const char * | query, | ||
const char * | encoding = nullptr ) |
Execute a query, returning the result as a string.
infilename | - the file name of the source document |
query | - the query supplied as a string |
encoding | - the encoding of the query string. If not specified then the platform default encoding is used. |
operator delete
. SaxonApiException |
XdmValue * XQueryProcessor::executeQueryToValue | ( | const char * | infilename, |
const char * | query, | ||
const char * | encoding = nullptr ) |
Execute a query, returning the result as an XdmValue.
infilename | - the file name of the source document |
query | - the query supplied as a string |
encoding | - the encoding of the query string. If not specified then the platform default encoding is used. |
SaxonApiException |
const char * XQueryProcessor::getcwd | ( | ) |
Get the current working directory set on this XQueryProcessor.
Memory deallocation is handled internally.
const char * XQueryProcessor::getErrorCode | ( | ) |
Deprecated.
Get the first error code if there are any errors. After the execution of the query there may be a number of errors reported against it.
const char * XQueryProcessor::getErrorMessage | ( | ) |
Deprecated.
Get the first error message if there are any errors. A query may have a number of errors reported against it.
SaxonApiException * XQueryProcessor::getException | ( | ) |
Deprecated.
Get the SaxonApiException object created when we have an error. After the execution of the query if there is an error then a SaxonApiException is created.
XdmValue * XQueryProcessor::getParameter | ( | const char * | name, |
bool | withParam = true ) |
Get the value of a parameter.
name | - the name of the parameter |
withParam | - internal use only |
std::map< std::string, XdmValue * > & XQueryProcessor::getParameters | ( | ) |
Get all parameters as a std::map.
std::map< std::string, std::string > & XQueryProcessor::getProperties | ( | ) |
Get all configuration properties specified on the processor as a std::map.
const char * XQueryProcessor::getProperty | ( | const char * | name | ) |
Get the value of a configuration property specified on the XQuery processor in use.
name | - the name of the property |
const char * XQueryProcessor::getQueryBaseURI | ( | ) |
Get the static base URI for the query.
bool XQueryProcessor::isStreaming | ( | ) |
Ask whether the streaming option has been set.
That is, whether subsequent calls on compile() will compile queries to be capable of executing in streaming mode.
bool XQueryProcessor::removeParameter | ( | const char * | name | ) |
Remove a parameter (name, value) pair.
name | - the name of the parameter |
void XQueryProcessor::runQueryToFile | ( | ) |
Execute a query as already configured for this XQueryProcessor, and save the result to file.
All configuration properties must set in advance - for instance supplying the query and the context item, and the file name for the result output.
SaxonApiException |
const char * XQueryProcessor::runQueryToString | ( | ) |
Execute a query as already configured for this XQueryProcessor, returning the result as a string.
All configuration properties must set in advance - for instance supplying the query and the context item.
operator delete
. SaxonApiException |
XdmValue * XQueryProcessor::runQueryToValue | ( | ) |
Execute a query as already configured for this XQueryProcessor, returning the result as an XdmValue.
All configuration properties must set in advance - for instance supplying the query and the context item.
SaxonApiException |
void XQueryProcessor::setContextItem | ( | XdmItem * | value | ) |
Set the initial context item for the query as an XdmItem.
value | - the initial context item, or nullptr if there is to be no initial context item |
void XQueryProcessor::setContextItemFromFile | ( | const char * | filename | ) |
Set the context item for the query as a source document.
filename | - the name of the source document |
void XQueryProcessor::setcwd | ( | const char * | cwd | ) |
Set the current working directory.
cwd | - current working directory |
void XQueryProcessor::setLanguageVersion | ( | const char * | version | ) |
Set the XQuery language version for the XQuery compiler.
version | - "3.1" or "4.0" in the current Saxon release. |
void XQueryProcessor::setOutputFile | ( | const char * | outfile | ) |
Set the output file where the query result is sent.
outfile | - the name of the file where results will be stored |
void XQueryProcessor::setParameter | ( | const char * | name, |
XdmValue * | value, | ||
bool | withParam = true ) |
Set the value of a parameter used in the query.
name | - the name of the parameter, as a string. For a namespaced name use clark notation i.e. "{uri}local" |
value | - value of the query parameter, or nullptr to clear a previously set value |
withParam | - internal use only |
void XQueryProcessor::setProperty | ( | const char * | name, |
const char * | value ) |
Set a configuration property specific to the XQuery processor in use.
XQueryProcessor: set serialization properties (names start with '!' i.e. name "!method" -> "xml"), 'o':outfile name, 's': source as file name 'q': query file name, 'q': current by name, 'qs': string form of the query, 'base': set the base URI of the query, 'dtd': set DTD validation 'on' or 'off'
name | - the name of the property |
value | - the value of the property |
void XQueryProcessor::setQueryBaseURI | ( | const char * | baseURI | ) |
Set the static base URI for the query.
baseURI | - the static base URI; or nullptr to indicate that no base URI is available |
void XQueryProcessor::setQueryContent | ( | const char * | content | ) |
Compile a query supplied as a string.
The supplied query is cached for later execution.
content | - the query supplied as a character string |
void XQueryProcessor::setQueryFile | ( | const char * | filename | ) |
Compile a query file.
The supplied query is cached for later execution.
filename | - the file name of the query document |
void XQueryProcessor::setStreaming | ( | bool | option | ) |
Say whether the query should be compiled and evaluated to use streaming.
This affects subsequent calls on the compile() methods. This option requires Saxon-EE.
option | if true, the compiler will attempt to compile a query to be capable of executing in streaming mode. If the query cannot be streamed, a compile-time exception is reported. In streaming mode, the source document is supplied as a stream, and no tree is built in memory. The default is false. When setStreaming(true) is specified, this has the additional side effect of setting the required context item type to "document-node()" |
void XQueryProcessor::setUpdating | ( | bool | updating | ) |
Say whether the query is allowed to be updating.
XQuery update syntax will be rejected during query compilation unless this flag is set. XQuery Update is supported only under Saxon-EE.
updating | - true if the query is allowed to use the XQuery Update facility (requires Saxon-EE). If set to false, the query must not be an updating query. If set to true, it may be either an updating or a non-updating query. |