SaxonC 12.5
Saxon Processor library for C/C++, PHP and Python
|
#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 * | clone () |
void | setContextItem (XdmItem *value) |
Set the initial context item for the query. | |
void | setOutputFile (const char *outfile) |
void | setContextItemFromFile (const char *filename) |
void | setParameter (const char *name, XdmValue *value, bool withParam=true) |
void | setLanguageVersion (const char *version) |
Set XQuery language version. | |
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 property specific to the processor in use. | |
void | clearParameters (bool deleteValues=false) |
Clear parameter values set. | |
void | clearProperties () |
Clear 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) |
Perform the Query to file. | |
XdmValue * | executeQueryToValue (const char *infilename, const char *query, const char *encoding=nullptr) |
Perform the Query to a XdmValue representation. | |
const char * | executeQueryToString (const char *infilename, const char *query, const char *encoding=nullptr) |
Perform the Query to a string representation. | |
XdmValue * | runQueryToValue () |
Execute the Query cached. | |
const char * | runQueryToString () |
void | runQueryToFile () |
Execute the Query cached to file. | |
void | declareNamespace (const char *prefix, const char *uri) |
Declare a namespace binding. | |
XdmValue * | getParameter (const char *name, bool withParam=true) |
std::map< std::string, XdmValue * > & | getParameters () |
Get all parameters as a std::map. | |
std::map< std::string, std::string > & | getProperties () |
Get all properties as a std::map. | |
void | setQueryFile (const char *filename) |
Compile a query supplied as a file name. | |
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. | |
void | setcwd (const char *cwd) |
const char * | checkException () |
Check for exception thrown. | |
bool | exceptionOccurred () |
void | exceptionClear () |
Clear any exception thrown. | |
const char * | getErrorMessage () |
Get the first error message if there are any errors. | |
const char * | getErrorCode () |
Get the first error code if there are any errors. | |
SaxonApiException * | getException () |
Get the SaxonApiException object created when we have an error. | |
An XQueryProcessor
represents a factory to compile, load and execute queries.
XQueryProcessor::XQueryProcessor | ( | SaxonProcessor * | p, |
std::string | cwd = "" ) |
Constructor with the SaxonProcessor supplied.
p | - Supplied pointer to the SaxonProcessor object |
cwd | - set 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 exception thrown.
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 | ( | ) |
Clone the XQueryProcessor 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.
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. Assume the prefix or uri is nullptr. |
bool XQueryProcessor::exceptionOccurred | ( | ) |
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 ) |
Perform the Query to file.
The result is is saved to file
infilename | - The file name of the source document |
ofilename | - The file name of where result will be stored |
query | - The query as string representation. |
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 ) |
Perform the Query to a string representation.
infilename | - The file name of the source document |
query | - The query as string representation |
encoding | - the encoding of the query string. If not specified then the platform default encoding is used. |
SaxonApiException |
XdmValue * XQueryProcessor::executeQueryToValue | ( | const char * | infilename, |
const char * | query, | ||
const char * | encoding = nullptr ) |
Perform the Query to a XdmValue representation.
infilename | - The file name of the source document |
query | - The query as string representation |
encoding | - the encoding of the query string. If not specified then the platform default encoding is used. |
SaxonApiException |
const char * XQueryProcessor::getErrorCode | ( | ) |
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 | ( | ) |
Get the first error message if there are any errors.
A query may have a number of errors reported against it.
SaxonApiException * XQueryProcessor::getException | ( | ) |
Get the SaxonApiException object created when we have an error.
After the execution of the processor if there is an error, then a SaxonApiException is created. NULL returned if there is no error.
XdmValue * XQueryProcessor::getParameter | ( | const char * | name, |
bool | withParam = true ) |
Get a parameter value by name
name | - Specified parameter name to get |
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 properties as a std::map.
bool XQueryProcessor::isStreaming | ( | ) |
Ask whether the streaming option has been set.
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 | of the parameter |
Remove a parameter (name, value) pair
void XQueryProcessor::runQueryToFile | ( | ) |
Execute the Query cached to file.
The use of the context item would have had to be set in advance Assume the output filename has been set in advance
SaxonApiException |
const char * XQueryProcessor::runQueryToString | ( | ) |
Execute the Query cached. The use of the context item would have had to be set in advance
SaxonApiException |
XdmValue * XQueryProcessor::runQueryToValue | ( | ) |
Execute the Query cached.
The use of the context item would have had to be set in advance
SaxonApiException |
void XQueryProcessor::setContextItem | ( | XdmItem * | value | ) |
Set the initial context item for the query.
value | - the initial context item, or nullptr if there is to be no initial context item |
Set the source document for the query
void XQueryProcessor::setContextItemFromFile | ( | const char * | ifile | ) |
Set the source from file for the query.
Set the source document for the query
void XQueryProcessor::setcwd | ( | const char * | cwd | ) |
set the current working directory
void XQueryProcessor::setLanguageVersion | ( | const char * | version | ) |
Set XQuery language version.
Say which version of XQuery should be used
version | "3.1" or "4.0" in the current Saxon release. |
void XQueryProcessor::setOutputFile | ( | const char * | ofile | ) |
Set the output file where the result is sent
void XQueryProcessor::setParameter | ( | const char * | name, |
XdmValue * | value, | ||
bool | withParam = true ) |
Set a parameter value used in the query
name | of the parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name" |
value | of the query parameter, or nullptr to clear a previously set value |
withParam | Internal use only |
Set a parameter value used in the query
void XQueryProcessor::setProperty | ( | const char * | name, |
const char * | value ) |
Set a property specific to the 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 | of the property |
value | of the property |
Set a 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.
void XQueryProcessor::setQueryFile | ( | const char * | filename | ) |
Compile a query supplied as a file name.
The supplied query is cached for later execution.
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. |