SaxonC 12.8.0
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
SaxonCXPath.h File Reference

SaxonCXPath.h provides the C API for XPath processing. This file contains a set of functions to compile and execute XPath expressions. More...

#include "saxonc_export.h"
#include "saxonc/SaxonCProcessor.h"

Go to the source code of this file.

Functions

SAXONC_EXPORT int64_t booleanValue (sxnc_environment *environi, bool val)
 Create a boxed Boolean value.
SAXONC_EXPORT int64_t integerValue (sxnc_environment *environi, int i)
 Create a boxed Integer value.
SAXONC_EXPORT int64_t doubleValue (sxnc_environment *environi, double d)
 Create a boxed Double value.
SAXONC_EXPORT int64_t floatValue (sxnc_environment *environi, float f)
 Create a boxed Float value.
SAXONC_EXPORT int64_t longValue (sxnc_environment *environi, long l)
 Create a boxed Long value.
SAXONC_EXPORT int64_t getJavaStringValue (sxnc_environment *environi, const char *str)
 Create a boxed String value.
SAXONC_EXPORT int64_t xdmValueAsObj (sxnc_environment *environi, const char *type, const char *str)
 A Constructor for internal use.
SAXONC_EXPORT sxnc_valuexdmValue (sxnc_environment *environi, const char *type, const char *str)
 A Constructor.
SAXONC_EXPORT int c_createXPathProcessor (sxnc_environment *environi, sxnc_processor *processor, sxnc_xpath *xpath)
 Initialise the Saxon Processor and XPath processor.
SAXONC_EXPORT sxnc_valueevaluate (sxnc_environment *environi, sxnc_xpath *proc, char *cwd, char *xpathStr, char *encoding, sxnc_parameter *parameters, sxnc_property *properties, int parLen, int propLen)
 Compile and evaluate an XPath expression, supplied as a character string, with properties and parameters required by the XPath expression.
SAXONC_EXPORT sxnc_valueevaluateSingle (sxnc_environment *environi, sxnc_xpath *proc, char *cwd, char *xpathStr, char *encoding, sxnc_parameter *parameters, sxnc_property *properties, int parLen, int propLen)
 Compile and evaluate an XPath expression for which the result is expected to be a single XdmItem or NULL.
SAXONC_EXPORT bool effectiveBooleanValue (sxnc_environment *environi, sxnc_xpath *proc, char *cwd, char *xpathStr, char *encoding, sxnc_parameter *parameters, sxnc_property *properties, int parLen, int propLen)
 Evaluate an XPath expression, returning the effective boolean value of the result.
SAXONC_EXPORT bool isAtomicValue (sxnc_environment *environi, sxnc_value value)
 Determine whether the item is an atomic value or a node.
SAXONC_EXPORT int size (sxnc_environment *environi, sxnc_value val)
 Get the number of items in the sequence.
SAXONC_EXPORT const char * getStringValue (sxnc_environment *environi, sxnc_value value)
 Get the string value of the item.
SAXONC_EXPORT int getIntegerValue (sxnc_environment *environi, sxnc_value value, int failure_value)
 Get the integer value of the item.
SAXONC_EXPORT bool getBooleanValue (sxnc_environment *environi, sxnc_value value)
 Get the boolean value of the item.
SAXONC_EXPORT long getLongValue (sxnc_environment *environi, sxnc_value value, long failureVal)
 Get the long value of the item.
SAXONC_EXPORT float getFloatValue (sxnc_environment *environi, sxnc_value value, float failureVal)
 Get the float value of the item.
SAXONC_EXPORT double getDoubleValue (sxnc_environment *environi, sxnc_value value, double failureVal)
 Get the double value of the item.

Detailed Description

SaxonCXPath.h provides the C API for XPath processing. This file contains a set of functions to compile and execute XPath expressions.

Function Documentation

◆ booleanValue()

SAXONC_EXPORT int64_t booleanValue ( sxnc_environment * environi,
bool val )

