SaxonC
11.6
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. More... | |
XQueryProcessor (const XQueryProcessor &other) | |
XQueryProcessor * | clone () |
void | setContextItem (XdmItem *value) |
Set the initial context item for the query. More... | |
void | setOutputFile (const char *outfile) |
void | setContextItemFromFile (const char *filename) |
void | setParameter (const char *name, XdmValue *value) |
bool | removeParameter (const char *name) |
Remove a parameter (name, value) pair. More... | |
void | setProperty (const char *name, const char *value) |
Set a property specific to the processor in use. More... | |
void | clearParameters (bool deleteValues=false) |
Clear parameter values set. More... | |
void | clearProperties () |
Clear property values set. | |
void | setUpdating (bool updating) |
Say whether the query is allowed to be updating. More... | |
void | executeQueryToFile (const char *infilename, const char *ofilename, const char *query) |
Perform the Query to file. More... | |
XdmValue * | executeQueryToValue (const char *infilename, const char *query) |
Perform the Query to a XdmValue representation. More... | |
const char * | executeQueryToString (const char *infilename, const char *query) |
Perform the Query to a string representation. More... | |
XdmValue * | runQueryToValue () |
Execute the Query cached. More... | |
const char * | runQueryToString () |
void | runQueryToFile () |
Execute the Query cached to file. More... | |
void | declareNamespace (const char *prefix, const char *uri) |
Declare a namespace binding. More... | |
std::map< std::string, XdmValue * > & | getParameters () |
Get all parameters as a std::map. More... | |
std::map< std::string, std::string > & | getProperties () |
Get all properties as a std::map. More... | |
void | setQueryFile (const char *filename) |
Compile a query supplied as a file name. More... | |
void | setQueryContent (const char *content) |
Compile a query supplied as a string. More... | |
void | setQueryBaseURI (const char *baseURI) |
Set the static base URI for the query. More... | |
void | setcwd (const char *cwd) |
const char * | checkException () |
Check for exception thrown. More... | |
bool | exceptionOccurred () |
void | exceptionClear () |
Clear any exception thrown. | |
const char * | getErrorMessage () |
Get the ith error message if there are any error. More... | |
const char * | getErrorCode () |
Get the i'th error code if there are any error. More... | |
SaxonApiException * | getException () |
Get the SaxonApiException object created when we have an error. More... | |
An XQueryProcessor
represents factory to compile, load and execute the query.
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 | ||
) |
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. TODO check |
const char * XQueryProcessor::executeQueryToString | ( | const char * | infilename, |
const char * | query | ||
) |
Perform the Query to a string representation.
infilename | - The file name of the source document |
query | - The query as string representation |
XdmValue * XQueryProcessor::executeQueryToValue | ( | const char * | infilename, |
const char * | query | ||
) |
const char * XQueryProcessor::getErrorCode | ( | ) |
Get the i'th error code if there are any error.
After the execution of the query there may be a number of errors reported against it.
const char * XQueryProcessor::getErrorMessage | ( | ) |
Get the ith error message if there are any error.
A transformation 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.
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::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
const char * XQueryProcessor::runQueryToString | ( | ) |
Execute the Query cached. The use of the context item would have had to be set in advance
XdmValue * XQueryProcessor::runQueryToValue | ( | ) |
Execute the Query cached.
The use of the context item would have had to be set in advance
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::setOutputFile | ( | const char * | ofile | ) |
Set the output file where the result is sent
void XQueryProcessor::setParameter | ( | const char * | name, |
XdmValue * | value | ||
) |
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 |
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::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. |