SaxonC 12.4
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
Public Member Functions | List of all members
XQueryProcessor Class Reference

#include <XQueryProcessor.h>

Public Member Functions

 XQueryProcessor ()
 Default constructor.
 
 XQueryProcessor (SaxonProcessor *p, std::string cwd="")
 Constructor with the SaxonProcessor supplied.
 
 XQueryProcessor (const XQueryProcessor &other)
 
XQueryProcessorclone ()
 
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)
 
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.
 
XdmValueexecuteQueryToValue (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.
 
XdmValuerunQueryToValue ()
 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.
 
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.
 
SaxonApiExceptiongetException ()
 Get the SaxonApiException object created when we have an error.
 

Detailed Description

An XQueryProcessor represents a factory to compile, load and execute queries.

Constructor & Destructor Documentation

◆ XQueryProcessor() [1/2]

XQueryProcessor::XQueryProcessor ( SaxonProcessor p,
std::string  cwd = "" 
)

Constructor with the SaxonProcessor supplied.

Parameters
p- Supplied pointer to the SaxonProcessor object
cwd- set the current working directory. Default is the empty string

◆ XQueryProcessor() [2/2]

XQueryProcessor::XQueryProcessor ( const XQueryProcessor other)

XQueryProcessor copy constructor.

Parameters
other- XQueryProcessor

Member Function Documentation

◆ checkException()

const char * XQueryProcessor::checkException ( )

Check for exception thrown.

Returns
char*. Returns the main exception message if thrown otherwise return nullptr

◆ clearParameters()

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.

Parameters
deleteValues- if true then XdmValues are deleted

◆ clone()

XQueryProcessor * XQueryProcessor::clone ( )

Clone the XQueryProcessor with the same internal state, which can be used in separate threads.

◆ declareNamespace()

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.

Parameters
prefixThe namespace prefix. If the value is a zero-length string, this method sets the default namespace for elements and types.
uriThe 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.

◆ exceptionOccurred()

bool XQueryProcessor::exceptionOccurred ( )

Checks for pending exceptions without creating a local reference to the exception object

Returns
bool - true when there is a pending exception; otherwise return false

◆ executeQueryToFile()

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

Parameters
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.
Exceptions
SaxonApiException

◆ executeQueryToString()

const char * XQueryProcessor::executeQueryToString ( const char *  infilename,
const char *  query,
const char *  encoding = nullptr 
)

Perform the Query to a string representation.

Parameters
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.
Returns
char array - result of as a string
Exceptions
SaxonApiException

◆ executeQueryToValue()

XdmValue * XQueryProcessor::executeQueryToValue ( const char *  infilename,
const char *  query,
const char *  encoding = nullptr 
)

Perform the Query to a XdmValue representation.

Parameters
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.
Returns
XdmValue - result of the the query as a XdmValue
Exceptions
SaxonApiException

◆ getErrorCode()

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.

Returns
char* - The error code of the exception.

◆ getErrorMessage()

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.

Returns
char* - The message of the exception

◆ getException()

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.

Returns
SaxonApiException object of the exception thrown.

◆ getParameters()

std::map< std::string, XdmValue * > & XQueryProcessor::getParameters ( )

Get all parameters as a std::map.

Returns
std::map - map of the parameters string->XdmValue*

◆ getProperties()

std::map< std::string, std::string > & XQueryProcessor::getProperties ( )

Get all properties as a std::map.

Returns
std::map map of the properties string->string

◆ isStreaming()

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.

Returns
true if the streaming option has been set.

◆ removeParameter()

bool XQueryProcessor::removeParameter ( const char *  name)

Remove a parameter (name, value) pair.

Parameters
nameof the parameter
Returns
bool - outcome of the removal

Remove a parameter (name, value) pair

◆ runQueryToFile()

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

Exceptions
SaxonApiException

◆ runQueryToString()

const char * XQueryProcessor::runQueryToString ( )

Execute the Query cached. The use of the context item would have had to be set in advance

Returns
Result as a string (i.e. pointer array of char)
Exceptions
SaxonApiException

◆ runQueryToValue()

XdmValue * XQueryProcessor::runQueryToValue ( )

Execute the Query cached.

The use of the context item would have had to be set in advance

Returns
XdmValue of the result
Exceptions
SaxonApiException

◆ setContextItem()

void XQueryProcessor::setContextItem ( XdmItem value)

Set the initial context item for the query.

Parameters
value- the initial context item, or nullptr if there is to be no initial context item

Set the source document for the query

◆ setContextItemFromFile()

void XQueryProcessor::setContextItemFromFile ( const char *  ifile)

Set the source from file for the query.

Set the source document for the query

◆ setcwd()

void XQueryProcessor::setcwd ( const char *  cwd)

set the current working directory

◆ setLanguageVersion()

void XQueryProcessor::setLanguageVersion ( const char *  version)

Set XQuery language version.

Say which version of XQuery should be used

Parameters
version"3.1" or "4.0" in the current Saxon release.

◆ setOutputFile()

void XQueryProcessor::setOutputFile ( const char *  ofile)

Set the output file where the result is sent

◆ setParameter()

void XQueryProcessor::setParameter ( const char *  name,
XdmValue value 
)

Set a parameter value used in the query

Parameters
nameof the parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name"
valueof the query parameter, or nullptr to clear a previously set value

Set a parameter value used in the query

◆ setProperty()

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'

Parameters
nameof the property
valueof the property

Set a property.

◆ setQueryBaseURI()

void XQueryProcessor::setQueryBaseURI ( const char *  baseURI)

Set the static base URI for the query.

Parameters
baseURIthe static base URI; or nullptr to indicate that no base URI is available

◆ setQueryContent()

void XQueryProcessor::setQueryContent ( const char *  content)

Compile a query supplied as a string.

The supplied query is cached for later execution.

◆ setQueryFile()

void XQueryProcessor::setQueryFile ( const char *  filename)

Compile a query supplied as a file name.

The supplied query is cached for later execution.

◆ setStreaming()

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.

Parameters
optionif 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()"

◆ setUpdating()

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.

Parameters
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.

The documentation for this class was generated from the following files: