PySaxonProcessor

class PySaxonProcessor

Bases: object

A PySaxonProcessor acts as a factory for generating XQuery, XPath, Schema and XSLT compilers. This class is itself the context that needs to be managed (i.e. allocation & release) .. rubric:: Example

from saxoncee import * with PySaxonProcessor(license=False) as proc:

print(“Test SaxonC on Python”) print(proc.version) xdmAtomicval = proc.make_boolean_value(False) xslt30proc = proc.new_xslt30_processor()

__enter__()

enter method for use with the keyword ‘with’ context Deprecated. This may be removed in a later release.

__exit__(exception_type, exception_value, traceback)

Deprecated. This method no longer does anything, and may be removed in a later release.

classmethod __new__(*args, **kwargs)
__pyx_vtable__ = <capsule object NULL>
__reduce__()

Helper for pickle.

__setstate__()
attach_current_thread
clark_name_to_eqname(self, name, encoding=None)

Convert clark name string to EQName notation; i.e. the expanded name, as a string using the notation defined by the EQName production in XPath 3.0. If the name is in a namespace, the resulting string takes the form <code>Q{uri}local</code>. Otherwise, the value is the local part of the name. :param name: The URI in Clark notation: <code>{uri}local</code> if the name is in a namespace,

or simply <code>local</code> if not.

Parameters:

encoding (str) – The encoding of the string. If not specified then the platform default encoding is used.

Returns:

the expanded name, as a string using the notation defined by the EQName production in XPath 3.0.

Return type:

str

clear_configuration_properties(self)

Clear the configuration properties in use by the processor

cwd

Property represents the current working directory

detach_current_thread
edition

Property to get the short name of the licensed Saxon product edition. This represents the kind of configuration that has been created, rather than the software that has been installed; which depends on the license key supplied, as well as the software edition installed. :returns: the Saxon edition code: “EE”, “PE”, or “HE”. :rtype: str

empty_sequence()

Returns a PyXdmValue representing the empty sequence

Returns:

the empty sequence

Return type:

PyXdmValue

eqname_to_clark_name(self, name, encoding=None)

Convert EQName string to clark name notation. :param name: The URI in EQName notation: <code>Q{uri}local</code> if the name is in a namespace.

For a name in no namespace, either of the forms <code>Q{}local</code> or simply <code>local</code> are accepted.

Parameters:

encoding (str) – The encoding of the string. If not specified then the platform default encoding is used.

Returns:

the URI in clark notation

Return type:

str

error_message

from 12.1 this method is no longer used, since exceptions are now thrown. The PySaxonProcessor may have a number of errors reported against it. Get the error message if there are any errors. :returns: The message of the exception. Returns None if the exception does not exist. :rtype: str

Type:

Deprecated

exception_clear(self)

Deprecated: from 12.1 this method is no longer used, since exceptions are now thrown. Clear any exception thrown internally in SaxonC.

exception_occurred

from 12.1 this method is no longer used, since exceptions are now thrown. Property to check if an exception has occurred internally within SaxonC :returns: True if an exception has been reported; otherwise False :rtype: boolean

Type:

Deprecated

get_string_value(self, PyXdmItem item)

Get the string value of the supplied PyXdmItem, as defined in the XPath data model :param item: An XDM item :type item: PyXdmItem

Returns:

The string value of this XDM item

Return type:

str

is_licensed

Property to check whether a license key has been found and accepted. :returns: True if the SaxonC Processor is licensed, or False otherwise :rtype: bool

is_schema_aware

Property to check if the processor is schema aware. A licensed SaxonC-EE product is schema aware :returns: True if the processor is schema aware, or False otherwise :rtype: bool

make_array(self, list values)

Make a PyXdmArray whose members are from a list of PyXdmValues :param values: List of PyXdmValues :type values: list

Returns:

The corresponding value

Return type:

PyXdmArray

make_atomic_value(self, value_type, value, encoding=None)

Create an XDM atomic value from string representation :param value_type: Local name of a type in the XML Schema namespace :type value_type: str :param value: The value given in a string form. In the case of a QName the value supplied must be

in clark notation {uri}local.

Parameters:

encoding (str) – The encoding of the value_type. If not specified then the platform default encoding is used.

Returns:

The corresponding XDM value

Return type:

PyXdmAtomicValue

make_boolean_value(self, value)

Factory method: makes a PyXdmAtomicValue representing a boolean value :param value: True or False, to determine which boolean value is required :type value: bool

Returns:

The corresponding XDM value

Return type:

PyXdmAtomicValue

make_double_value(self, value)

Factory method: makes a double value :param value: The supplied primitive double value :type value: double

Returns:

The corresponding XDM value

Return type:

PyXdmAtomicValue

make_float_value(self, value)

Factory method: makes a float value :param value: The supplied primitive float value :type value: float

Returns:

The corresponding XDM value

Return type:

PyXdmAtomicValue

make_integer_value(self, value)

Factory method: makes either an Int64Value or a BigIntegerValue depending on the value supplied :param value: The supplied primitive integer value :type value: int

Returns:

The corresponding XDM value which is a BigIntegerValue or Int64Value as appropriate

Return type:

PyXdmAtomicValue

