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¶
beta.xslt.xpath.ArrayItem
beta.xslt.xpath.AtomicItem
beta.xslt.xpath.Breakpoint
beta.xslt.xpath.BreakpointList
beta.xslt.xpath.CallStackItem
beta.xslt.xpath.CancelFlag
beta.xslt.xpath.CompileError
beta.xslt.xpath.CompileOptions
beta.xslt.xpath.Debugger
beta.xslt.xpath.DecimalFormat
beta.xslt.xpath.DeleteUpdatePrimitive
beta.xslt.xpath.DynamicContext
beta.xslt.xpath.Error
beta.xslt.xpath.Executable
beta.xslt.xpath.Expression
beta.xslt.xpath.ExtensionItem
beta.xslt.xpath.FunctionItem
beta.xslt.xpath.InsertAfterUpdatePrimitive
beta.xslt.xpath.InsertAttributesUpdatePrimitive
beta.xslt.xpath.InsertBeforeUpdatePrimitive
beta.xslt.xpath.InsertIntoAsFirstUpdatePrimitive
beta.xslt.xpath.InsertIntoAsLastUpdatePrimitive
beta.xslt.xpath.InsertIntoUpdatePrimitive
beta.xslt.xpath.InsertUpdatePrimitive
beta.xslt.xpath.Instruction
beta.xslt.xpath.InstructionList
beta.xslt.xpath.Item
beta.xslt.xpath.MapItem
beta.xslt.xpath.Module
beta.xslt.xpath.NodeItem
beta.xslt.xpath.PutUpdatePrimitive
beta.xslt.xpath.RenameUpdatePrimitive
beta.xslt.xpath.ReplaceElementContentUpdatePrimitive
beta.xslt.xpath.ReplaceNodeUpdatePrimitive
beta.xslt.xpath.ReplaceValeUpdatePrimitive
beta.xslt.xpath.ReplaceValueUpdatePrimitive
beta.xslt.xpath.Result
beta.xslt.xpath.ResultList
beta.xslt.xpath.RuntimeError
beta.xslt.xpath.RuntimeOptions
beta.xslt.xpath.Sequence
beta.xslt.xpath.SerializationParams
beta.xslt.xpath.Session
beta.xslt.xpath.TextLocation
beta.xslt.xpath.Tracepoint
beta.xslt.xpath.TracepointList
beta.xslt.xpath.TypeConverter
beta.xslt.xpath.UpdatePrimitive
beta.xslt.xpath.Variable
beta.xslt.xpath.WhitespaceHandler
beta.xslt.xpath.XmlDocumentOptions
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 ofbeta.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 ofbeta.xpath.CompileOptions
andbeta.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
¶
-
SerializationMethod.
HTML
¶
-
SerializationMethod.
JSON
¶
-
SerializationMethod.
TEXT
¶
-
SerializationMethod.
XHTML
¶
-
SerializationMethod.
XML
¶
-
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.