Saxon/C  1.2.1
Saxon Processor library for C/C++, PHP and Python
Public Member Functions | List of all members
XPathProcessor Class Reference

#include <XPathProcessor.h>

Public Member Functions

 XPathProcessor ()
 Default constructor. More...
 
 XPathProcessor (SaxonProcessor *proc, std::string cwd="")
 Constructor with the SaxonProcessor supplied. More...
 
void setBaseURI (const char *uriStr)
 Set the static base URI for XPath expressions compiled using this XPathCompiler. More...
 
XdmValueevaluate (const char *xpathStr)
 Compile and evaluate an XPath expression. More...
 
XdmItemevaluateSingle (const char *xpathStr)
 Compile and evaluate an XPath expression. The result is expected to be a single XdmItem. More...
 
void setContextItem (XdmItem *item)
 
void setcwd (const char *cwd)
 
void setContextFile (const char *filename)
 Set the context item from file.
 
bool effectiveBooleanValue (const char *xpathStr)
 Evaluate the XPath expression, returning the effective boolean value of the result. More...
 
void setParameter (const char *name, XdmValue *value)
 
bool removeParameter (const char *name)
 
void setProperty (const char *name, const char *value)
 Set a property specific to the processor in use. More...
 
void declareNamespace (const char *prefix, const char *uri)
 Declare a namespace binding as part of the static context for XPath expressions compiled using this XPathCompiler. More...
 
void setBackwardsCompatible (bool option)
 Say whether XPath 1.0 backwards compatibility mode is to be used. More...
 
void setCaching (bool caching)
 Say whether the compiler should maintain a cache of compiled expressions. More...
 
void importSchemaNamespace (const char *uri)
 Import a schema namespace. More...
 
std::map< std::string, XdmValue * > & getParameters ()
 
std::map< std::string, std::string > & getProperties ()
 
void clearParameters (bool deleteValues=false)
 
void clearProperties ()
 
bool exceptionOccurred ()
 
void exceptionClear ()
 Clear any exception thrown.
 
int exceptionCount ()
 Get number of errors reported during evaluation of the XPath. More...
 
const char * getErrorMessage (int i)
 Get the ith error message if there are any error. More...
 
const char * getErrorCode (int i)
 Get the ith error code if there are any error. More...
 
const char * checkException ()
 Check for exception thrown. More...
 

Detailed Description

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

Constructor & Destructor Documentation

◆ XPathProcessor() [1/2]

XPathProcessor::XPathProcessor ( )

Default constructor.

Creates a Saxon-HE XPath product

◆ XPathProcessor() [2/2]

XPathProcessor::XPathProcessor ( SaxonProcessor proc,
std::string  cwd = "" 
)

Constructor with the SaxonProcessor supplied.

Parameters
proc- Pointer to the SaxonProcessor object
cwd- The current working directory

Member Function Documentation

◆ checkException()

const char * XPathProcessor::checkException ( )

Check for exception thrown.

Returns
cha*. Returns the exception message if thrown otherwise return NULL

◆ clearParameters()

void XPathProcessor::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 XPathProcessor::clearProperties ( )

Clear property values set

◆ declareNamespace()

void XPathProcessor::declareNamespace ( const char *  prefix,
const char *  uri 
)

Declare a namespace binding as part of the static context for XPath expressions compiled using this XPathCompiler.

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.

◆ effectiveBooleanValue()

bool XPathProcessor::effectiveBooleanValue ( const char *  xpathStr)

Evaluate the XPath expression, returning the effective boolean value of the result.

Parameters
xpathStr- supplied as a character string
Returns
bool

◆ evaluate()

XdmValue * XPathProcessor::evaluate ( const char *  xpathStr)

Compile and evaluate an XPath expression.

Parameters
xpathStr- supplied as a character string
Returns
XdmValue

◆ evaluateSingle()

XdmItem * XPathProcessor::evaluateSingle ( const char *  xpathStr)

Compile and evaluate an XPath expression. The result is expected to be a single XdmItem. NULL is returned if the expression returns an empty sequence. If the expression returns a sequence of more than one item, any items after the first are ignored.

Parameters
xpathStr- supplied as a character string
Returns
XdmItem or NULL if expression returns an empty sequence

◆ exceptionCount()

int XPathProcessor::exceptionCount ( )

Get number of errors reported during evaluation of the XPath.

After the evalution of the XPAth expression there may be a number of errors reported against it.

Returns
int - Count of the exceptions recorded against the transformation

◆ exceptionOccurred()

bool XPathProcessor::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 Checks for pending exceptions without creating a local reference to the exception object
bool - true when there is a pending exception; otherwise return false

◆ getErrorCode()

const char * XPathProcessor::getErrorCode ( int  i)

Get the ith error code if there are any error.

After the execution of the XPath expression there may be a number of errors reported against it.

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

◆ getErrorMessage()

const char * XPathProcessor::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 * > & XPathProcessor::getParameters ( )

Get all parameters as a std::map

◆ getProperties()

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

Get all properties as a std::map

◆ importSchemaNamespace()

void XPathProcessor::importSchemaNamespace ( const char *  uri)

Import a schema namespace.

Here we add the element and attribute declarations and type definitions contained in a given namespace to the static context for the XPath expression.

This method will not cause the schema to be loaded. That must be done separately, using the SchemaManager. This method will not fail if the schema has not been loaded (but in that case the set of declarations and definitions made available to the XPath expression is empty). The schema document for the specified namespace may be loaded before or after this method is called.

This method does not bind a prefix to the namespace. That must be done separately, using the declareNamespace(String, String) method.

Parameters
uriThe schema namespace to be imported. To import declarations in a no-namespace schema, supply a zero-length string.

◆ removeParameter()

bool XPathProcessor::removeParameter ( const char *  name)

Remove a parameter (name, value) pair

Parameters
nameof the parameter
Returns
bool - outcome of the romoval

◆ setBackwardsCompatible()

void XPathProcessor::setBackwardsCompatible ( bool  option)

Say whether XPath 1.0 backwards compatibility mode is to be used.

In backwards compatibility mode, more implicit type conversions are allowed in XPath expressions, for example it is possible to compare a number with a string. The default is false (backwards compatibility mode is off).

Parameters
optiontrue if XPath 1.0 backwards compatibility is to be enabled, false if it is to be disabled.

◆ setBaseURI()

void XPathProcessor::setBaseURI ( const char *  uriStr)

Set the static base URI for XPath expressions compiled using this XPathCompiler.

The base URI is part of the static context, and is used to resolve any relative URIs appearing within an XPath expression, for example a relative URI passed as an argument to the doc() function. If no static base URI is supplied, then the current working directory is used.

Parameters
uriStr

◆ setCaching()

void XPathProcessor::setCaching ( bool  caching)

Say whether the compiler should maintain a cache of compiled expressions.

Parameters
cachingif set to true, caching of compiled expressions is enabled. If set to false, any existing cache is cleared, and future compiled expressions will not be cached until caching is re-enabled. The cache is also cleared (but without disabling future caching) if any method is called that changes the static context for compiling expressions, for example declareVariable(QName) or declareNamespace(String, String).

◆ setcwd()

void XPathProcessor::setcwd ( const char *  cwd)

set the current working directory

◆ setParameter()

void XPathProcessor::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

◆ setProperty()

void XPathProcessor::setProperty ( const char *  name,
const char *  value 
)

Set a property specific to the processor in use.

XPathProcessor: set serialization properties (names start with '!' i.e. name "!method" -> "xml") 'o':outfile name, 's': context item supplied as file name

Parameters
nameof the property
valueof the property

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