make_long_value(self, value)

Factory method: makes either an Int64Value or a BigIntegerValue depending on the value supplied :param value: The supplied primitive long value :type value: long

Returns:

The corresponding XDM value

Return type:

PyXdmAtomicValue

make_map(self, dict dataMap)

Make a PyXdmMap from a dict type whose entries are key-value pairs of type (PyXdmAtomicValue, PyXdmValue). The factory method create_xdm_dict(proc, mmap) can be used to create pairs of type (PyXdmAtomicValue, PyXdmValue) from primitive types, which can then be used as input to this function make_map. :param dataMap: Dictionary of (PyXdmAtomicValue, PyXdmValue) pairs :type dataMap: dict

Returns:

The corresponding value

Return type:

PyXdmMap

Example

mymap = {“a”:saxonproc.make_integer_value(1), “b”:saxonproc.make_integer_value(2),

“c”:saxonproc.make_integer_value(3)}

xdmdict = create_xdm_dict(saxonproc, mymap) map = saxonproc.make_map(xdmdict)

make_map2(self, dict dataMap, encoding=None)

Make a PyXdmMap from a dict type whose entries are key-value pairs of type (str, PyXdmValue). :param dataMap: Dictionary of (str, PyXdmValue) pairs :type dataMap: dict :param encoding: The encoding of the string. If not specified then the platform default encoding is used. :type encoding: str

Returns:

The corresponding value

Return type:

PyXdmMap

make_qname_value(self, str_, encoding=None)

Create a QName XDM value from string representation in clark notation :param str_: The value given in a string form in clark notation {uri}local :type str_: str :param encoding: The encoding of the string. If not specified then the platform default encoding is used. :type encoding: str

Returns:

The corresponding XDM value

Return type:

PyXdmAtomicValue

make_string_value(self, value, encoding=None)

Factory method to create an xs:string atomic value as a new PyXdmAtomicValue. :param value: The string value. NULL is taken as equivalent to “”. :type value: str :param encoding: The encoding of the string. If not specified then the platform default encoding is used. :type encoding: str

Returns:

The corresponding XDM string value

Return type:

PyXdmAtomicValue

new_document_builder(self)

Create a PyDocumentBuilder. A PyDocumentBuilder holds properties controlling how a Saxon document tree should be built, and provides methods to invoke the tree construction. :returns: a newly created PyDocumentBuilder :rtype: PyDocumentBuilder

new_schema_validator(self)

Create a PySchemaValidator which can be used to validate instance documents against the schema held by this processor. :returns: a newly created PySchemaValidator :rtype: PySchemaValidator

new_xpath_processor(self)

Create a PyXPathProcessor. A PyXPathProcessor is used to compile and execute XPath expressions. :returns: a newly created XPathProcessor :rtype: PyXPathProcessor

new_xquery_processor(self)

Create a PyXqueryProcessor. A PyXQueryProcessor is used to compile and execute XQuery queries. :returns: a newly created PyXQueryProcessor :rtype: PyXQueryProcessor

new_xslt30_processor(self)

Create a PyXslt30Processor. A PyXslt30Processor is used to compile and execute XSLT 3.0 stylesheets. :returns: a newly created PyXslt30Processor :rtype: PyXslt30Processor

parse_json(self, **kwds)

Parse a source JSON document supplied as a lexical representation or source file, and return it as an XDM value :param **kwds: Possible keyword arguments: one of the following (json_file_name|json_text) is required. :param The keyword ‘encoding’: :type The keyword ‘encoding’: str :param (if not specified then the platform default encoding is used).:

Returns:

The XDM value representation of the JSON document

Return type:

PyXdmValue

Raises:

Exception – Error if invalid use of keywords

parse_xml(self, **kwds)

Parse a source XML document supplied as a lexical representation, source file or uri, and return it as an XDM node :param **kwds: Possible keyword arguments: one of the following (xml_file_name|xml_text|xml_uri) is required. :param The keyword ‘encoding’: :type The keyword ‘encoding’: str :param (if not specified then the platform default encoding is used).:

Returns:

The XDM node representation of the XML document

Return type:

PyXdmNode

Raises:

Exception – Error if invalid use of keywords

resources_directory

Property represents the resources directory

set_catalog(self, str file_name)

Set the XML catalog to be used in Saxon This method is now deprecated. Use set_catalog_files :param file_name: The file name for the XML catalog :type file_name: str

set_catalog_files(self, str file_name)

Set the XML catalog files to be used in Saxon :param file_names list: List of strings for the XML catalog file names

set_configuration_property(self, name, value, encoding=None)

Set configuration property specific to the processor in use. Properties set here are common across all processors. :param name: The name of the property :type name: str :param value: The value of the property :type value: str :param encoding: The encoding of the string. If not specified then the platform default encoding is used. :type encoding: str

Example

‘l’: ‘on’ or ‘off’ - to enable the line number

set_cwd(self, cwd)

Set the current working directory :param cwd: current working directory :type cwd: str

set_resources_directory(self, dir_)

Set the resources directory :param dir_: A string of the resources directory which Saxon will use :type dir_: str

version

Get the Saxon Version. :returns: The Saxon version :rtype: str