| |
- builtins.RuntimeError(builtins.Exception)
-
- PySaxonApiError
- builtins.object
-
- PyDocumentBuilder
- PySaxonProcessor
- PySchemaValidator
- PyXPathProcessor
- PyXQueryProcessor
- PyXdmValue
-
- PyXdmItem
-
- PyXdmAtomicValue
- PyXdmFunctionItem
-
- PyXdmArray
- PyXdmMap
- PyXdmNode
- PyXdmValueIterator
- PyXslt30Processor
- PyXsltExecutable
- enum.IntEnum(builtins.int, enum.Enum)
-
- XdmNodeKind
- XdmType
class PyDocumentBuilder(builtins.object) |
|
A PyDocumentBuilder holds properties controlling how a Saxon document tree should be built, and
provides methods to invoke the tree construction.
This class has no public constructor. To construct a PyDocumentBuilder, use the factory method
PySaxonProcessor.new_document_builder(). |
|
Methods defined here:
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __reduce__ = __reduce_cython__(...)
- __setstate__ = __setstate_cython__(...)
- get_schema_validator(...)
- get_schema_validator(self)
Get the PySchemaValidator used to validate documents loaded using this PyDocumentBuilder
Returns:
PySchemaValidator: if one has been set; otherwise None.
- parse_xml(...)
- parse_xml(self, **kwds)
Parse a source document supplied as a lexical representation, source file or uri, and return it as XDM node
Args:
**kwds: Possible keyword arguments: one of the following (xml_file_name|xml_text|xml_uri) is required.
The keyword 'encoding' (str) can be used to specify the encoding used to decode the xml_text string
(if not specified then the platform default encoding is used).
Returns:
PyXdmNode: The XDM node representation of the XML document
Raises:
Exception: Error if invalid use of keywords.
PySaxonApiError: Error if failure to parse XML file or XML text
- set_base_uri(...)
- set_base_uri(self, base_uri)
Set the base URI of a document loaded using this PyDocumentBuilder. This is used for resolving any relative
URIs appearing within the document, for example in references to DTDs and external entities. This information
is required when the document is loaded from a source that does not provide an intrinsic URI, notably when
loading from a String. The value is ignored when loading from a source that does have an intrinsic base URI.
Args:
base_uri (str): the base output URI
- set_dtd_validation(...)
- set_dtd_validation(self, value)
Set whether DTD validation should be applied to documents loaded using this PyDocumentBuilder.
By default, no DTD validation takes place.
Args:
value (bool): true if DTD validation should be applied to loaded documents
- set_line_numbering(...)
- set_line_numbering(self, value)
Set whether line and column numbering and is to be enabled for documents constructed using this
PyDocumentBuilder. By default, line and column numbering is disabled.
Args:
value (bool): true if line numbers are to be maintained, false otherwise
- set_schema_validator(...)
- set_schema_validator(self, PySchemaValidator val)
Set the PySchemaValidator to be used. This determines whether schema validation is applied to an input
document and whether type annotations in a supplied document are retained. If no PySchemaValidator is supplied,
then schema validation does not take place.
This option requires the schema-aware version of the Saxon product (SaxonC-EE).
Since a PySchemaValidator is serially reusable but not thread-safe, using this method is not appropriate when
the PyDocumentBuilder is shared between threads.
Args:
val (PySchemaValidator): the schema validator to be used
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- base_uri
- base_uri(self)
Get the base URI of documents loaded using this PyDocumentBuilder when no other URI is available.
Returns:
str: String value of the base URI to be used. This may be NULL if no value has been set.
- dtd_validation
- dtd_validation(self)
bool: Ask whether DTD validation is to be applied to documents loaded using this PyDocumentBuilder
- line_numbering
- line_numbering(self)
bool: true if line numbering is enabled
|
class PySaxonApiError(builtins.RuntimeError) |
| |
- Method resolution order:
- PySaxonApiError
- builtins.RuntimeError
- builtins.Exception
- builtins.BaseException
- builtins.object
Data descriptors defined here:
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from builtins.RuntimeError:
- __init__(self, /, *args, **kwargs)
- Initialize self. See help(type(self)) for accurate signature.
Static methods inherited from builtins.RuntimeError:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Methods inherited from builtins.BaseException:
- __delattr__(self, name, /)
- Implement delattr(self, name).
- __getattribute__(self, name, /)
- Return getattr(self, name).
- __reduce__(...)
- Helper for pickle.
- __repr__(self, /)
- Return repr(self).
- __setattr__(self, name, value, /)
- Implement setattr(self, name, value).
- __setstate__(...)
- __str__(self, /)
- Return str(self).
- with_traceback(...)
- Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.
Data descriptors inherited from builtins.BaseException:
- __cause__
- exception cause
- __context__
- exception context
- __dict__
- __suppress_context__
- __traceback__
- args
|
class PySaxonProcessor(builtins.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)
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() |
|
Methods defined here:
- __enter__(...)
- enter method for use with the keyword 'with' context
Deprecated. This may be removed in a later release.
- __exit__(...)
- Deprecated. This method no longer does anything, and may be removed in a later release.
- __reduce__ = __reduce_cython__(...)
- __setstate__ = __setstate_cython__(...)
- clark_name_to_eqname(...)
- 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.
Args:
name (str): The URI in Clark notation: <code>{uri}local</code> if the name is in a namespace,
or simply <code>local</code> if not.
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
str: the expanded name, as a string using the notation defined by the EQName production in XPath 3.0.
- clear_configuration_properties(...)
- clear_configuration_properties(self)
Clear the configuration properties in use by the processor
- empty_sequence(...)
- Returns a PyXdmValue representing the empty sequence
Returns:
PyXdmValue: the empty sequence
- eqname_to_clark_name(...)
- eqname_to_clark_name(self, name, encoding=None)
Convert EQName string to clark name notation.
Args:
name (str): 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.
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
str: the URI inb clark notation
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown internally in SaxonC.
- get_string_value(...)
- get_string_value(self, PyXdmItem item)
Get the string value of the supplied PyXdmItem, as defined in the XPath data model
Args:
item (PyXdmItem): An XDM item
Returns:
str: The string value of this XDM item
- make_array(...)
- make_array(self, list values)
Make a PyXdmArray whose members are from a list of PyXdmValues
Args:
values (list): List of PyXdmValues
Returns:
PyXdmArray: The corresponding value
- make_atomic_value(...)
- make_atomic_value(self, value_type, value, encoding=None)
Create an XDM atomic value from string representation
Args:
value_type (str): Local name of a type in the XML Schema namespace
value (str): The value given in a string form. In the case of a QName the value supplied must be
in clark notation {uri}local.
encoding (str): The encoding of the value_type. If not specified then the platform default encoding is used.
Returns:
PyXdmAtomicValue: The corresponding XDM value
- make_boolean_value(...)
- make_boolean_value(self, value)
Factory method: makes a PyXdmAtomicValue representing a boolean value
Args:
value (bool): True or False, to determine which boolean value is required
Returns:
PyXdmAtomicValue: The corresponding XDM value
- make_double_value(...)
- make_double_value(self, value)
Factory method: makes a double value
Args:
value (double): The supplied primitive double value
Returns:
PyXdmAtomicValue: The corresponding XDM value
- make_float_value(...)
- make_float_value(self, value)
Factory method: makes a float value
Args:
value (float): The supplied primitive float value
Returns:
PyXdmAtomicValue: The corresponding XDM value
- make_integer_value(...)
- make_integer_value(self, value)
Factory method: makes either an Int64Value or a BigIntegerValue depending on the value supplied
Args:
value (int): The supplied primitive integer value
Returns:
PyXdmAtomicValue: The corresponding XDM value which is a BigIntegerValue or Int64Value as appropriate
- make_long_value(...)
- make_long_value(self, value)
Factory method: makes either an Int64Value or a BigIntegerValue depending on the value supplied
Args:
value (long): The supplied primitive long value
Returns:
PyXdmAtomicValue: The corresponding XDM value
- make_map(...)
- 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.
Args:
dataMap (dict): Dictionary of (PyXdmAtomicValue, PyXdmValue) pairs
Returns:
PyXdmMap: The corresponding value
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(...)
- make_map2(self, dict dataMap, encoding = None)
Make a PyXdmMap from a dict type whose entries are key-value pairs of type (str, PyXdmValue).
Args:
dataMap (dict): Dictionary of (str, PyXdmValue) pairs
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
PyXdmMap: The corresponding value
- make_qname_value(...)
- make_qname_value(self, str_, encoding=None)
Create a QName XDM value from string representation in clark notation
Args:
str_ (str): The value given in a string form in clark notation {uri}local
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
PyXdmAtomicValue: The corresponding XDM value
- make_string_value(...)
- make_string_value(self, value, encoding = None)
Factory method. Unlike the constructor, this avoids creating a new StringValue in the case
of a zero-length string (and potentially other strings, in future)
Args:
value (str): The String value. NULL is taken as equivalent to "".
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
PyXdmAtomicValue: The corresponding XDM string value
- new_document_builder(...)
- 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:
PyDocumentBuilder: a newly created PyDocumentBuilder
- new_schema_validator(...)
- new_schema_validator(self)
Create a PySchemaValidator which can be used to validate instance documents against the schema held by
this processor.
Returns:
PySchemaValidator: a newly created PySchemaValidator
- new_xpath_processor(...)
- new_xpath_processor(self)
Create a PyXPathProcessor. A PyXPathProcessor is used to compile and execute XPath expressions.
Returns:
PyXPathProcessor: a newly created XPathProcessor
- new_xquery_processor(...)
- new_xquery_processor(self)
Create a PyXqueryProcessor. A PyXQueryProcessor is used to compile and execute XQuery queries.
Returns:
PyXQueryProcessor: a newly created PyXQueryProcessor
- new_xslt30_processor(...)
- new_xslt30_processor(self)
Create a PyXslt30Processor. A PyXslt30Processor is used to compile and execute XSLT 3.0 stylesheets.
Returns:
PyXslt30Processor: a newly created PyXslt30Processor
- parse_json(...)
- parse_json(self, **kwds)
Parse a source JSON document supplied as a lexical representation or source file, and return it as an XDM value
Args:
**kwds: Possible keyword arguments: one of the following (json_file_name|json_text) is required.
The keyword 'encoding' (str) can be used to specify the encoding used to decode the json_text string
(if not specified then the platform default encoding is used).
Returns:
PyXdmValue: The XDM value representation of the JSON document
Raises:
Exception: Error if invalid use of keywords
- parse_xml(...)
- 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
Args:
**kwds: Possible keyword arguments: one of the following (xml_file_name|xml_text|xml_uri) is required.
The keyword 'encoding' (str) can be used to specify the encoding used to decode the xml_text string
(if not specified then the platform default encoding is used).
Returns:
PyXdmNode: The XDM node representation of the XML document
Raises:
Exception: Error if invalid use of keywords
- set_catalog(...)
- set_catalog(self, str file_name)
Set the XML catalog to be used in Saxon
This method is now deprecated. Use set_catalog_files
Args:
file_name (str): The file name for the XML catalog
- set_catalog_files(...)
- set_catalog_files(self, str file_name)
Set the XML catalog files to be used in Saxon
Args:
file_names list: List of strings for the XML catalog file names
- set_configuration_property(...)
- 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.
Args:
name (str): The name of the property
value (str): The value of the property
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Example:
'l': 'on' or 'off' - to enable the line number
- set_cwd(...)
- set_cwd(self, cwd)
Set the current working directory
Args:
cwd (str): current working directory
- set_resources_directory(...)
- set_resources_directory(self, dir_)
Set the resources directory
Args:
dir_ (str): A string of the resources directory which Saxon will use
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- attach_current_thread
- cwd
- cwd(self)
Property represents the current working directory
- detach_current_thread
- error_message
- error_message(self)
The PySaxonProcessor may have a number of errors reported against it. Get the error message
if there are any errors.
Returns:
str: The message of the exception. Returns None if the exception does not exist.
- exception_occurred
- exception_occurred(self)
Property to check if an exception has occurred internally within SaxonC
Returns:
boolean: True if an exception has been reported; otherwise False
- is_schema_aware
- is_schema_aware(self)
Property to check if the processor is schema aware. A licensed SaxonC-EE product is schema aware
Returns:
bool: True if the processor is schema aware, or False otherwise
- resources_directory
- resources_directory(self)
Property represents the resources directory
- version
- Get the Saxon Version.
Returns:
str: The Saxon version
Data and other attributes defined here:
- __pyx_vtable__ = <capsule object NULL>
|
class PySchemaValidator(builtins.object) |
|
A PySchemaValidator represents a factory for validating instance documents against a schema. |
|
Methods defined here:
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __reduce__ = __reduce_cython__(...)
- __setstate__ = __setstate_cython__(...)
- clear_parameters(...)
- clear_parameter(self)
Clear all parameters set on the processor
- clear_properties(...)
- clear_properties(self)
Clear all properties set on the processor
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- export_schema(...)
- export_schema(self, file_name)
Export a precompiled Schema Component Model containing all the components (except built-in components)
that have been loaded
Args:
file_name (str): The file name that will be used for the saved SCM
- get_error_code(...)
- get_error_code(self)
A validation may have a number of errors reported against it. Get the error code if there was an error.
Args:
Returns:
str: The error code associated with the exception thrown. Returns None if the exception does not exist.
- get_error_message(...)
- get_error_message(self)
A validation may have a number of errors reported against it. Get the error message if there
are any errors.
Args:
Returns:
str: The message of the exception. Returns None if the exception does not exist.
- register_schema(...)
- register_schema(self, **kwds)
Register a schema supplied as file name, schema text, or XDM node
Args:
**kwds: Possible keyword arguments: must be one of the following (xsd_text|xsd_file|xsd_node)
- remove_parameter(...)
- remove_parameter(self, name)
Remove the parameter given by name from the PySchemaValidator. The parameter will not have any effect on the
validation if it has not yet been executed.
Args:
name (str): The name of the schema parameter
Returns:
bool: True if the removal of the parameter has been successful, False otherwise.
- set_cwd(...)
- set_cwd(self, cwd)
Set the current working directory
Args:
cwd (str): current working directory
- set_lax(...)
- set_lax(self, lax)
The validation mode may be either strict or lax. The default is strict; this method may be called to
indicate that lax validation is required. With strict validation, validation fails if no element
declaration can be located for the outermost element. With lax validation, the absence of an element
declaration results in the content being considered valid.
Args:
lax (bool): True if validation is to be lax, False if it is to be strict
- set_output_file(...)
- set_output_file(self, output_file)
Set the name of the output file that will be used by the validator.
Args:
output_file (str): The output file name for use by the validator
- set_parameter(...)
- set_parameter(self, name, PyXdmValue value)
Set the value of a parameter for the Schema validator
Args:
name (str): the name of the schema parameter, as a string. For a namespaced parameter use
clark notation {uri}local
value (PyXdmValue): the value of the parameter, or NULL to clear a previously set value
- set_property(...)
- set_property(self, name, value, encoding = None)
Set a property specific to the processor in use.
Args:
name (str): The name of the property
value (str): The value of the property
encoding (str): The encoding of the name argument. Argument can be omitted or None.
If not specified then the platform default encoding is used.
Example:
PySchemaValidator: set serialization properties (names start with '!' i.e. name "!method" -> "xml")
'o': output file name,
'dtd': Possible values 'on' or 'off' to set DTD validation,
'resources': directory to find Saxon data files,
's': source as file name,
'string': Set the source as xml string for validation. Parsing will take place in the validate method
'report-node': Boolean flag for validation reporting feature. Error validation failures are represented
in an XML document and returned as a PyXdmNode object
'report-file': Specify value as a file name string. This will switch on the validation reporting feature,
which will be saved to the file in an XML format
'verbose': boolean value which sets the verbose mode to the output in the terminal. Default is 'on'
'element-type': Set the name of the required type of the top-level element of the document to be validated.
The string should be in clark notation {uri}local
'lax': Boolean to set the validation mode to strict (False) or lax ('True')
- set_source_node(...)
- set_source_node(self, PyXdmNode source)
Set the source node for validation
Args:
source (PyXdmNode): the source node to be validated
- validate(...)
- validate(self, **kwds)
Validate an instance document by a registered schema.
Args:
**kwds: Possible keyword arguments: must be one of the following (file_name|xdm_node|xml_text).
Specifies the source file to be validated. Allow None when source document is
supplied using the set_source_node method
Raises:
Exception: Error if incorrect keyword used, options available: file_name|xdm_node|xml_text
PySaxonApiError: if the source document is found to be invalid, or if error conditions occur
that prevented validation from taking place (such as failure to read or parse the input document)
- validate_to_node(...)
- validate_to_node(self, **kwds)
Validate an instance document by a registered schema, returning the validated document.
Args:
**kwds: Possible keyword arguments: must be one of the following (file_name|xdm_node|xml_text).
Specifies the source file to be validated. Allow None when source document is supplied
using the set_source_node method.
Returns:
PyXdmNode: The validated document returned to the calling program as a PyXdmNode
Raises:
Exception: Error if incorrect keyword used, options available: file_name|xdm_node|xml_text
PySaxonApiError: if the source document is found to be invalid, or if error conditions occur
that prevented validation from taking place (such as failure to read or parse the input document)
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- exception_occurred
- exception_occurred(self)
Property to check if an exception has occurred internally within SaxonC
Returns:
boolean: True if an exception has been reported; otherwise False
- validation_report
- validation_report(self)
Get the validation report
Returns:
PyXdmNode: The Validation report result from the Schema validator
Raises:
PySaxonApiError: if the source document is found to be invalid, or if error conditions occur
that prevented validation from taking place (such as failure to read or parse the input document)
|
class PyXPathProcessor(builtins.object) |
|
A PyXPathProcessor represents a factory to compile, load and execute XPath expressions. |
|
Methods defined here:
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __reduce__ = __reduce_cython__(...)
- __setstate__ = __setstate_cython__(...)
- clear_parameters(...)
- clear_parameter(self)
Clear all parameters set on the processor
- clear_properties(...)
- clear_parameter(self)
Clear all properties set on the processor
- declare_namespace(...)
- declare_namespace(self, prefix, uri)
Declare a namespace binding as part of the static context for XPath expressions compiled using this processor
Args:
prefix (str): The namespace prefix. If the value is a zero-length string, this method sets the default
namespace for elements and types.
uri (uri): The 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.
- declare_variable(...)
- declare_variable(self, str name)
Declare a variable as part of the static context for XPath expressions compiled using this processor.
It is an error for the XPath expression to refer to a variable unless it has been declared. This method
declares the existence of the variable, but it does not bind any value to the variable; that is done later,
when the XPath expression is evaluated. The variable is allowed to have any type (that is, the required
type is item()*).
Args:
name (str): The name of the variable, as a string in clark notation
- effective_boolean_value(...)
- effective_boolean_value(self, xpath_str)
Evaluate the XPath expression, returning the effective boolean value of the result.
Args:
xpath_str (str): XPath expression supplied as a string
encoding (str): The encoding of the XPath string. Argument can be omitted or None.
If not specified then the platform default encoding is used.
Returns:
boolean: The result is a boolean value.
Raises:
PySaxonApiError: Error if failure to evaluate XPath expression
- evaluate(...)
- evaluate(self, xpath_str)
Evaluate an XPath expression supplied as a string
Args:
xpath_str (str): The XPath expression supplied as a string
encoding (str): The encoding of the XPath string. Argument can be omitted or None.
If not specified then the platform default encoding is used.
Returns:
PyXdmValue: the result of evaluating the XPath expression
Raises:
PySaxonApiError: Error if failure to evaluate XPath expression
- evaluate_single(...)
- evaluate_single(self, xpath_str)
Evaluate an XPath expression supplied as a string, returning a single item
Args:
xpath_str (str): The XPath expression supplied as a string
encoding (str): The encoding of the XPath string. Argument can be omitted or None.
If not specified then the platform default encoding is used.
Returns:
PyXdmItem: A single XDM item is returned. Returns None 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.
Raises:
PySaxonApiError: Error if failure to evaluate XPath expression
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- import_schema_namespace(...)
- import_schema_namespace(self, uri)
Import a schema namespace
Args:
uri (str): The schema namespace to be imported. To import declarations in a no-namespace schema,
supply a zero-length string.
- remove_parameter(...)
- remove_parameter(self, name)
Remove the parameter given by name from the PyXPathProcessor. The parameter will not have any effect on the
XPath if it has not yet been executed.
Args:
name (str): The name of the XPath parameter
Returns:
bool: True if the removal of the parameter has been successful, False otherwise.
- set_backwards_compatible(...)
- set_backwards_compatible(self, option)
Say whether XPath 1.0 backwards compatibility mode is to be used
Args:
option (bool): true if XPath 1.0 backwards compatibility is to be enabled, false if it is to be disabled.
- set_base_uri(...)
- set_base_uri(self, base_uri)
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.
Args:
base_uri (str): the base output URI
- set_caching(...)
- set_caching(self, is_caching)
Say whether the compiler should maintain a cache of compiled expressions.
Args:
is_caching (bool): if 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 declare_variable() or
declare_namespace().
- set_context(...)
- set_context(self, **kwds)
Set the initial context for the XPath expression
Args:
**kwds: Possible keyword arguments: file_name (str) or xdm_item (PyXdmItem)
- set_cwd(...)
- set_cwd(self, cwd)
Set the current working directory
Args:
cwd (str): current working directory
- set_language_version(...)
- set_language_version(self, version)
Say whether an XPath 2.0, XPath 3.0, XPath 3.1 or XPath 4.0 processor is required.
Args:
value (str): One of the values 1.0, 2.0, 3.0, 3.05, 3.1, 4.0.
- set_parameter(...)
- set_parameter(self, name, value)
Set the value of an XPath parameter
Args:
name (str): the name of the XPath parameter, as a string. For a namespaced parameter use
clark notation {uri}local
value (PyXdmValue): the value of the query parameter, or NULL to clear a previously set value
- set_property(...)
- set_property(self, name, value)
Set a property specific to the processor in use.
Args:
name (str): The name of the property
value (str): The value of the property
Example:
PyXPathProcessor: set serialization properties (names start with '!' i.e. name "!method" -> "xml")
'resources': directory to find Saxon data files,
's': source as file name,
'extc': Register native library to be used with extension functions
- set_unprefixed_element_matching_policy(...)
- set_unprefixed_element_matching_policy(self, int policy)
Set the policy for matching unprefixed element names in XPath expressions.
Possible int values: DEFAULT_NAMESPACE = 0, ANY_NAMESPACE = 1 or DEFAULT_NAMESPACE_OR_NONE = 2
Args:
policy (int): The policy to be used
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- base_uri
- get_base_uri(self)
Get 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.
Returns:
str: the base output URI as a string representation of the URI
- error_code
- error_code(self)
An expression may have a number of errors reported against it. This property returns the error code
if there are any errors.
Returns:
str: The error code associated with the exception. Returns None if the exception does not exist.
- error_message
- error_message(self)
An expression may have a number of errors reported against it. This property returns the error message
if there are any errors.
Returns:
str: The message of the exception. Returns None if the exception does not exist.
- exception_occurred
- exception_occurred(self)
Check if an exception has occurred internally within SaxonC
Returns:
boolean: True if an exception has been reported; otherwise False
|
class PyXQueryProcessor(builtins.object) |
|
A PyXQueryProcessor represents a factory to compile, load and execute queries. |
|
Methods defined here:
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __reduce__ = __reduce_cython__(...)
- __setstate__ = __setstate_cython__(...)
- check_exception(...)
- check_exception(self)
Check for exception thrown and get message of the exception.
Returns:
str: Returns the exception message if thrown otherwise returns None
- clear_parameters(...)
- clear_parameters(self)
Clear all parameters set on the processor
- clear_properties(...)
- clear_properties(self)
Clear all properties set on the processor
- declare_namespace(...)
- declare_namespace(self, prefix, uri)
Declare a namespace binding as part of the static context for queries compiled using this processor.
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.
Args:
prefix (str): The namespace prefix. If the value is a zero-length string, this method sets the default
namespace for elements and types.
uri (str) : The 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.
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- is_streaming(...)
- is_streaming(self, bool option)
Ask whether the streaming option has been set.
Returns:
true if the streaming option has been set.
- remove_parameter(...)
- remove_parameter(self, name)
Remove the parameter given by name from the PyXQueryProcessor. The parameter will not have any effect on the
query if it has not yet been executed.
Args:
name (str): The name of the query parameter
Returns:
bool: True if the removal of the parameter has been successful, False otherwise.
- run_query_to_file(...)
- run_query_to_file(self, **kwds)
Execute a query with the result saved to file.
Args:
**kwds: Possible arguments: output_file_name (str) to specify the output file, if
omitted then the output file name needs to be supplied as a property;
input_file_name (str) or input_xdm_item (PyXdmItem) can be used to supply
the input; query_file (str) or query_text (str) can be used to supply the query;
lang (str) can be used to specify which version of XQuery should be used,
options: '3.1' or '4.0'.
Also accept the keyword 'encoding' (str) to specify the encoding of the query_text string
is specified. If not specified then the platform default encoding is used.
Raises:
PySaxonApiError: Error if failure to run query
Exception: Error if invalid use of keywords
- run_query_to_string(...)
- run_query_to_string(self, **kwds)
Execute a query and return the result as a string.
Args:
**kwds: Possible keyword arguments: input_file_name (str) or input_xdm_item (PyXdmItem) can be used to
supply the input; query_file (str) or query_text (str) can be used to supply the query;
lang (str) can be used to specify which version of XQuery should be used, options: '3.1' or '4.0'.
Also accept the keyword 'encoding' (str) to specify the encoding of the query_text string
is specified. If not specified then the platform default encoding is used.
Returns:
str: Output result as a string
Raises:
PySaxonApiError: Error if failure to run query
Exception: Error if invalid use of keywords
- run_query_to_value(...)
- run_query_to_value(self, **kwds)
Execute a query and return the result as a PyXdmValue object.
Args:
**kwds: Possible keyword arguments: input_file_name (str) or input_xdm_item (PyXdmItem) can be used to
supply the input; query_file (str) or query_text (str) can be used to supply the query;
lang (str) can be used to specify which version of XQuery should be used, options: '3.1' or '4.0'.
Also accept the keyword 'encoding' (str) to specify the encoding of the query_text string
is specified. If not specified then the platform default encoding is used.
Returns:
PyXdmValue: Output result as a PyXdmValue
Raises:
PySaxonApiError: Error if failure to run query
Exception: Error if invalid use of keywords
- set_context(...)
- set_context(self, **kwds)
Set the initial context for the query
Args:
**kwds: Possible keyword arguments: file_name (str) or xdm_item (PyXdmItem)
- set_cwd(...)
- set_cwd(self, cwd)
Set the current working directory.
Args:
cwd (str): current working directory
- set_output_file(...)
- set_output_file(self, output_file)
Set the output file where the result is sent
Args:
output_file (str): Name of the output file
- set_parameter(...)
- set_parameter(self, name, PyXdmValue value)
Set the value of a query parameter
Args:
name (str): the name of the stylesheet parameter, as a string. For a namespaced parameter use
clark notation {uri}local
value (PyXdmValue): the value of the query parameter
- set_property(...)
- set_property(self, name, str value)
Set a property specific to the processor in use.
Args:
name (str): The name of the property
value (str): The value of the property
Example:
PyXQueryProcessor: set serialization properties (names start with '!' i.e. name "!method" -> "xml")
'o': output file name,
'dtd': Possible values 'on' or 'off' to set DTD validation,
'resources': directory to find Saxon data files,
's': source as file name,
- set_query_base_uri(...)
- set_query_base_uri(self, base_uri)
Set the static base URI for the query
Args:
base_uri (str): The static base URI; or None to indicate that no base URI is available
- set_query_content(...)
- set_query_content(self, str content)
Supply the query as a string
Args:
content (str): The query content supplied as a string
- set_query_file(...)
- set_query_file(self, file_name)
Supply the query as a file
Args:
file_name (str): The file name for the query
- set_streaming(...)
- set_streaming(self, bool option)
Say whether the query should be compiled and evaluated to use streaming. Option requires SaxonC-EE.
Args:
option (bool): if 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.
- set_updating(...)
- set_updating(self, 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 SaxonC-EE.
Args:
updating (bool): true if the query is allowed to use the XQuery Update facility (requires SaxonC-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.
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- error_code
- error_code(self)
A query may have a number of errors reported against it. This property returns the error code
if there are any errors.
Returns:
str: The error code associated with the exception. Returns None if the exception does not exist.
- error_message
- error_message(self)
A query may have a number of errors reported against it. This property returns an error message
if there are any errors.
Returns:
str: The message of the exception. Returns None if the exception does not exist.
- exception_occurred
- exception_occurred(self)
Property to check for pending exceptions without creating a local reference to the exception object
Returns:
boolean: True when there is a pending exception; otherwise False
|
class PyXdmArray(PyXdmFunctionItem) |
|
The class PyXdmArray represents an array in the XDM data model. An array is a list of zero or more members,
each of which is an arbitrary XDM value. The array itself is an XDM item. A PyXdmArray is immutable. |
|
- Method resolution order:
- PyXdmArray
- PyXdmFunctionItem
- PyXdmItem
- PyXdmValue
- builtins.object
Methods defined here:
- __iter__(...)
- __iter__(self)
Returns the Iterator object of PyXdmArray
- __reduce__ = __reduce_cython__(...)
- __repr__(self, /)
- Return repr(self).
- __setstate__ = __setstate_cython__(...)
- __str__(self, /)
- Return str(self).
- add_member(...)
- add_member(self, value)
Append a new member to an array.
Args:
value (PyXdmValue): the new member
Returns:
PyXdmArray: a new array, one item longer than the original
- as_list(...)
- as_list(self)
Get the members of the array in the form of a list.
Returns:
list: list of the members of this array
- concat(...)
- concat(self, PyXdmArray value)
Concatenate another array to this array
Args:
value (PyXdmArray): the other array
Returns:
PyXdmArray: a new array, containing the members of this array followed by the members of the other array
- get(...)
- get(self, int n)
Get the n'th member in the array, counting from zero
Args:
n (int): the member that is required, counting the first member in the array as member zero
Returns:
PyXdmValue: the n'th member in the sequence making up the array, counting from zero
- put(...)
- put(self, int n, PyXdmValue value)
Create a new array in which one member is replaced with a new value.
Args:
n (int): n the position of the member that is to be replaced, counting the first member
in the array as member zero
value (PyXdmValue): the new value for this member
Returns:
PyXdmArray: a new array, the same length as the original, with one member replaced by a new value
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- arity
- arity(self)
Get the arity of the function
Returns:
int: the arity of the function, that is, the number of arguments in the function's signature
- array_length
- array_length(self)
Get the number of members in the array
Returns:
int: the number of members in the array. (Note that the size() method returns 1 (one),
because an XDM array is an item.)
- string_value
- string_value(self)
Property to get the string value of the PyXdmArray
Returns:
str: String value of the array item
Data and other attributes defined here:
- __pyx_vtable__ = <capsule object NULL>
Methods inherited from PyXdmFunctionItem:
- call(...)
- call(self, list args)
Call the function
Args:
args (list): the values to be supplied as arguments to the function. The "function
conversion rules" will be applied to convert the arguments to the required
type when necessary.
Returns:
PyXdmValue: the result of calling the function
Static methods inherited from PyXdmFunctionItem:
- get_system_function(...)
- get_system_function(self, PySaxonProcessor proc, str name, arity, encoding=None)
Get a system function. This can be any function defined in XPath 3.1 functions and operators,
including functions in the math, map, and array namespaces. It can also be a Saxon extension
function, provided a licensed Processor is used.
Args:
proc (PySaxonProcessor): the Saxon processor
name (str): the name of the requested function as an EQName or clark name
arity (int): the arity of the requested function
encoding (str): the encoding of the name string. If not specified then the platform default encoding is used.
Returns:
PyXdmFunctionItem: the requested function
Data descriptors inherited from PyXdmFunctionItem:
- name
- name(self)
Get the name of the function
Returns:
str: The name of the function as an EQName
Methods inherited from PyXdmItem:
- get_array_value(...)
- get_array_value(self)
Get the subclass PyXdmArray for this current PyXdmItem object if it is an array item
Returns:
PyXdmArray: Subclass this object to PyXdmArray or error
- get_atomic_value(...)
- get_atomic_value(self)
Get the subclass PyXdmAtomicValue for this current PyXdmItem object if it is an atomic value
Returns:
PyXdmAtomicValue: Subclass this object to PyXdmAtomicValue or error
- get_function_value(...)
- get_function_value(self)
Get the subclass PyXdmFunctionItem for this current PyXdmItem object if it is a function item
Returns:
PyXdmFunctionItem: Subclass this object to PyXdmFunctionItem or error
- get_map_value(...)
- get_map_value(self)
Get the subclass PyXdmMap for this current PyXdmItem object if it is a map item
Returns:
PyXdmNode: Subclass this object to PyXdmMap or error
- get_node_value(...)
- get_node_value(self)
Get the subclass PyXdmNode for this current PyXdmItem object if it is a node
Returns:
PyXdmNode: Subclass this object to PyXdmNode or error
- get_string_value(...)
- get_string_value(self, encoding=None)
Property to get the string value of the item as defined in the XPath data model
Args:
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
str: The string value of this node
- item_at(...)
- item_at(self, index)
Get the n'th item in the sequence, counting from zero.
Args:
index (int): the index of the item required, counting from zero
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
Data descriptors inherited from PyXdmItem:
- head
- head(self)
Property to get the first item in the sequence represented by this PyXdmItem. Since a PyXdmItem is a sequence
of length one, this returns the PyXdmItem itself.
Returns:
PyXdmItem: The PyXdmItem or None if the sequence is empty
- is_array
- is_array(self)
Property to check if the current PyXdmItem is an array item
Returns:
bool: True if the current item is an array item
- is_atomic
- is_atomic(self)
Property to check if the current PyXdmItem is an atomic value
Returns:
bool: True if the current item is an atomic value
- is_function
- is_function(self)
Property to check if the current PyXdmItem is a function item
Returns:
bool: True if the current item is a function item
- is_map
- is_map(self)
Property to check if the current PyXdmItem is a map item
Returns:
bool: True if the current item is a map item
- is_node
- is_node(self)
Property to check if the current PyXdmItem is a node
Returns:
bool: True if the current item is a node
Methods inherited from PyXdmValue:
- __getitem__(...)
- __getitem__(self, index)
Implement the built-in subscript operator (i.e. square brackets []) to return the ith item in the sequence
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- add_xdm_item(...)
- add_xdm_item(self, PyXdmItem value)
Add an item to the XDM sequence
Args:
value (PyXdmItem): The PyXdmItem object to add to the sequence
Data descriptors inherited from PyXdmValue:
- size
- size(self)
Get the number of items in the sequence
Returns:
int: The count of items in the sequence
|
class PyXdmAtomicValue(PyXdmItem) |
|
The class PyXdmAtomicValue represents an item in an XPath sequence that is an atomic value. The value may
belong to any of the 19 primitive types defined in XML Schema, or to a type derived from these primitive
types, or the XPath type xs:untypedAtomic. |
|
- Method resolution order:
- PyXdmAtomicValue
- PyXdmItem
- PyXdmValue
- builtins.object
Methods defined here:
- __eq__(self, value, /)
- Return self==value.
- __ge__(self, value, /)
- Return self>=value.
- __gt__(self, value, /)
- Return self>value.
- __hash__(self, /)
- Return hash(self).
- __int__(self, /)
- int(self)
- __le__(self, value, /)
- Return self<=value.
- __lt__(self, value, /)
- Return self<value.
- __ne__(self, value, /)
- Return self!=value.
- __reduce__ = __reduce_cython__(...)
- __repr__(...)
- ___repr__(self)
- __setstate__ = __setstate_cython__(...)
- __str__(...)
- __str__(self)
The string value of the node as returned by the toString method
Returns:
str: String value of this node
- get_string_value(...)
- get_string_value(self, encoding=None)
Property to get the string value of the atomic value as defined in the XPath data model
Args:
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
str: The string value of this node
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- boolean_value
- boolean_value(self)
Get the boolean value of the PyXdmAtomicValue, converted using the XPath casting rules
Returns:
bool: the result of converting to a boolean
- double_value
- double_value(self)
Get the double value of the PyXdmAtomicValue, converted using the XPath casting rules
Returns:
double: the result of converting to a double
- head
- head(self)
Property to get the first item in the sequence represented by this PyXdmAtomicValue. Since a PyXdmItem
is a sequence of length one, this returns the PyXdmAtomicValue itself.
Returns:
PyXdmAtomicValue: The PyXdmAtomicValue or None if the sequence is empty
- integer_value
- integer_value(self)
Get the integer value of the PyXdmAtomicValue, converted using the XPath casting rules
Returns:
int: the result of converting to an integer
- primitive_type_name
- primitive_type_name(self)
Get the primitive type name of the PyXdmAtomicValue
Returns:
str: String of the primitive type name
- string_value
- string_value(self)
Get the string value of the PyXdmAtomicValue, converted using the XPath casting rules
Returns:
str: the result of converting to a string
Data and other attributes defined here:
- __pyx_vtable__ = <capsule object NULL>
Methods inherited from PyXdmItem:
- get_array_value(...)
- get_array_value(self)
Get the subclass PyXdmArray for this current PyXdmItem object if it is an array item
Returns:
PyXdmArray: Subclass this object to PyXdmArray or error
- get_atomic_value(...)
- get_atomic_value(self)
Get the subclass PyXdmAtomicValue for this current PyXdmItem object if it is an atomic value
Returns:
PyXdmAtomicValue: Subclass this object to PyXdmAtomicValue or error
- get_function_value(...)
- get_function_value(self)
Get the subclass PyXdmFunctionItem for this current PyXdmItem object if it is a function item
Returns:
PyXdmFunctionItem: Subclass this object to PyXdmFunctionItem or error
- get_map_value(...)
- get_map_value(self)
Get the subclass PyXdmMap for this current PyXdmItem object if it is a map item
Returns:
PyXdmNode: Subclass this object to PyXdmMap or error
- get_node_value(...)
- get_node_value(self)
Get the subclass PyXdmNode for this current PyXdmItem object if it is a node
Returns:
PyXdmNode: Subclass this object to PyXdmNode or error
- item_at(...)
- item_at(self, index)
Get the n'th item in the sequence, counting from zero.
Args:
index (int): the index of the item required, counting from zero
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
Data descriptors inherited from PyXdmItem:
- is_array
- is_array(self)
Property to check if the current PyXdmItem is an array item
Returns:
bool: True if the current item is an array item
- is_atomic
- is_atomic(self)
Property to check if the current PyXdmItem is an atomic value
Returns:
bool: True if the current item is an atomic value
- is_function
- is_function(self)
Property to check if the current PyXdmItem is a function item
Returns:
bool: True if the current item is a function item
- is_map
- is_map(self)
Property to check if the current PyXdmItem is a map item
Returns:
bool: True if the current item is a map item
- is_node
- is_node(self)
Property to check if the current PyXdmItem is a node
Returns:
bool: True if the current item is a node
Methods inherited from PyXdmValue:
- __getitem__(...)
- __getitem__(self, index)
Implement the built-in subscript operator (i.e. square brackets []) to return the ith item in the sequence
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __iter__(...)
- __iter__(self)
Returns the Iterator object of PyXdmValue
- add_xdm_item(...)
- add_xdm_item(self, PyXdmItem value)
Add an item to the XDM sequence
Args:
value (PyXdmItem): The PyXdmItem object to add to the sequence
Data descriptors inherited from PyXdmValue:
- size
- size(self)
Get the number of items in the sequence
Returns:
int: The count of items in the sequence
|
class PyXdmFunctionItem(PyXdmItem) |
|
The class PyXdmFunctionItem represents a function item |
|
- Method resolution order:
- PyXdmFunctionItem
- PyXdmItem
- PyXdmValue
- builtins.object
Methods defined here:
- __reduce__ = __reduce_cython__(...)
- __repr__(self, /)
- Return repr(self).
- __setstate__ = __setstate_cython__(...)
- __str__(self, /)
- Return str(self).
- call(...)
- call(self, list args)
Call the function
Args:
args (list): the values to be supplied as arguments to the function. The "function
conversion rules" will be applied to convert the arguments to the required
type when necessary.
Returns:
PyXdmValue: the result of calling the function
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
- get_system_function(...)
- get_system_function(self, PySaxonProcessor proc, str name, arity, encoding=None)
Get a system function. This can be any function defined in XPath 3.1 functions and operators,
including functions in the math, map, and array namespaces. It can also be a Saxon extension
function, provided a licensed Processor is used.
Args:
proc (PySaxonProcessor): the Saxon processor
name (str): the name of the requested function as an EQName or clark name
arity (int): the arity of the requested function
encoding (str): the encoding of the name string. If not specified then the platform default encoding is used.
Returns:
PyXdmFunctionItem: the requested function
Data descriptors defined here:
- arity
- arity(self)
Get the arity of the function
Returns:
int: The arity of the function, that is, the number of arguments in the function's signature
- name
- name(self)
Get the name of the function
Returns:
str: The name of the function as an EQName
- string_value
- string_value(self)
Property to get the string value of the PyXdmFunctionItem
Returns:
str: String value of the function item
Data and other attributes defined here:
- __pyx_vtable__ = <capsule object NULL>
Methods inherited from PyXdmItem:
- get_array_value(...)
- get_array_value(self)
Get the subclass PyXdmArray for this current PyXdmItem object if it is an array item
Returns:
PyXdmArray: Subclass this object to PyXdmArray or error
- get_atomic_value(...)
- get_atomic_value(self)
Get the subclass PyXdmAtomicValue for this current PyXdmItem object if it is an atomic value
Returns:
PyXdmAtomicValue: Subclass this object to PyXdmAtomicValue or error
- get_function_value(...)
- get_function_value(self)
Get the subclass PyXdmFunctionItem for this current PyXdmItem object if it is a function item
Returns:
PyXdmFunctionItem: Subclass this object to PyXdmFunctionItem or error
- get_map_value(...)
- get_map_value(self)
Get the subclass PyXdmMap for this current PyXdmItem object if it is a map item
Returns:
PyXdmNode: Subclass this object to PyXdmMap or error
- get_node_value(...)
- get_node_value(self)
Get the subclass PyXdmNode for this current PyXdmItem object if it is a node
Returns:
PyXdmNode: Subclass this object to PyXdmNode or error
- get_string_value(...)
- get_string_value(self, encoding=None)
Property to get the string value of the item as defined in the XPath data model
Args:
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
str: The string value of this node
- item_at(...)
- item_at(self, index)
Get the n'th item in the sequence, counting from zero.
Args:
index (int): the index of the item required, counting from zero
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
Data descriptors inherited from PyXdmItem:
- head
- head(self)
Property to get the first item in the sequence represented by this PyXdmItem. Since a PyXdmItem is a sequence
of length one, this returns the PyXdmItem itself.
Returns:
PyXdmItem: The PyXdmItem or None if the sequence is empty
- is_array
- is_array(self)
Property to check if the current PyXdmItem is an array item
Returns:
bool: True if the current item is an array item
- is_atomic
- is_atomic(self)
Property to check if the current PyXdmItem is an atomic value
Returns:
bool: True if the current item is an atomic value
- is_function
- is_function(self)
Property to check if the current PyXdmItem is a function item
Returns:
bool: True if the current item is a function item
- is_map
- is_map(self)
Property to check if the current PyXdmItem is a map item
Returns:
bool: True if the current item is a map item
- is_node
- is_node(self)
Property to check if the current PyXdmItem is a node
Returns:
bool: True if the current item is a node
Methods inherited from PyXdmValue:
- __getitem__(...)
- __getitem__(self, index)
Implement the built-in subscript operator (i.e. square brackets []) to return the ith item in the sequence
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __iter__(...)
- __iter__(self)
Returns the Iterator object of PyXdmValue
- add_xdm_item(...)
- add_xdm_item(self, PyXdmItem value)
Add an item to the XDM sequence
Args:
value (PyXdmItem): The PyXdmItem object to add to the sequence
Data descriptors inherited from PyXdmValue:
- size
- size(self)
Get the number of items in the sequence
Returns:
int: The count of items in the sequence
|
class PyXdmItem(PyXdmValue) |
|
The class PyXdmItem represents an item in a sequence, as defined by the XDM data model.
An item is either an atomic value, a node, or a function item. |
|
- Method resolution order:
- PyXdmItem
- PyXdmValue
- builtins.object
Methods defined here:
- __reduce__ = __reduce_cython__(...)
- __repr__(self, /)
- Return repr(self).
- __setstate__ = __setstate_cython__(...)
- __str__(self, /)
- Return str(self).
- get_array_value(...)
- get_array_value(self)
Get the subclass PyXdmArray for this current PyXdmItem object if it is an array item
Returns:
PyXdmArray: Subclass this object to PyXdmArray or error
- get_atomic_value(...)
- get_atomic_value(self)
Get the subclass PyXdmAtomicValue for this current PyXdmItem object if it is an atomic value
Returns:
PyXdmAtomicValue: Subclass this object to PyXdmAtomicValue or error
- get_function_value(...)
- get_function_value(self)
Get the subclass PyXdmFunctionItem for this current PyXdmItem object if it is a function item
Returns:
PyXdmFunctionItem: Subclass this object to PyXdmFunctionItem or error
- get_map_value(...)
- get_map_value(self)
Get the subclass PyXdmMap for this current PyXdmItem object if it is a map item
Returns:
PyXdmNode: Subclass this object to PyXdmMap or error
- get_node_value(...)
- get_node_value(self)
Get the subclass PyXdmNode for this current PyXdmItem object if it is a node
Returns:
PyXdmNode: Subclass this object to PyXdmNode or error
- get_string_value(...)
- get_string_value(self, encoding=None)
Property to get the string value of the item as defined in the XPath data model
Args:
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
str: The string value of this node
- item_at(...)
- item_at(self, index)
Get the n'th item in the sequence, counting from zero.
Args:
index (int): the index of the item required, counting from zero
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- head
- head(self)
Property to get the first item in the sequence represented by this PyXdmItem. Since a PyXdmItem is a sequence
of length one, this returns the PyXdmItem itself.
Returns:
PyXdmItem: The PyXdmItem or None if the sequence is empty
- is_array
- is_array(self)
Property to check if the current PyXdmItem is an array item
Returns:
bool: True if the current item is an array item
- is_atomic
- is_atomic(self)
Property to check if the current PyXdmItem is an atomic value
Returns:
bool: True if the current item is an atomic value
- is_function
- is_function(self)
Property to check if the current PyXdmItem is a function item
Returns:
bool: True if the current item is a function item
- is_map
- is_map(self)
Property to check if the current PyXdmItem is a map item
Returns:
bool: True if the current item is a map item
- is_node
- is_node(self)
Property to check if the current PyXdmItem is a node
Returns:
bool: True if the current item is a node
- string_value
- string_value(self)
Property to get the string value of the PyXdmItem
Data and other attributes defined here:
- __pyx_vtable__ = <capsule object NULL>
Methods inherited from PyXdmValue:
- __getitem__(...)
- __getitem__(self, index)
Implement the built-in subscript operator (i.e. square brackets []) to return the ith item in the sequence
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __iter__(...)
- __iter__(self)
Returns the Iterator object of PyXdmValue
- add_xdm_item(...)
- add_xdm_item(self, PyXdmItem value)
Add an item to the XDM sequence
Args:
value (PyXdmItem): The PyXdmItem object to add to the sequence
Data descriptors inherited from PyXdmValue:
- size
- size(self)
Get the number of items in the sequence
Returns:
int: The count of items in the sequence
|
class PyXdmMap(PyXdmFunctionItem) |
|
The class PyXdmMap represents a map item in the XDM data model. A map is a list of zero or more entries, each of
which is a pair comprising a key (which is an atomic value) and a value (which is an arbitrary value).
The map itself is an XDM item. A PyXdmMap is immutable. |
|
- Method resolution order:
- PyXdmMap
- PyXdmFunctionItem
- PyXdmItem
- PyXdmValue
- builtins.object
Methods defined here:
- __iter__(...)
- __iter__(self)
Returns the Iterator object of PyXdmMap
- __reduce__ = __reduce_cython__(...)
- __repr__(self, /)
- Return repr(self).
- __setstate__ = __setstate_cython__(...)
- __str__(self, /)
- Return str(self).
- contains_key(...)
- contains_key(self, PyXdmAtomicValue key)
Returns true if this map contains a mapping for the specified key.
Args:
key (PyXdmAtomicValue): key whose presence in this map is to be tested
Returns:
bool: true if this map contains a mapping for the specified key
- get(...)
- get(self, key, encoding=None)
Returns the value to which the specified key is mapped, or NULL if this map contains no mapping for the key.
All keys in the PyXdmMap are of type PyXdmAtomicValue, but for convenience, this method also accepts keys of
primitive type (str, int and float), which will be converted to PyXdmAtomicValue internally.
Args:
key: the key whose associated value is to be returned. The key supports the following types:
PyXdmAtomicValue, str, int and float
encoding (str): The encoding of the key, if supplied as a string. If not specified then the platform
default encoding is used.
Returns:
PyXdmValue: the value to which the specified key is mapped, or NULL if this map contains no
mapping for the key
- keys(...)
- keys(self)
Get the keys in the PyXdmMap
Returns:
list[PyXdmAtomicValue]: List of PyXdmAtomicValue objects
- put(...)
- put(self, PyXdmAtomicValue key, PyXdmValue value)
Create a new map containing an additional (key, value) pair. If there is an existing entry with
the same key, it is replaced.
Args:
key (PyXdmAtomicValue): The key for the new map entry
value (PyXdmValue): The value for the new map entry
Returns:
PyXdmMap: a new map containing the new entry. The original map is unchanged.
- remove(...)
- remove(self, PyXdmAtomicValue key)
Create a new map in which the entry for a given key has been removed.
Args:
key (PyXdmAtomicValue): The key to be removed given as an PyXdmAtomicValue
Returns:
PyXdmMap: a map without the specified entry. The original map is unchanged.
- values(...)
- values(self)
Get the values found in this map, that is, the value parts of the key-value pairs.
Returns:
list: List of the values found in this map.
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- isEmpty
- isEmpty(self)
Returns true if this map contains no key-value mappings.
Returns:
bool: true if this map contains no key-value mappings
- map_size
- map_size(self)
Get the number of entries in the map
Returns:
int: the number of entries in the map. (Note that the size() method returns 1 (one), because an XDM
map is an item.)
- string_value
- string_value(self)
Property to get the string value of the PyXdmMap
Returns:
str: String value of the map item
Data and other attributes defined here:
- __pyx_vtable__ = <capsule object NULL>
Methods inherited from PyXdmFunctionItem:
- call(...)
- call(self, list args)
Call the function
Args:
args (list): the values to be supplied as arguments to the function. The "function
conversion rules" will be applied to convert the arguments to the required
type when necessary.
Returns:
PyXdmValue: the result of calling the function
Static methods inherited from PyXdmFunctionItem:
- get_system_function(...)
- get_system_function(self, PySaxonProcessor proc, str name, arity, encoding=None)
Get a system function. This can be any function defined in XPath 3.1 functions and operators,
including functions in the math, map, and array namespaces. It can also be a Saxon extension
function, provided a licensed Processor is used.
Args:
proc (PySaxonProcessor): the Saxon processor
name (str): the name of the requested function as an EQName or clark name
arity (int): the arity of the requested function
encoding (str): the encoding of the name string. If not specified then the platform default encoding is used.
Returns:
PyXdmFunctionItem: the requested function
Data descriptors inherited from PyXdmFunctionItem:
- arity
- arity(self)
Get the arity of the function
Returns:
int: The arity of the function, that is, the number of arguments in the function's signature
- name
- name(self)
Get the name of the function
Returns:
str: The name of the function as an EQName
Methods inherited from PyXdmItem:
- get_array_value(...)
- get_array_value(self)
Get the subclass PyXdmArray for this current PyXdmItem object if it is an array item
Returns:
PyXdmArray: Subclass this object to PyXdmArray or error
- get_atomic_value(...)
- get_atomic_value(self)
Get the subclass PyXdmAtomicValue for this current PyXdmItem object if it is an atomic value
Returns:
PyXdmAtomicValue: Subclass this object to PyXdmAtomicValue or error
- get_function_value(...)
- get_function_value(self)
Get the subclass PyXdmFunctionItem for this current PyXdmItem object if it is a function item
Returns:
PyXdmFunctionItem: Subclass this object to PyXdmFunctionItem or error
- get_map_value(...)
- get_map_value(self)
Get the subclass PyXdmMap for this current PyXdmItem object if it is a map item
Returns:
PyXdmNode: Subclass this object to PyXdmMap or error
- get_node_value(...)
- get_node_value(self)
Get the subclass PyXdmNode for this current PyXdmItem object if it is a node
Returns:
PyXdmNode: Subclass this object to PyXdmNode or error
- get_string_value(...)
- get_string_value(self, encoding=None)
Property to get the string value of the item as defined in the XPath data model
Args:
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
str: The string value of this node
- item_at(...)
- item_at(self, index)
Get the n'th item in the sequence, counting from zero.
Args:
index (int): the index of the item required, counting from zero
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
Data descriptors inherited from PyXdmItem:
- head
- head(self)
Property to get the first item in the sequence represented by this PyXdmItem. Since a PyXdmItem is a sequence
of length one, this returns the PyXdmItem itself.
Returns:
PyXdmItem: The PyXdmItem or None if the sequence is empty
- is_array
- is_array(self)
Property to check if the current PyXdmItem is an array item
Returns:
bool: True if the current item is an array item
- is_atomic
- is_atomic(self)
Property to check if the current PyXdmItem is an atomic value
Returns:
bool: True if the current item is an atomic value
- is_function
- is_function(self)
Property to check if the current PyXdmItem is a function item
Returns:
bool: True if the current item is a function item
- is_map
- is_map(self)
Property to check if the current PyXdmItem is a map item
Returns:
bool: True if the current item is a map item
- is_node
- is_node(self)
Property to check if the current PyXdmItem is a node
Returns:
bool: True if the current item is a node
Methods inherited from PyXdmValue:
- __getitem__(...)
- __getitem__(self, index)
Implement the built-in subscript operator (i.e. square brackets []) to return the ith item in the sequence
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- add_xdm_item(...)
- add_xdm_item(self, PyXdmItem value)
Add an item to the XDM sequence
Args:
value (PyXdmItem): The PyXdmItem object to add to the sequence
Data descriptors inherited from PyXdmValue:
- size
- size(self)
Get the number of items in the sequence
Returns:
int: The count of items in the sequence
|
class PyXdmNode(PyXdmItem) |
|
This class represents a node in the XDM data model. A PyXdmNode is a PyXdmItem, and is therefore a
PyXdmValue in its own right, and may also participate as one item within a sequence value.
The PyXdmNode interface exposes basic properties of the node, such as its name, its string value, and
its typed value. |
|
- Method resolution order:
- PyXdmNode
- PyXdmItem
- PyXdmValue
- builtins.object
Methods defined here:
- __getitem__(...)
- __getitem__(self, index)
Implement the built-in subscript operator (i.e. square brackets []) to return the ith child node of the current node
Returns:
PyXdmNode: The child node at the specified index.
If the child node at the index does not exist returns None.
- __len__(...)
- __len__(self)
Implement the built-in function len() to return the count of child nodes from this current node.
Returns:
int: The count of child nodes
- __reduce__ = __reduce_cython__(...)
- __repr__(...)
- ___repr__(self)
- __setstate__ = __setstate_cython__(...)
- __str__(...)
- __str__(self)
The string value of the node as returned by the toString method
Returns:
str: String value of this node
- axis_nodes(...)
- axis_nodes(self, int axis)
Get the array of nodes reachable from this node via a given axis.
Deprecated the argument type for axis will change from Saxon 13 to use the XdmNodeKind enum type
Axis options are as follows: ANCESTOR = 0,
ANCESTOR_OR_SELF = 1, ATTRIBUTE = 2, CHILD = 3,
DESCENDANT = 4, DESCENDANT_OR_SELF = 5, FOLLOWING = 6,
FOLLOWING_SIBLING = 7, NAMESPACE = 8, PARENT = 9, PRECEDING = 10,
PRECEDING_SIBLING = 11, SELF = 12
Args:
axis (int): Identifies which axis is to be navigated.
Returns:
list[PyXdmNode]: List of PyXdmNode objects
- get_attribute_value(...)
- get_attribute_value(self, name, encoding=None)
Get the value of a named attribute
Args:
name (str): the EQName of the required attribute
encoding (str): The encoding of the name argument. Argument can be omitted or None.
If not specified then the platform default encoding is used.
- get_parent(...)
- get_parent(self)
Get the current node's parent. If it does not exist return None.
Returns:
PyXdmNode: The parent node as a PyXdmNode object, or otherwise None
- get_string_value(...)
- get_string_value(self, encoding=None)
Property to get the string value of the node as defined in the XPath data model
Args:
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
str: The string value of this node
- to_string(...)
- to_string(self, encoding=None)
The string value of the node as returned by the toString method
Args:
encoding (str): The encoding of the string. If not specified then the platform default encoding is used.
Returns:
str: String value of this node
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- attribute_count
- attribute_count(self)
Get the number of attribute nodes on this node. If the node is not an element node then returns 0.
Returns:
int: The number of attribute nodes
- attributes
- attribute_nodes(self)
Get the attribute nodes of this node as a list of PyXdmNode objects
Returns:
list[PyXdmNode]: List of PyXdmNode objects
- base_uri
- base_uri(self)
Base URI property. Get the Base URI for the node, that is, the URI used for resolving a relative URI
contained in the node. This will be the same as the System ID unless xml:base has been used. Where the
node does not have a base URI of its own, the base URI of its parent node is returned.
Returns:
str: String value of the base uri for this node. This may be NULL if the base URI is unknown,
including the case where the node has no parent.
- children
- children(self)
Get the children of this node as a list of PyXdmNode objects
Returns:
list[PyXdmNode]: List of PyXdmNode objects
- column_number
- column_number(self)
Get the column number of the node in a source document.
Returns:
int: The column number of the node, or -1 if not available.
- head
- head(self)
Property to get the first item in the sequence represented by this PyXdmNode. Since a PyXdmItem is a sequence
of length one, this returns the PyXdmNode itself.
Returns:
PyXdmNode: The PyXdmNode or None if the sequence is empty
- line_number
- line_number(self)
Get the line number of the node in a source document.
Returns:
int: The line number of the node, or -1 if not available.
- local_name
- local_name(self)
Get the local name of the node, as a string
Returns:
str: the local name of the node. In the case of unnamed nodes (e.g. text and comment nodes) returns None
- name
- name(self)
Get the name of the node, as a string in the form of an EQName
Returns:
str: the name of the node. In the case of unnamed nodes (e.g. text and comment nodes) returns None
- node_kind
- node_kind(self)
Node kind property.
There are seven kinds of node: documents=9, elements = 1, attributes =2, text=3, comments = 8,
processing-instructions = 7, and namespaces=13.
Returns:
int: an integer identifying the kind of node. These integer values are the same as those used in the DOM
- node_kind_str
- node_kind_str(self)
Node kind property string. Returns one of the following: 'document', 'element', 'attribute', 'text', 'comment',
'processing-instruction', 'namespace', 'unknown'.
Returns:
str: a string identifying the kind of node.
- string_value
- string_value(self)
Property to get the string value of the node as defined in the XPath data model
Returns:
str: The string value of this node
- typed_value
- typed_value(self)
Get the typed value of this node, as defined in the XPath data model
Returns:
PyXdmValue: the typed value. If the typed value is a single atomic value, this will be returned
as an instance of PyXdmAtomicValue
Data and other attributes defined here:
- __pyx_vtable__ = <capsule object NULL>
Methods inherited from PyXdmItem:
- get_array_value(...)
- get_array_value(self)
Get the subclass PyXdmArray for this current PyXdmItem object if it is an array item
Returns:
PyXdmArray: Subclass this object to PyXdmArray or error
- get_atomic_value(...)
- get_atomic_value(self)
Get the subclass PyXdmAtomicValue for this current PyXdmItem object if it is an atomic value
Returns:
PyXdmAtomicValue: Subclass this object to PyXdmAtomicValue or error
- get_function_value(...)
- get_function_value(self)
Get the subclass PyXdmFunctionItem for this current PyXdmItem object if it is a function item
Returns:
PyXdmFunctionItem: Subclass this object to PyXdmFunctionItem or error
- get_map_value(...)
- get_map_value(self)
Get the subclass PyXdmMap for this current PyXdmItem object if it is a map item
Returns:
PyXdmNode: Subclass this object to PyXdmMap or error
- get_node_value(...)
- get_node_value(self)
Get the subclass PyXdmNode for this current PyXdmItem object if it is a node
Returns:
PyXdmNode: Subclass this object to PyXdmNode or error
- item_at(...)
- item_at(self, index)
Get the n'th item in the sequence, counting from zero.
Args:
index (int): the index of the item required, counting from zero
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
Data descriptors inherited from PyXdmItem:
- is_array
- is_array(self)
Property to check if the current PyXdmItem is an array item
Returns:
bool: True if the current item is an array item
- is_atomic
- is_atomic(self)
Property to check if the current PyXdmItem is an atomic value
Returns:
bool: True if the current item is an atomic value
- is_function
- is_function(self)
Property to check if the current PyXdmItem is a function item
Returns:
bool: True if the current item is a function item
- is_map
- is_map(self)
Property to check if the current PyXdmItem is a map item
Returns:
bool: True if the current item is a map item
- is_node
- is_node(self)
Property to check if the current PyXdmItem is a node
Returns:
bool: True if the current item is a node
Methods inherited from PyXdmValue:
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __iter__(...)
- __iter__(self)
Returns the Iterator object of PyXdmValue
- add_xdm_item(...)
- add_xdm_item(self, PyXdmItem value)
Add an item to the XDM sequence
Args:
value (PyXdmItem): The PyXdmItem object to add to the sequence
Data descriptors inherited from PyXdmValue:
- size
- size(self)
Get the number of items in the sequence
Returns:
int: The count of items in the sequence
|
class PyXdmValue(builtins.object) |
|
A PyXdmValue represents a value in the XDM data model. A value is a sequence of zero or more items, each
item being an atomic value, a node, or a function item. |
|
Methods defined here:
- __getitem__(...)
- __getitem__(self, index)
Implement the built-in subscript operator (i.e. square brackets []) to return the ith item in the sequence
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __iter__(...)
- __iter__(self)
Returns the Iterator object of PyXdmValue
- __reduce__ = __reduce_cython__(...)
- __repr__(...)
- __repr__(self)
The string representation of PyXdmItem
- __setstate__ = __setstate_cython__(...)
- __str__(...)
- __str__(self)
The string representation of PyXdmItem
- add_xdm_item(...)
- add_xdm_item(self, PyXdmItem value)
Add an item to the XDM sequence
Args:
value (PyXdmItem): The PyXdmItem object to add to the sequence
- item_at(...)
- item_at(self, index)
Get the n'th item in the sequence, counting from zero.
Args:
index (int): the index of the item required, counting from zero
Returns:
PyXdmItem: The item at the specified index. This could be a PyXdmItem or any of its subclasses:
PyXdmAtomicValue, PyXdmNode, PyXdmFunctionItem, PyXdmMap or PyXdmArray.
If the item does not exist returns None.
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- head
- head(self)
Property to get the first item in the sequence
Returns:
PyXdmItem: The first item or None if the sequence is empty
- size
- size(self)
Get the number of items in the sequence
Returns:
int: The count of items in the sequence
Data and other attributes defined here:
- __pyx_vtable__ = <capsule object NULL>
|
class PyXslt30Processor(builtins.object) |
|
A PyXslt30Processor represents a factory to compile, load and execute stylesheets.
It is possible to cache the context and the stylesheet in the PyXslt30Processor. |
|
Methods defined here:
- __init__(...)
- Creates a new PyXslt30Processor, keeping a reference to its PySaxonProcessor
:param processor:
- __reduce__ = __reduce_cython__(...)
- __setstate__ = __setstate_cython__(...)
- clear_parameters(...)
- clear_parameter(self)
Clear all parameters set on the processor for execution of the stylesheet
- compile_stylesheet(...)
- compile_stylesheet(self, **kwds)
Compile a stylesheet received as text, uri, as a node object, or as referenced in a specified XML document
via the xml-stylesheet processing instruction. The term "compile" here indicates that the stylesheet is
converted into an executable form. The compilation uses a snapshot of the properties of the PyXslt30Processor
at the time this method is invoked. It is also possible to save the compiled stylesheet (SEF file) given the
options 'save' and 'output_file'.
Args:
**kwds: Possible keyword arguments: one of stylesheet_text (str), stylesheet_file (str),
associated_file (str) or stylesheet_node (PyXdmNode); save (bool) and output_file (str) can be used
to save the exported stylesheet (SEF) to file; lang (str) can be used to set the XSLT (and XPath)
language level to be supported by the processor (possible values: '3.0' and '4.0');
fast_compile (bool) which requests fast compilation.
The following additional keywords can be used with 'save': target (str) which sets the target edition
under which the compiled stylesheet will be executed; and relocate (bool) which says whether the
compiled stylesheet can be deployed to a different location, with a different base URI.
The keyword 'encoding' (str) can be used with stylesheet_text to specify the encoding used to decode
the string (if not specified then the platform default encoding is used).
Returns:
PyXsltExecutable: which represents the compiled stylesheet. The PyXsltExecutable is immutable
and thread-safe; it may be used to run multiple transformations, in series or concurrently.
Raises:
PySaxonApiError: Error raised if the stylesheet contains static errors or if it cannot be read.
Example:
xsltproc = saxon_proc.new_xslt30_processor()
1) executable = xsltproc.compile_stylesheet(stylesheet_text="<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='2.0'>
<xsl:param name='values' select='(2,3,4)' /><xsl:output method='xml' indent='yes' />
<xsl:template match='*'><output><xsl:value-of select='//person[1]'/>
<xsl:for-each select='$values' >
<out><xsl:value-of select='. * 3'/></out>
</xsl:for-each></output></xsl:template></xsl:stylesheet>")
2) executable = xsltproc.compile_stylesheet(stylesheet_file="test1.xsl", save=True, output_file="test1.sef", target="HE")
3) executable = xsltproc.compile_stylesheet(associated_file="foo.xml")
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- get_parameter(...)
- get_parameter(self, name, encoding=None)
Get a parameter value by a given name
Args:
name (str): The name of the stylesheet parameter
encoding (str): The encoding of the name string. If not specified then the platform default encoding is used.
Returns:
PyXdmValue: The XDM value of the parameter
- import_package(...)
- import_package(self, package_file_name)
Import a library package. Calling this method makes the supplied package available for reference
in the xsl:use-package declarations of subsequent compilations performed using this Xslt30Processor.
Args:
package_file_name (str): the file name of the package to be imported, which should be supplied
as an SEF. If relative, the file name of the SEF is resolved against the cwd, which is set
using the set_cwd method.
Example:
xsltproc = saxon_proc.new_xslt30_processor()
xsltproc.import_package('test-package-001.pack')
executable = xsltproc.compile_stylesheet(stylesheet_file="foo.xsl")
- remove_parameter(...)
- remove_parameter(self, name, encoding=None)
Remove the parameter given by name from the PyXslt30Processor. The parameter will not have any effect on the
stylesheet if it has not yet been executed.
Args:
name (str): The name of the stylesheet parameter
encoding (str): The encoding of the name string. If not specified then the platform default encoding is used.
Returns:
bool: True if the removal of the parameter has been successful, False otherwise.
- set_cwd(...)
- set_cwd(self, cwd)
Set the current working directory.
Args:
cwd (str): current working directory
- set_jit_compilation(...)
- set_jit_compilation(self, bool jit)
Say whether just-in-time compilation of template rules should be used.
Args:
jit (bool): True if just-in-time compilation is to be enabled. With this option enabled,
static analysis of a template rule is deferred until the first time that the
template is matched. This can improve performance when many template
rules are rarely used during the course of a particular transformation; however,
it means that static errors in the stylesheet will not necessarily cause the
compile(Source) method to throw an exception (errors in code that is
actually executed will still be notified but this may happen after the compile(Source)
method returns). This option is enabled by default in SaxonC-EE, and is not available
in SaxonC-HE or SaxonC-PE.
Recommendation: disable this option unless you are confident that the
stylesheet you are compiling is error-free.
- set_parameter(...)
- set_parameter(self, name, PyXdmValue value, encoding = None)
Set the value of a stylesheet parameter
Args:
name (str): the name of the stylesheet parameter, as a string. For a namespaced parameter use
clark notation {uri}local
value (PyXdmValue): the value of the stylesheet parameter, or NULL to clear a previously set value
encoding (str): The encoding of the name string. If not specified then the platform default encoding is used.
- transform_to_file(...)
- transform_to_file(self, **kwds)
Execute a transformation with the result saved to file. For a more elaborate API for transformation use the
compile_stylesheet method to compile the stylesheet to a PyXsltExecutable, and use the methods of that class.
Args:
**kwds: Required keyword arguments: source_file (str), stylesheet_file (str) and output_file (str).
Possible argument: base_output_uri (str) which is used for resolving relative URIs in the href
attribute of the xsl:result-document instruction.
Example:
xsltproc.transform_to_file(source_file="cat.xml", stylesheet_file="test1.xsl", output_file="result.xml")
Raises:
PySaxonApiError: Error raised if failure in XSLT transformation
- transform_to_string(...)
- transform_to_string(self, **kwds)
Execute a transformation and return the result as a string. For a more elaborate API for transformation use the
compile_stylesheet method to compile the stylesheet to a PyXsltExecutable, and use the methods of that class.
Args:
**kwds: Required keyword arguments: source_file (str) and stylesheet_file (str).
Possible arguments: base_output_uri (str) which is used for resolving relative URIs in the href
attribute of the xsl:result-document instruction. Also accept the keyword 'encoding' (str) to
specify the encoding of the output string. This must match the encoding specified by xsl:output in
the stylesheet. If not specified then the platform default encoding is used.
Example:
result = xsltproc.transform_to_string(source_file="cat.xml", stylesheet_file="test1.xsl")
Raises:
PySaxonApiError: Error raised if failure in XSLT transformation
- transform_to_value(...)
- transform_to_value(self, **kwds)
Execute a transformation and return the result as a PyXdmValue object. For a more elaborate API for
transformation use the compile_stylesheet method to compile the stylesheet to a PyXsltExecutable, and use
the methods of that class.
Args:
**kwds: Required keyword arguments: source_file (str) and stylesheet_file (str).
Possible argument: base_output_uri (str) which is used for resolving relative URIs in the href
attribute of the xsl:result-document instruction.
Returns:
PyXdmValue: Result of the transformation as a PyXdmValue object
Example:
result = xsltproc.transform_to_value(source_file="cat.xml", stylesheet_file="test1.xsl")
Raises:
PySaxonApiError: Error raised if failure in XSLT transformation
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- error_code
- error_code(self)
A transformation may have a number of errors reported against it. This property returns the error code if
there are any errors.
Returns:
str: The error code associated with the exception. Returns None if the exception does not exist.
- error_message
- error_message(self)
A transformation may have a number of errors reported against it. This property returns an error message
if there are any errors.
Returns:
str: The message of the exception. Returns None if the exception does not exist.
- exception_occurred
- exception_occurred(self)
Property to check for pending exceptions without creating a local reference to the exception object
Returns:
boolean: True when there is an exception thrown; otherwise False
|
class PyXsltExecutable(builtins.object) |
|
A PyXsltExecutable represents the compiled form of a stylesheet.
A PyXsltExecutable is created by using one of the compile methods on the PyXslt30Processor class. |
|
Methods defined here:
- __init__(...)
- Creates a new instance, keeping a reference to its PySaxonProcessor
:param processor:
- __reduce__ = __reduce_cython__(...)
- __setstate__ = __setstate_cython__(...)
- apply_templates_returning_file(...)
- apply_templates_returning_file(self, **kwds)
Invoke the stylesheet by applying templates to a supplied input sequence, saving the results to file.
It is possible to specify the output file as an argument or using the set_output_file method.
It is possible to specify the initial match selection either as an argument or using the
set_initial_match_selection method. This method does not set the global context item for the transformation;
if that is required, it can be done separately using the set_global_context_item method.
Args:
**kwds: Possible keyword arguments: source_file (str) or xdm_value (PyXdmValue) can be used to supply
the initial match selection; output_file (str), and base_output_uri (str) which is used for
resolving relative URIs in the href attribute of the xsl:result-document instruction.
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
executable.set_initial_match_selection(file_name="cat.xml")
executable.apply_templates_returning_file(output_file="result.xml")
- apply_templates_returning_string(...)
- apply_templates_returning_string(self, **kwds)
Invoke the stylesheet by applying templates to a supplied input sequence, saving the results as a string.
It is possible to specify the initial match selection either as an argument or using the
set_initial_match_selection method. This method does not set the global context item for the transformation;
if that is required, it can be done separately using the set_global_context_item method.
Args:
**kwds: Possible keyword arguments: source_file (str) or xdm_value (PyXdmValue) can be used to supply
the initial match selection; and base_output_uri (str) which is used for resolving relative URIs
in the href attribute of the xsl:result-document instruction. Also accept the keyword 'encoding'
(str) to specify the encoding of the output string. This must match the encoding specified by
xsl:output in the stylesheet, or as specified using set_property() on this PyXsltExecutable. If
not specified then the platform default encoding is used.
Returns:
str: Result of the transformation as a str value
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
xslt30_proc = saxon_proc.new_xslt30_processor()
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) executable.set_initial_match_selection(file_name="cat.xml")
content = executable.apply_templates_returning_string()
print(content)
2) node = saxon_proc.parse_xml(xml_text="<in/>")
content = executable.apply_templates_returning_string(xdm_value=node)
print(content)
- apply_templates_returning_value(...)
- apply_templates_returning_value(self, **kwds)
Invoke the stylesheet by applying templates to a supplied input sequence, saving the results as a PyXdmValue.
It is possible to specify the initial match selection either as an argument or using the
set_initial_match_selection method. This method does not set the global context item for the transformation;
if that is required, it can be done separately using the set_global_context_item method.
Args:
**kwds: Possible keyword arguments: source_file (str) or xdm_value (PyXdmValue) can be used to supply
the initial match selection; and base_output_uri (str) which is used for resolving relative URIs
in the href attribute of the xsl:result-document instruction.
Returns:
PyXdmValue: Result of the transformation as a PyXdmValue object
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
xslt30_proc = saxon_proc.new_xslt30_processor()
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) executable.set_initial_match_selection(file_name="cat.xml")
result = executable.apply_templates_returning_value()
2) result = executable.apply_templates_returning_value(source_file="cat.xml")
- call_function_returning_file(...)
- call_function_returning_file(self, str function_name, list args, **kwds)
Invoke a transformation by calling a named function with the result saved to file. It is possible to specify
the output file as an argument or using the set_output_file method.
Args:
function_name(str): The name of the function to invoke, in clark notation {uri}local
args (list[PyXdmValue]): Pointer array of PyXdmValue objects - the values of the arguments to be supplied
to the function.
**kwds: Possible keyword arguments: output_file (str) and base_output_uri (str)
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test2.xsl")
1) executable.set_output_file("result.xml")
executable.call_function_returning_file("{http://localhost/example}func", [])
2) executable.set_global_context_item(file_name="cat.xml")
executable.call_function_returning_file("{http://localhost/test}add", [saxonproc.make_integer_value(2)], output_file="result.xml")
- call_function_returning_string(...)
- call_function_returning_string(self, str function_name, list args, **kwds)
Invoke a transformation by calling a named function and return the result as a serialized string.
Args:
function_name (str): The name of the function to invoke, in clark notation {uri}local
args (list[PyXdmValue]): Pointer array of PyXdmValue objects - the values of the arguments to be supplied
to the function.
**kwds: Possible keyword arguments: base_output_uri (str). Also accept the keyword 'encoding' (str) to
specify the encoding of the output string. This must match the encoding specified by xsl:output in
the stylesheet, or as specified using set_property() on this PyXsltExecutable. If not specified
then the platform default encoding is used.
Returns:
str: Result of the transformation as a str value
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) result = executable.call_function_returning_string("{http://localhost/example}func", [])
2) executable.set_global_context_item(file_name="cat.xml")
result = executable.call_function_returning_string("{http://localhost/test}add", [saxonproc.make_integer_value(2)])
- call_function_returning_value(...)
- call_function_returning_value(self, str function_name, list args, **kwds)
Invoke a transformation by calling a named function and return the result as a PyXdmValue.
Args:
function_name (str): The name of the function to invoke, in clark notation {uri}local
args (list[PyXdmValue]): Pointer array of PyXdmValue objects - the values of the arguments to be supplied
to the function.
**kwds: Possible keyword arguments: base_output_uri (str)
Returns:
PyXdmValue: Result of the transformation as a PyXdmValue object
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) result = executable.call_function_returning_value("{http://localhost/example}func", [])
2) executable.set_global_context_item(file_name="cat.xml")
result = executable.call_function_returning_value("{http://localhost/test}add", [saxonproc.make_integer_value(2)])
- call_template_returning_file(...)
- call_template_returning_file(self, str template_name, **kwds)
Invoke a transformation by calling a named template with the result saved to file. It is possible to specify the
output file as an argument or using the set_output_file method.
Args:
template_name (str): The name of the template to invoke. If None is supplied then call the initial-template.
**kwds: Possible keyword arguments: output_file (str), and base_output_uri (str) which is used for
resolving relative URIs in the href attribute of the xsl:result-document instruction.
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) executable.call_template_returning_file("main", output_file="result.xml")
2) executable.set_global_context_item(file_name="cat.xml")
executable.call_template_returning_file("main", output_file="result.xml")
3) executable.set_global_context_item(file_name="cat.xml")
executable.set_output_file("result.xml")
executable.call_template_returning_file()
print(result)
- call_template_returning_string(...)
- call_template_returning_string(self, str template_name, **kwds)
Invoke a transformation by calling a named template and return the result as a string.
Args:
template_name (str): The name of the template to invoke. If None is supplied then call the initial-template.
**kwds: Possible keyword arguments: base_output_uri (str) which is used for resolving relative URIs in
the href attribute of the xsl:result-document instruction. Also accept the keyword 'encoding' (str)
to specify the encoding of the output string. This must match the encoding specified by xsl:output
in the stylesheet, or as specified using set_property() on this PyXsltExecutable. If not specified
then the platform default encoding is used.
Returns:
PyXdmValue: Result of the transformation as a PyXdmValue object
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) result = executable.call_template_returning_string("main")
2) executable.set_global_context_item(file_name="cat.xml")
result = executable.call_template_returning_string("main")
3) executable.set_global_context_item(file_name="cat.xml")
result = executable.call_template_returning_string()
print(result)
- call_template_returning_value(...)
- call_template_returning_value(self, str template_name, **kwds)
Invoke a transformation by calling a named template and return the result as a PyXdmValue.
Args:
template_name (str): The name of the template to invoke. If None is supplied then call the initial-template.
**kwds: Possible keyword arguments: base_output_uri (str) which is used for resolving relative URIs in
the href attribute of the xsl:result-document instruction.
Returns:
PyXdmValue: Result of the transformation as a PyXdmValue object
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
xslt30_proc = saxon_proc.new_xslt30_processor()
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) result = executable.call_template_returning_value("main")
2) executable.set_global_context_item(file_name="cat.xml")
result = executable.call_template_returning_value("main")
- clear_parameters(...)
- clear_parameter(self)
Clear all parameters set on the processor for execution of the stylesheet
- clear_properties(...)
- clear_properties(self)
Clear all properties set on the processor
- clear_xsl_messages(...)
- clear_xsl_messages(self)
Clear the messages written using the xsl:message instruction to the in-memory list.
If xsl:messages are enabled to write to file then this method has no affect
- clone(...)
- clone(self)
Create a clone object of this PyXsltExecutable object
Returns:
PyXsltExecutable: copy of this object
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- export_stylesheet(...)
- export_stylesheet(self, str file_name)
Produce a representation of the compiled stylesheet, in XML form, suitable for
distribution and reloading.
Args:
file_name (str): The name of the file where the compiled stylesheet is to be saved
- get_initial_template_parameters(...)
- Returns the currently set dictionary of either tunneling or non-tunneling initial template parameters.
Any changes you make to the dictionary WILL NOT be reflected in the processor. This is a read-only view of
the parameters.
Args:
tunnel (bool): True if these values are to be used for setting tunnel parameters;
False if they are to be used for non-tunnel parameters. The default is false.
Returns:
(dict) the parameters dictionary
- get_parameter(...)
- get_parameter(self, name)
Get a parameter value by a given name
Args:
name (str): The name of the stylesheet parameter
Returns:
PyXdmValue: The XDM value of the parameter
- get_result_documents(...)
- get_result_documents(self)
Return the secondary result documents resulting from the execution of the stylesheet. Null is
returned if the user has not enabled this feature via the method set_capture_result_documents.
Returns:
dict [str, PyXdmValue]: Dict of the key-value pairs. Indexed by the absolute URI of each result
document, and the corresponding value is a PyXdmValue object containing the result document (as
an in-memory tree, without serialization).
- get_xsl_messages(...)
- get_xsl_messages(self)
Get the messages written using the xsl:message instruction. Return NULL if the user has not
enabled capturing of xsl:messages via the method set_save_xsl_message.
:return: value (PyXdmValue):
- remove_parameter(...)
- remove_parameter(self, name)
Remove the parameter given by name from the PyXslt30Processor. The parameter will not have any effect on the
stylesheet if it has not yet been executed.
Args:
name (str): The name of the stylesheet parameter
Returns:
bool: True if the removal of the parameter has been successful, False otherwise.
- set_base_output_uri(...)
- set_base_output_uri(self, base_uri)
Set the base output URI. The default is the base URI of the principal output
of the transformation. If a base output URI is supplied using this function then
it takes precedence over any base URI defined in the principal output, and
it may cause the base URI of the principal output to be modified in situ.
The base output URI is used for resolving relative URIs in the 'href' attribute
of the xsl:result-document instruction; it is accessible to XSLT stylesheet
code using the XPath current-output-uri() function.
Args:
base_uri (str): the base output URI
- set_capture_result_documents(...)
- set_capture_result_documents(self, bool value, bool raw_result)
Enable the capture of the result document output into a dict. This overrides the default mechanism.
If this option is enabled, then any document created using xsl:result-document is saved (as a PyXdmNode)
in a dict object where it is accessible using the URI as a key. After the execution of the transformation
a call on the get_result_documents method is required to get access to the result documents in the map.
It is also possible to capture the result document as a raw result directly as a PyXdmValue, without
constructing an XML tree, and without serialization. It corresponds to the serialization.
Args:
value (bool): true causes secondary result documents from the transformation to be saved in a map;
false disables this option.
raw_result (bool): true enables the handling of raw destination for result documents. If not supplied
this can also be set on the set_result_as_raw_value method. The set_result_as_raw_value method
has higher priority to this flag.
- set_cwd(...)
- set_cwd(self, cwd)
Set the current working directory.
Args:
cwd (str): current working directory
- set_global_context_item(...)
- set_global_context_item(self, **kwds)
Set the global context item for the transformation.
Args:
**kwds: Possible keyword arguments: must be one of the following (file_name|xdm_item)
Raises:
Exception: Exception is raised if keyword argument is not one of file_name or xdm_item
(providing a PyXdmItem).
- set_initial_match_selection(...)
- set_initial_match_selection(self, **kwds)
The initial value to which templates are to be applied (equivalent to the select attribute of
xsl:apply-templates).
Args:
**kwds: Possible keyword arguments: must be one of the following (file_name|xdm_value)
Raises:
Exception: Exception is raised if keyword argument is not one of file_name or xdm_value
(providing a PyXdmValue).
- set_initial_mode(...)
- set_initial_mode(self, name)
Set the initial mode for the transformation
Args:
name (str): the EQName of the initial mode. Two special values are recognized, in the
reserved XSLT namespace:
xsl:unnamed to indicate the mode with no name, and xsl:default to indicate the
mode defined in the stylesheet header as the default mode.
The value null also indicates the default mode (which defaults to the unnamed
mode, but can be set differently in an XSLT 3.0 stylesheet).
- set_initial_template_parameters(...)
- set_initial_template_parameters(self, bool tunnel, dict parameters)
Set parameters to be passed to the initial template. These are used
whether the transformation is invoked by applying templates to an initial source item,
or by invoking a named template. The parameters in question are the xsl:param elements
appearing as children of the xsl:template element.
Args:
tunnel (bool): True if these values are to be used for setting tunnel parameters;
False if they are to be used for non-tunnel parameters. The default is false.
parameters (dict): the parameters to be used for the initial template supplied as key-value pairs.
Example:
1) paramArr = {'a':saxonproc.make_integer_value(12), 'b':saxonproc.make_integer_value(5)}
xsltproc.set_initial_template_parameters(False, paramArr)
2) set_initial_template_parameters(False, {a:saxonproc.make_integer_value(12)})
- set_output_file(...)
- set_output_file(self, output_file)
Set the output file where the output of the transformation will be sent
Args:
output_file (str): The output file supplied as a string
- set_parameter(...)
- set_parameter(self, name, value)
Set the value of a stylesheet parameter
Args:
name (str): the name of the stylesheet parameter, as a string. For a namespaced parameter use
clark notation {uri}local
value (PyXdmValue): the value of the stylesheet parameter
- set_property(...)
- set_property(self, name, value)
Set a property specific to the processor in use.
Args:
name (str): The name of the property
value (str): The value of the property
Example:
PyXsltExecutable: set serialization properties (names start with '!' e.g. name "!method" -> "xml")
'o': output file name,
'it': initial template,
'im': initial mode,
's': source as file name
'm': switch on message listener for xsl:message instructions,
'item'| 'node': source supplied as a PyXdmNode object,
'extc': Set the native library to use with Saxon for extension functions written in C/C++/PHP
- set_result_as_raw_value(...)
- set_result_as_raw_value(self, bool is_raw)
Set true if the return type of callTemplate, applyTemplates and transform methods is to return PyXdmValue,
otherwise return PyXdmNode object with root Document node
Args:
is_raw (bool): True if returning raw result, i.e. PyXdmValue, otherwise return PyXdmNode
- set_save_xsl_message(...)
- set_save_xsl_message(self, show, str file_name)
Gives users the option to switch the xsl:message feature on or off. It is also possible
to send the xsl:message outputs to file given by file name.
Args:
show (bool): Boolean to indicate if xsl:message should be outputted. Default (True) is on.
file_name (str): The name of the file to send output
- transform_to_file(...)
- transform_to_file(self, **kwds)
Execute a transformation with the result saved to file. It is possible to specify the output file as an
argument or using the set_output_file method.
Args:
**kwds: Possible keyword arguments: source_file (str) or xdm_node (PyXdmNode); output_file (str),
and base_output_uri (str) which is used for resolving relative URIs in the href attribute of the
xsl:result-document instruction.
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) executable.transform_to_file(source_file="cat.xml", output_file="result.xml")
2) executable.set_initial_match_selection("cat.xml")
executable.set_output_file("result.xml")
executable.transform_to_file()
3) node = saxon_proc.parse_xml(xml_text="<in/>")
executable.transform_to_file(output_file="result.xml", xdm_node= node)
- transform_to_string(...)
- transform_to_string(self, **kwds)
Execute a transformation and return the result as a string.
Args:
**kwds: Possible keyword arguments: one of source_file (str) or xdm_node (PyXdmNode);
base_output_uri (str) which is used for resolving relative URIs
in the href attribute of the xsl:result-document instruction.
Also accept the keyword 'encoding' (str) to specify the encoding of the output string. This must
match the encoding specified by xsl:output in the stylesheet, or as specified using set_property()
on this PyXsltExecutable. If not specified then the platform default encoding is used.
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) result = executable.transform_to_string(source_file="cat.xml")
2) executable.set_initial_match_selection(file_name="cat.xml")
result = executable.transform_to_string()
3) node = saxon_proc.parse_xml(xml_text="<in/>")
result = executable.transform_to_string(xdm_node= node)
- transform_to_value(...)
- transform_to_value(self, **kwds)
Execute a transformation and return the result as a PyXdmValue object.
Args:
**kwds: Possible keyword arguments: source_file (str) or xdm_node (PyXdmNode);
and base_output_uri (str) which is used for resolving relative URIs in the href attribute
of the xsl:result-document instruction.
Returns:
PyXdmValue: Result of the transformation as a PyXdmValue object
Raises:
PySaxonApiError: Error raised in the event of a dynamic error
Example:
xslt30_proc = saxon_proc.new_xslt30_processor()
executable = xslt30_proc.compile_stylesheet(stylesheet_file="test1.xsl")
1) result = executable.transform_to_value(source_file="cat.xml")
2) executable.set_initial_match_selection("cat.xml")
result = executable.transform_to_value()
3) node = saxon_proc.parse_xml(xml_text="<in/>")
result = executable.transform_to_value(xdm_node= node)
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data descriptors defined here:
- error_message
- error_message(self)
A transformation may have a number of errors reported against it. Get the error message if there are any errors
Returns:
str: The message of the exception. Returns None if the exception does not exist.
- exception_occurred
- exception_occurred(self)
Property to check for pending exceptions without creating a local reference to the exception object
Returns:
boolean: True when there is a pending exception; otherwise False
|
class XdmNodeKind(enum.IntEnum) |
|
XdmNodeKind(value, names=None, *, module=None, qualname=None, type=None, start=1)
An enumeration. |
|
- Method resolution order:
- XdmNodeKind
- enum.IntEnum
- builtins.int
- enum.Enum
- builtins.object
Data and other attributes defined here:
- ANCESTOR = <XdmNodeKind.ANCESTOR: 0>
- ANCESTOR_OR_SELF = <XdmNodeKind.ANCESTOR_OR_SELF: 1>
- ATTRIBUTE = <XdmNodeKind.ATTRIBUTE: 2>
- CHILD = <XdmNodeKind.CHILD: 3>
- DESCENDANT = <XdmNodeKind.DESCENDANT: 4>
- DESCENDANT_OR_SELF = <XdmNodeKind.DESCENDANT_OR_SELF: 5>
- FOLLOWING = <XdmNodeKind.FOLLOWING: 6>
- FOLLOWING_SIBLING = <XdmNodeKind.FOLLOWING_SIBLING: 7>
- NAMESPACE = <XdmNodeKind.NAMESPACE: 8>
- PARENT = <XdmNodeKind.PARENT: 9>
- PRECEDING = <XdmNodeKind.PRECEDING: 10>
- PRECEDING_SIBLING = <XdmNodeKind.PRECEDING_SIBLING: 11>
- SELF = <XdmNodeKind.SELF: 12>
Data descriptors inherited from enum.Enum:
- name
- The name of the Enum member.
- value
- The value of the Enum member.
Readonly properties inherited from enum.EnumMeta:
- __members__
- Returns a mapping of member name->value.
This mapping lists all enum members, including aliases. Note that this
is a read-only view of the internal mapping.
|
class XdmType(enum.IntEnum) |
|
XdmType(value, names=None, *, module=None, qualname=None, type=None, start=1)
An enumeration. |
|
- Method resolution order:
- XdmType
- enum.IntEnum
- builtins.int
- enum.Enum
- builtins.object
Data and other attributes defined here:
- XDM_ARRAY = <XdmType.XDM_ARRAY: 3>
- XDM_ATOMIC_VALUE = <XdmType.XDM_ATOMIC_VALUE: 1>
- XDM_EMPTY = <XdmType.XDM_EMPTY: 6>
- XDM_FUNCTION_ITEM = <XdmType.XDM_FUNCTION_ITEM: 5>
- XDM_ITEM = <XdmType.XDM_ITEM: 7>
- XDM_MAP = <XdmType.XDM_MAP: 4>
- XDM_NODE = <XdmType.XDM_NODE: 2>
- XDM_VALUE = <XdmType.XDM_VALUE: 0>
Data descriptors inherited from enum.Enum:
- name
- The name of the Enum member.
- value
- The value of the Enum member.
Readonly properties inherited from enum.EnumMeta:
- __members__
- Returns a mapping of member name->value.
This mapping lists all enum members, including aliases. Note that this
is a read-only view of the internal mapping.
| |