beta.xslt.xpath

The xpath module provides a Python API for the XPath 3.1 specification. This Python interface enables the user to compile an xpath expression and to execute it with different input data. The typical starting point would be the functions beta.xpath.Expression.compile() and beta.xpath.Expression.execute().

There are also utility functions beta.xpath.compile() and beta.xpath.execute() for simplified usage.

>>> seq = execute('fold-left(1 to 7, 2, function($primes, $val){$primes, (2*$val+1)[every $i in $primes satisfies . mod $i]})', session=Session())
>>> TypeConverter().to_python(seq)
(2, 3, 5, 7, 11, 13)

Classes

Functions

beta.xslt.xpath.compile(unicode expression_text, *, Session session, **kwargs)

Validate the provided expression_text and create a compiled expression from it. Internally uses the xpath.Expression.create_from_options classmethod but has different return values. Returns an beta.xpath.Expression object on success or raises an exception if there are syntax or static errors detected. The keyword arguments corresponding to the properties of beta.xpath.CompileOptions are supported and are used to initialize the internally created options object.

beta.xslt.xpath.execute(unicode expression_text, *, Session session, initial_context=None, **kwargs)

Compile and execute the xpath expression. Returns an beta.xpath.Sequence, or raises an exception if an error is encountered. The keyword arguments corresponding to the properties of beta.xpath.CompileOptions and beta.xpath.RuntimeOptions are supported and are used in the initialization of the respective objects.

>>> res = execute('year-from-date(current-date()) ge 2018')
>>> res.to_python()
True

Enum Classes

class beta.xslt.xpath.BreakPosition

An enumeration.

class beta.xslt.xpath.BreakReason

An enumeration.

class beta.xslt.xpath.DebugAction

An enumeration.

class beta.xslt.xpath.DeliveryFormat

The beta.xpath.DeliveryFormat enumeration controls the delivery of the xslt and xquery final results, including the optional serialization and saving steps.

DeliveryFormat.AUTO

Will decide between DOCUMENT or RAW based on the build-tree attribute

DeliveryFormat.DOCUMENT

The returned sequence will contain the xslt result wrapped with an implicitly created document node.

DeliveryFormat.RAW

The raw result will be delivered in the result sequence.

DeliveryFormat.SAVED

The result is serialized and written to the output-uri. The result sequence will contain a string, representing the output-uri.

DeliveryFormat.SERIALIZED

A string, representing the results of serialization (without the final encoding stage), will be returned in the result sequence.

class beta.xslt.xpath.ExecutionMode

An enumeration.

class beta.xslt.xpath.ImportStrategy

An enumeration.

class beta.xslt.xpath.NormalizationForm

The beta.xpath.NormalizationForm enumeration represents the Unicode Normalization Form used during serialization. The unicode normalization is a process of removing alternative representations of equivalent sequences from textual data.

NormalizationForm.FULLY_NORMALIZED

Fully normalized, as specified in Character Model for the World Wide Web 1.0: Normalization.

NormalizationForm.NFC

Normalization Form C.

NormalizationForm.NFD

Normalization Form D.

NormalizationForm.NFKC

Normalization Form KC.

NormalizationForm.NFKD

Normalization Form KD.

NormalizationForm.NONE

No Unicode Normalization will be applied.

class beta.xslt.xpath.ProcessContents

An enumeration.

class beta.xslt.xpath.SchemaLocationStrategy

An enumeration.

class beta.xslt.xpath.SerializationMethod

The beta.xpath.SerializationMethod enumeration represents the serialization output methods, as described in XSLT and XQuery Serialization 3.1.

SerializationMethod.ADAPTIVE

Adaptive Output Method

SerializationMethod.HTML

HTML Output Method

SerializationMethod.JSON

JSON Output Method

SerializationMethod.TEXT

Text Output Method

SerializationMethod.XHTML

XHTML Output Method

SerializationMethod.XML

XML Output Method

class beta.xslt.xpath.Standalone

The beta.xpath.Standalone enumeration is used during xml serialization to control the standalone attribute generation in the xml declaration.

Standalone.NO

The xml declaration will contain standalone=”no”.

Standalone.OMIT

The xml declaration will contain no standalone attribute.

Standalone.YES

The xml declaration will contain standalone=”yes”.

class beta.xslt.xpath.Version

An enumeration.

class beta.xslt.xpath.XsdVersion

An enumeration.