Create a boxed Boolean value.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
val- boolean value

◆ c_createXPathProcessor()

SAXONC_EXPORT int c_createXPathProcessor ( sxnc_environment * environi,
sxnc_processor * processor,
sxnc_xpath * xpath )

Initialise the Saxon Processor and XPath processor.

This utility function is used to allocate memory on the heap, therefore is required to be called before execution of XPath.

Parameters
environi- GraalVM environment held as the struct sxnc_environment. This function calls malloc on the pointer.
processor- Pointer to the Saxon Processor which is represented as the struct sxnc_processor and is used for creating the XPath processor. This function calls malloc on the pointer.
xpath- Pointer to the sxnc_xpath struct which is used for the execution of XPath expressions. This function calls malloc on the pointer

◆ doubleValue()

SAXONC_EXPORT int64_t doubleValue ( sxnc_environment * environi,
double d )

Create a boxed Double value.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
d- double value

◆ effectiveBooleanValue()

SAXONC_EXPORT bool effectiveBooleanValue ( sxnc_environment * environi,
sxnc_xpath * proc,
char * cwd,
char * xpathStr,
char * encoding,
sxnc_parameter * parameters,
sxnc_property * properties,
int parLen,
int propLen )

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

Parameters
environi- GraalVM environment
proc- Pointer to the XPath Processor used for creating the XPath executable
cwd- Current working directory
xpathStr- A string containing the source text of the XPath expression
encoding- the encoding of the string. Accept null. If not specified then the platform default encoding is used.
parameters- Array of parameters for the XPath expression, as mappings (string, value)
properties- Array of properties for the XPath expression, as mappings (string, string). This could contain the context node, source as string or file name, etc.
parLen- The length of the parameters array
propLen- The length of the properties array

◆ evaluate()

SAXONC_EXPORT sxnc_value * evaluate ( sxnc_environment * environi,
sxnc_xpath * proc,
char * cwd,
char * xpathStr,
char * encoding,
sxnc_parameter * parameters,
sxnc_property * properties,
int parLen,
int propLen )

Compile and evaluate an XPath expression, supplied as a character string, with properties and parameters required by the XPath expression.

Parameters
environi- GraalVM environment
proc- Pointer to the XPath Processor used for creating the XPath executable
cwd- Current working directory
xpathStr- A string containing the source text of the XPath expression
encoding- the encoding of the string. Accept null. If not specified then the platform default encoding is used.
parameters- Array of parameters for the XPath expression, as mappings (string, value)
properties- Array of properties for the XPath expression, as mappings (string, string). This could contain the context node, source as string or file name, etc.
parLen- The length of the parameters array
propLen- The length of the properties array
Returns
sxnc_value - The sxnc_value struct encapsulates the returned XdmValue object or NULL if the expression returns an empty sequence.

◆ evaluateSingle()

SAXONC_EXPORT sxnc_value * evaluateSingle ( sxnc_environment * environi,
sxnc_xpath * proc,
char * cwd,
char * xpathStr,
char * encoding,
sxnc_parameter * parameters,
sxnc_property * properties,
int parLen,
int propLen )

Compile and evaluate an XPath expression for which the result is expected to be a single XdmItem or NULL.

The XPath expression is supplied as a character string, with properties and parameters required by the XPath expression.

Parameters
environi- GraalVM environment
proc- Pointer to the XPath Processor used for creating the XPath executable
cwd- Current working directory
xpathStr- A string containing the source text of the XPath expression
encoding- the encoding of the string. Accept null. If not specified then the platform default encoding is used.
parameters- Array of parameters for the XPath expression, as mappings (string, value)
properties- Array of properties for the XPath expression, as mappings (string, string). This could contain the context node, source as string or file name, etc.
parLen- The length of the parameters array
propLen- The length of the properties array
Returns
sxnc_value - The sxnc_value struct encapsulates the returned XdmItem object or NULL if the expression returns an empty sequence.

