Saxon/C  1.2.1
Saxon Processor library for C/C++, PHP and Python
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. More...
 
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)
 
void setProperty (const char *name, const char *value)
 
void clearParameters (bool deleteValues=false)
 
void clearProperties ()
 
void setUpdating (bool updating)
 
void executeQueryToFile (const char *infilename, const char *ofilename, const char *query)
 Perform the Query to file. More...
 
XdmValueexecuteQueryToValue (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...
 
XdmValuerunQueryToValue ()
 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.
 
int exceptionCount ()
 Get number of errors reported during execution of the query. More...
 
const char * getErrorMessage (int i)
 Get the ith error message if there are any error. More...
 
const char * getErrorCode (int i)
 Get the i'th error code if there are any error. More...
 

Detailed Description

An XQueryProcessor represents factory to compile, load and execute the query.

Constructor & Destructor Documentation

◆ XQueryProcessor()

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

Constructor with the SaxonProcessor supplied.

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

Member Function Documentation

◆ checkException()

const char * XQueryProcessor::checkException ( )

Check for exception thrown.

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

◆ clearParameters()

void XQueryProcessor::clearParameters ( bool  deleteValues = false)

Clear parameter values set

Parameters
deleteValues.Individual pointers to XdmValue objects have to be deleted in the calling program Default behaviour (false) is to leave XdmValues in memory true then XdmValues are deleted

◆ clearProperties()

void XQueryProcessor::clearProperties ( )

Clear property values set

◆ 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 null.

◆ exceptionCount()

int XQueryProcessor::exceptionCount ( )

Get number of errors reported during execution of the query.

A transformation may have a number of errors reported against it.

Returns
int - Count of the exceptions recorded against the transformation

◆ 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 
)

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. TODO check

◆ executeQueryToString()

const char * XQueryProcessor::executeQueryToString ( const char *  infilename,
const char *  query 
)

Perform the Query to a string representation.

Parameters
infilename- The file name of the source document
query- The query as string representation
Returns
char array - result of as a string

◆ executeQueryToValue()

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

Perform the Query to a XdmValue representation.

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

◆ getErrorCode()

const char * XQueryProcessor::getErrorCode ( int  i)

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.

Returns
char* - The error code of the i'th exception.

◆ getErrorMessage()

const char * XQueryProcessor::getErrorMessage ( int  i)

Get the ith error message if there are any error.

A transformation may have a number of errors reported against it.

Returns
char* - The message of the i'th exception

◆ 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

◆ removeParameter()

bool XQueryProcessor::removeParameter ( const char *  name)

Remove a parameter (name, value) pair

Parameters
namespaceicurrently not used
nameof the parameter
Returns
bool - outcome of the romoval

◆ 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

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

◆ 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)

◆ 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

◆ setContextItem()

void XQueryProcessor::setContextItem ( XdmItem value)

Set the initial context item for the query.

Parameters
value- the initial context item, or null 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

◆ 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 s

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

Set a parameter value used in the query

Parameters
nameof the parameter, as a string
valueof the query parameter, or null to clear a previously set value

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

Parameters
nameof the property
valueof the property

◆ setQueryBaseURI()

void XQueryProcessor::setQueryBaseURI ( const char *  baseURI)

Set the static base URI for the query.

Parameters
baseURIthe static base URI; or null 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.

◆ 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: