| |
- builtins.object
-
- PySaxonProcessor
- PySchemaValidator
- PyXPathProcessor
- PyXQueryProcessor
- PyXdmValue
-
- PyXdmItem
-
- PyXdmAtomicValue
- PyXdmNode
- PyXslt30Processor
- PyXsltProcessor
class PySaxonProcessor(builtins.object) |
|
An SaxonProcessor 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:
with saxonc.PySaxonProcessor(license=False) as proc:
print("Test Saxon/C 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
- __exit__(...)
- The exit method for the context PySaxonProcessor. Here we release the Jet VM resources.
If we have more than one live PySaxonProcessor object the release() method has no effect.
- __reduce__ = __reduce_cython__(...)
- __setstate__ = __setstate_cython__(...)
- clear_configuration_properties(...)
- clear_configuration_properties(self)
Clear the configurations properties in use by the processor
- exception_clear(...)
- exceltion_clear(self)
Clear any exception thrown internally in Saxon/C.
- exception_occurred(...)
- exception_occurred(self)
Check if an exception has occurred internally within Saxon/C
Returns:
boolean: True or False if an exception has been reported internally in Saxon/C
- get_string_value(...)
- get_string_value(self, PyXdmItem item)
Create an QName Xdm value from string representation in clark notation
Args:
str_ (str): The value given in a string form in clark notation. {uri}local
Returns:
PyAtomicValue: The corresonding value
- make_atomic_value(...)
- make_atomic_value(self, value_type, value)
Create an QName Xdm value from string representation in clark notation
Args:
str_ (str): The value given in a string form in clark notation. {uri}local
Returns:
PyAtomicValue: The corresonding value
- make_boolean_value(...)
- make_boolean_value(self, value)
Factory method: makes a XdmAtomicValue representing a boolean Value
Args:
value (boolean): True or False, to determine which boolean value is required
Returns:
PyAtomicValue: The corresonding XdmValue
- 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_qname_value(...)
- make_qname_value(self, str_)
Create an QName Xdm value from string representation in clark notation
Args:
str_ (str): The value given in a string form in clark notation. {uri}local
Returns:
PyAtomicValue: The corresonding value
- make_string_value(...)
- make_string_value(self, str_)
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:
str_ (str): the String value. Null is taken as equivalent to "".
Returns:
PyXdmAtomicValue: The corresponding Xdm StringValue
- new_schema_validator(...)
- new_schema_validator(self)
Create a PySchemaValidator which can be used to validate instance documents against the schema held by this
Returns:
PySchemaValidator: a newly created PySchemaValidator
- new_xpath_processor(...)
- new_xpath_processor(self)
Create an 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 an 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 an PyXslt30Processor. A PyXslt30Processor is used to compile and execute XSLT 3.0 stylesheets.
Returns:
PyXslt30Processor: a newly created PyXslt30Processor
- new_xslt_processor(...)
- new_xslt_processor(self)
Create an PyXsltProcessor. A PyXsltProcessor is used to compile and execute XSLT stylesheets.
Returns:
PyXsltProcessor: a newly created PyXsltProcessor
- parse_xml(...)
- parse_xml(self, **kwds)
Parse a lexical representation, source file or uri of the source document and return it as an Xdm Node
Args:
**kwds : The possible keyword arguments must be one of the follow (xml_file_name|xml_text|xml_uri)
Returns:
PyXdmNode: The Xdm Node representation of the XML document
Raises:
Exception: Error if the keyword argument is not one of xml_file_name|xml_text|xml_uri.
- release(...)
- release(self)
Clean up and destroy Java VM to release memory used.
- set_configuration_property(...)
- set_configuration_property(self, name, value)
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
Example:
'l': 'on' or 'off' - to enable the line number
- set_cwd(...)
- set_resources_directory(...)
- Property to set or get resources directory
: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:
- cwd
- cwd Property represents the current working directorty
:str: Get or set the current working directory
- is_schema_aware
- Check is the processor is Schema aware. A licensed Saxon-EE/C product is schema aware
:bool: Indicate if the processor is schema aware, True or False otherwise
- resources_directory
- version
- Get the Saxon Version.
Getter:
str: The Saxon version
|
class PySchemaValidator(builtins.object) |
|
An SchemaValidator represents factory for validating instance documents against a schema. |
|
Methods defined here:
- __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
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- exception_count(...)
- excepton_count(self)
Get number of errors reported during execution of the schema.
Returns:
int: Count of the exceptions thrown during execution
- exception_occurred(...)
- exception_occurred(self)
Check if an exception has occurred internally within Saxon/C
Returns:
boolean: True or False if an exception has been reported internally in Saxon/C
- get_error_code(...)
- get_error_code(self, index)
A transformation may have a number of errors reported against it. Get the i'th error code if there are any errors.
Args:
index (int): The i'th exception
Returns:
str: The error code associated with the i'th exception. Return None if the i'th exception does not exist.
- get_error_message(...)
- get_error_message(self, index)
A transformation may have a number of errors reported against it. Get the ith error message if there are any errors
Args:
index (int): The i'th exception
Returns:
str: The message of the i'th exception. Return None if the i'th exception does not exist.
- register_schema(...)
- Register schema given as file name or schema text. (xsd_text|xsd_file)
Args:
**kwds: Keyword argument options only one of 'xsd_text' or 'xsd_file'
- remove_parameter(...)
- remove_parameter(self, name)
Remove the parameter given by name from the PySchemaValidator. The parameter will not have any affect on the SchemaValidator 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 (boolean): lax 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 valida tor.
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 the parameter for the Schema validator
Args:
name (str): the name of the schema parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name
value (PyXdmValue): the value of the parameter, or None 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:
PySchemaValidator: set serialization properties (names start with '!' i.e. name "!method" -> "xml")
'o':outfile 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 an PyXdmNode object
'report-file': Specifcy 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-lelvel element of the doucment to be validated.
The string should be in the Clark notation {uri}local
'lax': Boolean to set the validation mode to strict (False) or lax ('True')
- set_source_node(...)
- set_source_node(self, source)
Set the source as an PyXdmNode object that will be validated
Args:
source (PyXdmNode) :
- validate(...)
- validate(self, **kwds)
Validate an instance document by a registered schema.
Args:
**kwds: The possible keyword arguments must be one of the follow (file_name|xml_text|xdm_node).
The source file to be validated. Allow None when source document is supplied using the set_source method
- validate_to_node(...)
- validate_to_node(self, **kwds)
Validate an instance document by a registered schema.
Args:
**kwds: The possible keyword arguments must be one of the follow (file_name|xml_text|xdm_node).
The source file to be validated. Allow None when source document is supplied using the set_source method
Returns:
PyXdmNode: The validated document returned to the calling program as an PyXdmNode
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:
- validation_report
- validation_report
The validation report Property
:PyXdmNode: The Validation report result from the Schema validator
|
class PyXPathProcessor(builtins.object) |
|
An XPathProcessor represents factory to compile, load and execute the XPath query. |
|
Methods defined here:
- __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 return None
- 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 compiler
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.
- 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): Supplied as a string
Returns:
boolean: The result is a boolean value.
- evaluate(...)
- evaluate(self, xpath_str)
Args:
xpath_str (str): The XPath query suplied as a string
Returns:
PyXdmValue:
- evaluate_single(...)
- evaluate_single(self, xpath_str)
Args:
xpath_str (str): The XPath query suplied as a string
Returns:
PyXdmItem: A single Xdm Item is returned or None is returned if the expression returns an empty sequence
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- exception_count(...)
- excepton_count(self)
Get number of errors reported during execution.
Returns:
int: Count of the exceptions thrown during execution
- exception_occurred(...)
- exception_occurred(self)
Check if an exception has occurred internally within Saxon/C
Returns:
boolean: True or False if an exception has been reported internally in Saxon/C
- get_error_code(...)
- get_error_code(self, index)
A transformation may have a number of errors reported against it. Get the i'th error code if there are any errors
Args:
index (int): The i'th exception
Returns:
str: The error code associated with the i'th exception. Return None if the i'th exception does not exist.
- get_error_message(...)
- get_error_message(self, index)
A transformation may have a number of errors reported against it. Get the ith error message if there are any errors
Args:
index (int): The i'th exception
Returns:
str: The message of the i'th exception. Return None if the i'th exception does not exist.
- remove_parameter(...)
- remove_parameter(self, name)
Remove the parameter given by name from the PyXPathProcessor. The parameter will not have any affect 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_base_uri(...)
- set_base_uri(self, uri)
Set the static base URI for XPath expressions compiled using this PyXPathCompiler. 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:
uri (str): This string will be used as the static base URI
- set_context(...)
- set_context(self, **kwds)
Set the context for the XPath query
Args:
**kwds : Possible keyword argument 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_parameter(...)
- set_parameter(self, name, PyXdmValue value)
Set the value of a XPath parameter
Args:
name (str): the name of the XPath parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name
value (PyXdmValue): the value of the query parameter, or None 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
Static methods defined here:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
|
class PyXQueryProcessor(builtins.object) |
|
An PyXQueryProcessor object represents factory to compile, load and execute queries. |
|
Methods defined here:
- __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 return None
- 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 part of the static context for queries compiled using this.
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 (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.
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- exception_count(...)
- excepton_count(self)
Get number of errors reported during execution.
Returns:
int: Count of the exceptions thrown during execution
- exception_occurred(...)
- exception_occurred(self)
Checks for pending exceptions without creating a local reference to the exception object
Returns:
boolean: True when there is a pending exception; otherwise return False
- get_error_code(...)
- get_error_code(self, index)
A transformation may have a number of errors reported against it. Get the i'th error code if there are any errors
Args:
index (int): The i'th exception
Returns:
str: The error code associated with the i'th exception. Return None if the i'th exception does not exist.
- get_error_message(...)
- get_error_message(self, index)
A transformation may have a number of errors reported against it. Get the ith error message if there are any errors
Args:
index (int): The i'th exception
Returns:
str: The message of the i'th exception. Return None if the i'th exception does not exist.
- remove_parameter(...)
- remove_parameter(self, name)
Remove the parameter given by name from the PyXQueryProcessor. The parameter will not have any affect 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 query with the result saved to file
Args:
**kwds: Keyword arguments with the possible options input_file_name (str) or input_xdm_item (PyXdmItem). The Query can be
supplied with the arguments 'query_file' or 'query_text', which are of type str. The name of the output file is
specified as the argument output_file_name.
- run_query_to_string(...)
- run_query_to_string(self, **kwds)
Execute query and output result as a string
Args:
**kwds: Keyword arguments with the possible options input_file_name (str) or input_xdm_item (PyXdmItem). Possible to supply
query with the arguments 'query_file' or 'query_text', which are of type str.
Returns:
str: Output result as a string
- run_query_to_value(...)
- run_query_to_value(self, **kwds)
Execute query and output result as an PyXdmValue object
Args:
**kwds: Keyword arguments with the possible options input_file_name (str) or input_xdm_item (PyXdmItem). Possible to supply
query with the arguments 'query_file' or 'query_text', which are of type str.
Returns:
PyXdmValue: Output result as an PyXdmValue
- set_context(...)
- set_context(self, **kwds)
Set the initial context for the query
Args:
**kwds : Possible keyword argument 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 namespaced parameter use the JAXP solution i.e. "{uri}name
value (PyXdmValue): the value of the query parameter, or None 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:
PyXQueryProcessor: set serialization properties (names start with '!' i.e. name "!method" -> "xml")
'o':outfile 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 query 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)
Set the query to be executed as a string
Args:
content (str): The query content suplied as a string
- set_query_file(...)
- set_query_file(self, file_name)
Set the query to be executed as a file
Args:
file_name (str): The file name for the query
- 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 Saxon-EE/C.
Args:
updating (bool): true if the query is allowed to use the XQuery Update facility (requires Saxon-EE/C). 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.
|
class PyXdmAtomicValue(PyXdmItem) |
|
The class PyXdmAtomicValue represents an item in an Xath 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:
- __reduce__ = __reduce_cython__(...)
- __repr__(...)
- ___repr__
- __setstate__ = __setstate_cython__(...)
- __str__(...)
- __str__(self)
The string value of the node as defined in the XPath data model
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:
- boolean_value
- Property which returns the boolean value of the PyXdmAtomicValue
Returns:
bool: boolean value.
- double_value
- Property which is returns the double value of the PyXdmAtomicValue if it can be converted.
Returns:
double: Double value of the Xdm object
- integer_value
- Property which is returns the int value of the PyXdmAtomicValue if it can be converted.
Returns:
int: Int value of the Xdm object
- primitive_type_name
- get_primitive_type_name()
Property - Get the primitive type name of the PyXdmAtomicValue
Returns:
str: String of the primitive type name
- string_value
- Property which returns the string value of the PyXdmAtomicValue
Returns:
str: String value of the Xdm object
Methods inherited from PyXdmItem:
- get_atomic_value(...)
- get_atomic_value(self)
Get the subclass PyXdmAtomicValue for this PyXdmItem object current object is an atomic value
Returns:
PyXdmAtomicValue: Subclass this object to PyXdmAtomicValue or error
- get_node_value(...)
- get_node_value(self)
Get the subclass PyXdmNode for this PyXdmItem object current object is an atomic value
Returns:
PyXdmNode: Subclass this object to PyXdmNode or error
Data descriptors inherited from PyXdmItem:
- is_atomic
- is_atomic(self)
Property to check if the current PyXdmItem is an atomic value
Returns:
bool: Check of is atomic value
Methods inherited from PyXdmValue:
- add_xdm_item(...)
- add_xdm_tem(self, PyXdmItem value)
Add PyXdmItem to the Xdm sequence
Args:
value (PyXdmItem): The PyXdmItem object
- item_at(...)
- item_at(self, index)
Get the n'th item in the value, counting from zero.
Args:
index (int): the index of the item required. Counting from zero
Returns:
PyXdmItem: Get the item indicated at the index. If the item does not exist return None.
Data descriptors inherited from PyXdmValue:
- head
- head(self)
Property to get the first item in the sequence
Returns:
PyXdmItem: The PyXdmItem or None if the sequence is empty
- size
- size(self)
Property - Get the number of items in the sequence
Returns:
int: The count of items in the sequence
|
class PyXdmNode(PyXdmItem) |
|
Value in the XDM data model. A value is a sequence of zero or more items, each item being either an atomic value or a node. |
|
- Method resolution order:
- PyXdmNode
- PyXdmItem
- PyXdmValue
- builtins.object
Methods defined here:
- __reduce__ = __reduce_cython__(...)
- __repr__(...)
- ___repr__
- __setstate__ = __setstate_cython__(...)
- __str__(...)
- __str__(self)
The string value of the node as defined in the XPath data model
Returns:
str: String value of this node
- get_attribute_value(...)
- getAttribute_value(self, name)
The name of the required attribute
Args:
name(str): the eqname of the required attribute
- get_parent(...)
- get_parent(self)
Get the current node's parent
Returns:
PyXdmNode: The parent node as PyXdmNode object
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)
Property to get the count of attribute nodes on this XdmNode object. If this current node is not an element node then return 0
Returns:
int: Count of attribute nodes
- attributes
- attribute_nodes(self)
Property to get the attribute nodes 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)
Property to get children of this current node. List of child nodes
Returns:
list[PyXdmNode]: List of PyXdmNode objects
- name
- name(self)
Get the name of the node, as a string in the form of a EQName
Returns:
str: the name of the node. In the case of unnamed nodes (for example, text and comment nodes) return None
- node_kind
- node_kind(self)
Node Kind property. This will be a value such as {@link net.sf.saxon.type.Type#ELEMENT} or {@link net.sf.saxon.type.Type#ATTRIBUTE}.
There are seven kinds of node: documents, elements, attributes, text, comments, processing-instructions, and namespaces.
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(self)
Node Kind property string. This will be a value such as {@link net.sf.saxon.type.Type#ELEMENT} or {@link net.sf.saxon.type.Type#ATTRIBUTE}.
There are seven kinds of node: documents, elements, attributes, text, comments, processing-instructions, and namespaces.
Returns:
int: an integer identifying the kind of node. These integer values are the same as those used in the DOM
- string_value
- get_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)
Property - get the typed value of this node, as defined in XDM
Returns:
PyXdmValue:the typed value. If the typed value is a single atomic value, this will be returne as an instance of {@link XdmAtomicValue}
Methods inherited from PyXdmItem:
- get_atomic_value(...)
- get_atomic_value(self)
Get the subclass PyXdmAtomicValue for this PyXdmItem object current object is an atomic value
Returns:
PyXdmAtomicValue: Subclass this object to PyXdmAtomicValue or error
- get_node_value(...)
- get_node_value(self)
Get the subclass PyXdmNode for this PyXdmItem object current object is an atomic value
Returns:
PyXdmNode: Subclass this object to PyXdmNode or error
Data descriptors inherited from PyXdmItem:
- is_atomic
- is_atomic(self)
Property to check if the current PyXdmItem is an atomic value
Returns:
bool: Check of is atomic value
Methods inherited from PyXdmValue:
- add_xdm_item(...)
- add_xdm_tem(self, PyXdmItem value)
Add PyXdmItem to the Xdm sequence
Args:
value (PyXdmItem): The PyXdmItem object
- item_at(...)
- item_at(self, index)
Get the n'th item in the value, counting from zero.
Args:
index (int): the index of the item required. Counting from zero
Returns:
PyXdmItem: Get the item indicated at the index. If the item does not exist return None.
Data descriptors inherited from PyXdmValue:
- head
- head(self)
Property to get the first item in the sequence
Returns:
PyXdmItem: The PyXdmItem or None if the sequence is empty
- size
- size(self)
Property - Get the number of items in the sequence
Returns:
int: The count of items in the sequence
|
class PyXdmValue(builtins.object) |
|
Value in the XDM data model. A value is a sequence of zero or more items, each item being either an atomic value or a node. |
|
Methods defined here:
- __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_tem(self, PyXdmItem value)
Add PyXdmItem to the Xdm sequence
Args:
value (PyXdmItem): The PyXdmItem object
- item_at(...)
- item_at(self, index)
Get the n'th item in the value, counting from zero.
Args:
index (int): the index of the item required. Counting from zero
Returns:
PyXdmItem: Get the item indicated at the index. If the item does not exist return 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 PyXdmItem or None if the sequence is empty
- size
- size(self)
Property - Get the number of items in the sequence
Returns:
int: The count of items in the sequence
|
class PyXslt30Processor(builtins.object) |
|
An PyXslt30Processor represents factory to compile, load and execute a stylesheet.
It is possible to cache the context and the stylesheet in the PyXslt30Processor |
|
Methods defined here:
- __reduce__ = __reduce_cython__(...)
- __setstate__ = __setstate_cython__(...)
- add_package(...)
- add_package(self, file_name)
Add an XSLT 3.0 package to the library.
Args:
file_name (str): The file name of the XSLT package
- 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.
Args:
**kwds: Possible optional arguments: source_file (str) or xdm_value (PyXdmValue).
Other allowed argument: stylesheet_file (str) and the required argument output_file (str)
Returns:
PyXdmValue: Result of the transformation as an PyXdmValue object
Example:
1) xsltproc.set_initial_match_selection(file_name="cat.xml")
content = xsltproc.apply_templates_returning_file(stylesheet_file="test1.xsl", output_file="result.xml")
print(content)
- 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 str.
Args:
**kwds: Possible optional arguments: source_file (str) or xdm_value (PyXdmValue). Other allowed argument: stylesheet_file (str)
Returns:
PyXdmValue: Result of the transformation as an PyXdmValue object
Example:
1) xsltproc.set_initial_match_selection(file_name="cat.xml")
content = xsltproc.apply_templates_returning_str(stylesheet_file="test1.xsl")
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 an XdmValue.
Args:
**kwds: Possible optional arguments: source_file (str) or xdm_value (PyXdmValue). Other allowed argument: stylesheet_file (str)
Returns:
PyXdmValue: Result of the transformation as an PyXdmValue object
Example:
1) xsltproc.set_initial_match_selection(file_name="cat.xml")
node = xsltproc.apply_templates_returning_value(stylesheet_file="test1.xsl")
2) xsltproc.compile_stylesheet(stylesheet_file="test1.xsl")
xsltproc.set_initial_match_selection(file_name="cat.xml")
node = xsltproc.apply_templates_returning_value()
- call_function_returning_file(...)
- call_function_returning_file(self, str function_name, list args, **kwds)
Invoke a transformation by calling a named template and return result as an PyXdmValue.
Args:
function_name(str): The name of the template to invoke. If None is supplied
then call the initial-template
list args: Pointer array of XdmValue object - he values of the arguments to be supplied to the function.
**kwds: Possible optional arguments: source_file (str) or xdm_value (PyXdmValue). Other allowed argument: stylesheet_file (str)
Returns:
PyXdmValue: Result of the transformation as an PyXdmValue object
Example:
1) xsltproc.set_output_file("result.xml")
xsltproc.call_function_returning_file("{http://localhost/example}func", stylesheet_file="test1.xsl")
2) xsltproc.set_initial_match_selection(file_name="cat.xml")
xsltproc.call_function_returning_file("{http://localhost/test}add", stylesheet_file="test1.xsl", output_file="result.xml")
3) xsltproc.compile_stylesheet(stylesheet_file="test2.xsl")
xsltproc.set_initial_match_selection(file_name="cat.xml")
xsltproc.call_function_returning_file("{http://exmaple.com}func1", 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 template and return result as a serialized string.
Args:
function_name(str): The name of the template to invoke. If None is supplied then call the initial-template
list args: Pointer array of XdmValue object - he values of the arguments to be supplied to the function.
**kwds: Possible optional arguments: source_file (str) or xdm_value (PyXdmValue). Other allowed argument: stylesheet_file (str)
Returns:
str: Result of the transformation as an str value
Example:
1) result = xsltproc.call_function_returning_string("{http://localhost/example}func", stylesheet_file="test1.xsl")
2) xsltproc.set_initial_match_selection(file_name="cat.xml")
result = xsltproc.call_function_returning_string("{http://localhost/test}add", stylesheet_file="test1.xsl")
3) xsltproc.compile_stylesheet(stylesheet_file="test2.xsl")
xsltproc.set_initial_match_selection(file_name="cat.xml")
result = xsltproc.call_function_returning_string("{http://exmaple.com}func1")
- call_function_returning_value(...)
- call_function_returning_value(self, str function_name, list args, **kwds)
Invoke a transformation by calling a named template and return result as an PyXdmValue.
Args:
function_name(str): The name of the template to invoke. If None is supplied then call the initial-template
list args: Pointer array of XdmValue object - he values of the arguments to be supplied to the function.
**kwds: Possible optional arguments: source_file (str) or xdm_value (PyXdmValue). Other allowed argument: stylesheet_file (str)
Returns:
PyXdmValue: Result of the transformation as an PyXdmValue object
Example:
1) node = xsltproc.call_function_returning_value("{http://localhost/example}func", stylesheet_file="test1.xsl")
2) xsltproc.set_initial_match_selection(file_name="cat.xml")
value = xsltproc.call_function_returning_value("{http://localhost/test}add", stylesheet_file="test1.xsl")
3) xsltproc.compile_stylesheet(stylesheet_file="test2.xsl")
xsltproc.set_initial_match_selection(file_name="cat.xml")
value = xsltproc.call_function_returning_value("{http://exmaple.com}func1")
- call_template_returning_file(...)
- call_template_returning_file(self, str template_name, **kwds)
Invoke a transformation by calling a named template and save result in a specified file.
Args:
template_name(str): The name of the template to invoke. If None is supplied then call the initial-template
**kwds: Possible optional arguments: source_file (str) or xdm_node (PyXdmNode). Other allowed argument: stylesheet_file (str)
Returns:
PyXdmValue: Result of the transformation as an PyXdmValue object
Example:
1) xsltproc.call_template_returning_file("main", stylesheet_file="test1.xsl", output_file="result.xml")
2) xsltproc.set_initial_match_selection(file_name="cat.xml")
xsltproc.call_template_returning_file("main", stylesheet_file="test1.xsl", output_file="result.xml")
3) xsltproc.compile_stylesheet(stylesheet_file="test2.xsl")
xsltproc.set_initial_match_selection(file_name="cat.xml")
xsltproc.call_template_returning_file("go", output_file="result.xml")
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 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 optional arguments: source_file (str) or xdm_Value (PyXdmValue). Other allowed argument: stylesheet_file (str)
Returns:
PyXdmValue: Result of the transformation as an PyXdmValue object
Example:
1) result = xsltproc.call_template_returning_string("main", stylesheet_file="test1.xsl")
2) xsltproc.set_initial_match_selection(file_name="cat.xml")
result = xsltproc.call_template_returning_string("main", stylesheet_file="test1.xsl")
cdef const char * c_templateName = NULL
3) xsltproc.compile_stylesheet(stylesheet_file="test2.xsl")
xsltproc.set_initial_match_selection(file_name="cat.xml")
result = xsltproc.call_template_returning_string("go")
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 result as an PyXdmValue.
Args:
template_name(str): The name of the template to invoke. If None is supplied then call the initial-template
**kwds: Possible optional arguments: source_file (str) or xdm_value (PyXdmValue). Other allowed argument: stylesheet_file (str)
Returns:
PyXdmValue: Result of the transformation as an PyXdmValue object
Example:
1) node = xsltproc.call_template_returning_value("main", stylesheet_file="test1.xsl")
2) xsltproc.set_initial_match_selection(file_name="cat.xml")
node = xsltproc.call_template_returning_value("main", stylesheet_file="test1.xsl")
3) xsltproc.compile_stylesheet(stylesheet_file="test2.xsl")
xsltproc.set_initial_match_selection(file_name="cat.xml")
node = xsltproc.call_template_returning_value("go")
- check_exception(...)
- check_exception(self)
Check for exception thrown and get message of the exception.
Returns:
str: Returns the exception message if thrown otherwise return None
- clearPackages(...)
- clear_packages(self)
Clear saved XSLT 3.0 package in the library.
- 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
- compile_stylesheet(...)
- compile_stylesheet(self, **kwds)
Compile a stylesheet received as text, uri or as a node object. The compiled stylesheet
is cached and available for execution later. It is also possible to save the compiled
stylesheet (SEF file) given the option 'save' and 'output_file'.
Get the stylesheet associated via the xml-stylesheet processing instruction (see
http://www.w3.org/TR/xml-stylesheet/) with the document
document specified in the source parameter, and that match
the given criteria. If there are several suitable xml-stylesheet
processing instructions, then the returned Source will identify
a synthesized stylesheet module that imports all the referenced
stylesheet module.
Args:
**kwds: Possible keyword arguments stylesheet_text (str), stylesheet_file (str),
associated_file (str) or stylsheet_node (PyXdmNode). Also possible to add the options
save (boolean) and output_file, which creates an exported stylesheet to file (SEF).
Example:
1. 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. xsltproc.compile_stylesheet(stylesheet_file="test1.xsl", save=True, output_file="test1.sef")
3. xsltproc.compile(associated_file="foo.xml")
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- exception_count(...)
- excepton_count(self)
Get number of errors reported during execution.
Returns:
int: Count of the exceptions thrown during execution
- exception_occurred(...)
- exception_occurred(self)
Checks for pending exceptions without creating a local reference to the exception object
Returns:
boolean: True when there is a pending exception; otherwise return False
- get_error_code(...)
- get_error_code(self, index)
A transformation may have a number of errors reported against it. Get the i'th error code if there are any errors
Args:
index (int): The i'th exception
Returns:
str: The error code associated with the i'th exception. Return None if the i'th exception does not exist.
- get_error_message(...)
- get_error_message(self, index)
A transformation may have a number of errors reported against it. Get the ith error message if there are any errors
Args:
index (int): The i'th exception
Returns:
str: The message of the i'th exception. Return None if the i'th exception does not exist.
- 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_xsl_messages(...)
- Get the messages written using the <code>xsl:message</code> instruction
get_xsl_message(self)
Returns:
PyXdmValue: Messages returned as an XdmValue.
- release_stylesheet(...)
- release_stylesheet(self)
Release cached stylesheet
- remove_parameter(...)
- remove_parameter(self, name)
Remove the parameter given by name from the PyXslt30Processor. The parameter will not have any affect 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_cwd(...)
- set_cwd(self, cwd)
Set the current working directory.
Args:
cwd (str): current working directory
- set_global_context_item(...)
- Set the global context item for the transformation.
Args:
**kwds: Keyword argument can only be one of the following: file_name|xdm_item
Raises:
Exception: Exception is raised if keyword argument is not one of file_name or an Xdm item.
- set_initial_match_selection(...)
- set_initial_match_selection(self, **kwds)
The initial filename to which templates are to be applied (equivalent to the <code>select</code> attribute of <code>xsl:apply-templates</code>).
Args:
**kwds: Keyword argument can only be one of the following: file_name|xdm_value
Raises:
Exception: Exception is raised if keyword argument is not one of file_name or XdmValue.
- set_initial_template_parameters(...)
- set_initial_template_parameters(self, bool tunnel, **kwds)
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.
TODO: To fix issue where we pass XdmValue object created directly in the function argument. This causes seg error
e.g. set_initial_template_parameter(False, {a:saxonproc.make_integer_value(12)})
Do the following instead:
paramArr = {a:saxonproc.make_integer_value(12)}
set_initial_template_parameter(False, paramArr)
Args:
tunnel (bool): True if these values are to be used for setting tunnel parameters;
**kwds: the parameters to be used for the initial template supplied as an key-value pair.
False if they are to be used for non-tunnel parameters. The default is false.
Example:
1)paramArr = {'a':saxonproc.make_integer_value(12), 'b':saxonproc.make_integer_value(5)}
xsltproc.set_initial_template_parameters(False, paramArr)
- set_jit_compilation(...)
- set_jit_compilation(self, 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 Saxon-EE, and is not available
in Saxon-HE or Saxon-PE.
Recommendation: disable this option unless you are confident that the
stylesheet you are compiling is error-free.
- 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 str
- set_parameter(...)
- set_parameter(self, PyXdmValue value)
Set the value of a stylesheet parameter
Args:
name (str): the name of the stylesheet parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name
value (PyXdmValue): the value of the stylesheet 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:
XsltProcessor: set serialization properties (names start with '!' i.e. name "!method" -> "xml")
'o':outfile 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 an XdmNode 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, is_raw)
Set true if the return type of callTemplate, applyTemplates and transform methods is to return XdmValue, otherwise return XdmNode object with root Document node
Args:
is_raw (bool): True if returning raw result, i.e. XdmValue, otherwise return XdmNode
- transform_to_file(...)
- transform_to_file(self, **kwds)
Execute transformation to a file. It is possible to specify the as an argument or using the set_output_file method.
Args:
**kwds: Possible optional arguments: source_file (str) or xdm_node (PyXdmNode). Other allowed argument: stylesheet_file (str), output_file (str)
Example:
1) xsltproc.transform_to_file(source_file="cat.xml", stylesheet_file="test1.xsl", output_file="result.xml")
2) xsltproc.set_source("cat.xml")
xsltproc.setoutput_file("result.xml")
xsltproc.transform_to_file(stylesheet_file="test1.xsl")
3) node = saxon_proc.parse_xml(xml_text="<in/>")
xsltproc.transform_to_file(output_file="result.xml", stylesheet_file="test1.xsl", xdm_node= node)
- transform_to_string(...)
- transform_to_string(self, **kwds)
Execute transformation to string.
Args:
**kwds: Possible arguments: source_file (str) or xdm_node (PyXdmNode). Other allowed argument: stylesheet_file (str)
Example:
1) result = xsltproc.transform_to_string(source_file="cat.xml", stylesheet_file="test1.xsl")
2) xsltproc.set_source("cat.xml")
result = xsltproc.transform_to_string(stylesheet_file="test1.xsl")
3) node = saxon_proc.parse_xml(xml_text="<in/>")
result = xsltproc.transform_to_string(stylesheet_file="test1.xsl", xdm_node= node)
- transform_to_value(...)
- transform_to_value(self, **kwds)
Execute transformation to an Xdm Node
Args:
**kwds: Possible optional arguments: source_file (str) or xdm_node (PyXdmNode). Other allowed argument: stylesheet_file (str)
Returns:
PyXdmNode: Result of the transformation as an PyXdmNode object
Example:
1) node = xsltproc.transform_to_value(source_file="cat.xml", stylesheet_file="test1.xsl")
2) xsltproc.set_source("cat.xml")
node = xsltproc.transform_to_value(stylesheet_file="test1.xsl")
3) node = saxon_proc.parse_xml(xml_text="<in/>")
node = xsltproc.transform_tovalue(stylesheet_file="test1.xsl", 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.
|
class PyXsltProcessor(builtins.object) |
|
An PyXsltProcessor represents factory to compile, load and execute a stylesheet.
It is possible to cache the context and the stylesheet in the PyXsltProcessor |
|
Methods defined here:
- __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 return None
- 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
- compile_stylesheet(...)
- compile_stylesheet(self, **kwds)
Compile a stylesheet received as text, uri or as a node object. The compiled stylesheet is cached and available for execution
later. It is also possible to save the compiled stylesheet (SEF file) given the option 'save' and 'output_file'
Args:
**kwds: Possible keyword arguments stylesheet_text (str), stylesheet_file (str) or stylsheetnode (PyXdmNode). Also possible
to add the options save (boolean) and output_file, which creates an exported stylesheet to file (SEF).
Example:
1. 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. xsltproc.compile_stylesheet(stylesheet_file="test1.xsl", save=True, output_file="test1.sef")
- exception_clear(...)
- exception_clear(self)
Clear any exception thrown
- exception_count(...)
- excepton_count(self)
Get number of errors reported during execution.
Returns:
int: Count of the exceptions thrown during execution
- exception_occurred(...)
- exception_occurred(self)
Checks for pending exceptions without creating a local reference to the exception object
Returns:
boolean: True when there is a pending exception; otherwise return False
- get_error_code(...)
- get_error_code(self, index)
A transformation may have a number of errors reported against it. Get the i'th error code if there are any errors
Args:
index (int): The i'th exception
Returns:
str: The error code associated with the i'th exception. Return None if the i'th exception does not exist.
- get_error_message(...)
- get_error_message(self, index)
A transformation may have a number of errors reported against it. Get the ith error message if there are any errors
Args:
index (int): The i'th exception
Returns:
str: The message of the i'th exception. Return None if the i'th exception does not exist.
- 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_xsl_messages(...)
- Get the messages written using the <code>xsl:message</code> instruction
get_xsl_message(self)
Returns:
PyXdmValue: Messages returned as an XdmValue.
- release_stylesheet(...)
- release_stylesheet(self)
Release cached stylesheet
- remove_parameter(...)
- remove_parameter(self, name)
Remove the parameter given by name from the PyXsltProcessor. The parameter will not have any affect 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_cwd(...)
- set_cwd(self, cwd)
Set the current working directory.
Args:
cwd (str): current working directory
- set_jit_compilation(...)
- set_jit_compilation(self, 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 Saxon-EE, and is not available
in Saxon-HE or Saxon-PE.
Recommendation: disable this option unless you are confident that the
stylesheet you are compiling is error-free.
- 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 str
- set_parameter(...)
- set_parameter(self, PyXdmValue value)
Set the value of a stylesheet parameter
Args:
name (str): the name of the stylesheet parameter, as a string. For namespaced parameter use the JAXP solution i.e. "{uri}name
value (PyXdmValue): the value of the stylesheet 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:
XsltProcessor: set serialization properties (names start with '!' i.e. name "!method" -> "xml")
'o':outfile 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 an XdmNode object,
'extc':Set the native library to use with Saxon for extension functions written in C/C++/PHP
- set_source(...)
- Set the source document for the transformation.
Args:
**kwds: Keyword argument can only be one of the following: file_name|xdm_node
Raises:
Exception: Exception is raised if keyword argument is not one of file_name or node.
- transform_to_file(...)
- transform_to_file(self, **kwds)
Execute transformation to a file. It is possible to specify the as an argument or using the set_output_file method.
Args:
**kwds: Possible optional arguments: source_file (str) or xdm_node (PyXdmNode). Other allowed argument: stylesheet_file (str), output_file (str)
Example:
1) xsltproc.transform_to_file(source_file="cat.xml", stylesheet_file="test1.xsl", output_file="result.xml")
2) xsltproc.set_source("cat.xml")
xsltproc.setoutput_file("result.xml")
xsltproc.transform_to_file(stylesheet_file="test1.xsl")
3) node = saxon_proc.parse_xml(xml_text="<in/>")
xsltproc.transform_to_file(output_file="result.xml", stylesheet_file="test1.xsl", xdm_node= node)
- transform_to_string(...)
- transform_to_string(self, **kwds)
Execute transformation to string.
Args:
**kwds: Possible arguments: source_file (str) or xdm_node (PyXdmNode). Other allowed argument: stylesheet_file (str)
Example:
1) result = xsltproc.transform_to_string(source_file="cat.xml", stylesheet_file="test1.xsl")
2) xsltproc.set_source("cat.xml")
result = xsltproc.transform_to_string(stylesheet_file="test1.xsl")
3) node = saxon_proc.parse_xml(xml_text="<in/>")
result = xsltproc.transform_to_string(stylesheet_file="test1.xsl", xdm_node= node)
- transform_to_value(...)
- transform_to_value(self, **kwds)
Execute transformation to an Xdm Node
Args:
**kwds: Possible optional arguments: source_file (str) or xdm_node (PyXdmNode). Other allowed argument: stylesheet_file (str)
Returns:
PyXdmNode: Result of the transformation as an PyXdmNode object
Example:
1) node = xsltproc.transform_to_value(source_file="cat.xml", stylesheet_file="test1.xsl")
2) xsltproc.set_source("cat.xml")
node = xsltproc.transform_to_value(stylesheet_file="test1.xsl")
3) node = saxon_proc.parse_xml(xml_text="<in/>")
node = xsltproc.transform_tovalue(stylesheet_file="test1.xsl", 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.
| |