◆ floatValue()

SAXONC_EXPORT int64_t floatValue ( sxnc_environment * environi,
float f )

Create a boxed Float value.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
f- float value

◆ getBooleanValue()

SAXONC_EXPORT bool getBooleanValue ( sxnc_environment * environi,
sxnc_value value )

Get the boolean value of the item.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
value- Value to convert to boolean

◆ getDoubleValue()

SAXONC_EXPORT double getDoubleValue ( sxnc_environment * environi,
sxnc_value value,
double failureVal )

Get the double value of the item.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
value- Value to convert to double
failureVal- If the Value is not a double then we can specify the value to return. Default is zero.

◆ getFloatValue()

SAXONC_EXPORT float getFloatValue ( sxnc_environment * environi,
sxnc_value value,
float failureVal )

Get the float value of the item.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
value- Value to convert to float
failureVal- If the Value is not a float then we can specify the value to return. Default is zero.

◆ getIntegerValue()

SAXONC_EXPORT int getIntegerValue ( sxnc_environment * environi,
sxnc_value value,
int failure_value )

Get the integer value of the item.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
value- Value to convert to integer
failure_value- If the value is not an integer then we can specify the value to return. Default is zero.

◆ getJavaStringValue()

SAXONC_EXPORT int64_t getJavaStringValue ( sxnc_environment * environi,
const char * str )

Create a boxed String value.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
str- char array value

◆ getLongValue()

SAXONC_EXPORT long getLongValue ( sxnc_environment * environi,
sxnc_value value,
long failureVal )

Get the long value of the item.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
value- Value to convert to long
failureVal- If the Value is not a long then we can specify the value to return. Default is zero.

◆ getStringValue()

SAXONC_EXPORT const char * getStringValue ( sxnc_environment * environi,
sxnc_value value )

Get the string value of the item.

 Get the n'th item in the value, counting from zero.

 @param n - the item that is required, counting the first item in the

sequence as item zero

Returns
the n'th item in the sequence making up the value, counting from zero
 Convert the Get the n'th item in the value, counting from zero.

 @param n the item that is required, counting the first item in the sequence
 as item zero
 @return the n'th item in the sequence making up the value, counting from
zero For a node, this gets the string value of the node. For an atomic value, it has the same effect as casting the value to a string. In all cases the result is the same as applying the XPath string() function.
Parameters
environi- GraalVM environment held as the struct sxnc_environment.
value- Value to convert to string

◆ integerValue()

SAXONC_EXPORT int64_t integerValue ( sxnc_environment * environi,
int i )

Create a boxed Integer value.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
i- int value

◆ isAtomicValue()

SAXONC_EXPORT bool isAtomicValue ( sxnc_environment * environi,
sxnc_value value )

Determine whether the item is an atomic value or a node.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
value- XDM value
Returns
true if the item is an atomic value, false if it is a node

◆ longValue()

SAXONC_EXPORT int64_t longValue ( sxnc_environment * environi,
long l )

Create a boxed Long value.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
l- long value

◆ size()

SAXONC_EXPORT int size ( sxnc_environment * environi,
sxnc_value val )

Get the number of items in the sequence.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
val- XDM value
Returns
the number of items in the value - always one

◆ xdmValue()

SAXONC_EXPORT sxnc_value * xdmValue ( sxnc_environment * environi,
const char * type,
const char * str )

A Constructor.

Create an XdmValue based on the target type. Conversion is applied if possible.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
type- the target type of the value
str- value to convert

◆ xdmValueAsObj()

SAXONC_EXPORT int64_t xdmValueAsObj ( sxnc_environment * environi,
const char * type,
const char * str )

A Constructor for internal use.

Create an underlying representation for the XdmValue based on the target type. Conversion is applied if possible.

Parameters
environi- GraalVM environment held as the struct sxnc_environment.
type- the target type of the value
str- value to convert