beta.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.xpath.ArrayItem
beta.xpath.AtomicItem
beta.xpath.Breakpoint
beta.xpath.BreakpointList
beta.xpath.CallStackItem
beta.xpath.CancelFlag
beta.xpath.CompileError
beta.xpath.CompileOptions
beta.xpath.Debugger
beta.xpath.DecimalFormat
beta.xpath.DeleteUpdatePrimitive
beta.xpath.DynamicContext
beta.xpath.Error
beta.xpath.Executable
beta.xpath.Expression
beta.xpath.ExtensionItem
beta.xpath.FunctionItem
beta.xpath.InsertAfterUpdatePrimitive
beta.xpath.InsertAttributesUpdatePrimitive
beta.xpath.InsertBeforeUpdatePrimitive
beta.xpath.InsertIntoAsFirstUpdatePrimitive
beta.xpath.InsertIntoAsLastUpdatePrimitive
beta.xpath.InsertIntoUpdatePrimitive
beta.xpath.InsertUpdatePrimitive
beta.xpath.Instruction
beta.xpath.InstructionList
beta.xpath.Item
beta.xpath.MapItem
beta.xpath.Module
beta.xpath.NodeItem
beta.xpath.PutUpdatePrimitive
beta.xpath.RenameUpdatePrimitive
beta.xpath.ReplaceElementContentUpdatePrimitive
beta.xpath.ReplaceNodeUpdatePrimitive
beta.xpath.ReplaceValeUpdatePrimitive
beta.xpath.ReplaceValueUpdatePrimitive
beta.xpath.Result
beta.xpath.ResultList
beta.xpath.RuntimeError
beta.xpath.RuntimeOptions
beta.xpath.Sequence
beta.xpath.SerializationParams
beta.xpath.Session
beta.xpath.TextLocation
beta.xpath.Tracepoint
beta.xpath.TracepointList
beta.xpath.TypeConverter
beta.xpath.UpdatePrimitive
beta.xpath.Variable
beta.xpath.WhitespaceHandler
beta.xpath.XmlDocumentOptions
Functions¶
-
beta.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.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.xpath.
BreakPosition
¶ An enumeration.
-
class
beta.xpath.
BreakReason
¶ An enumeration.
-
class
beta.xpath.
DebugAction
¶ An enumeration.
-
class
beta.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.xpath.
ExecutionMode
¶ An enumeration.
-
class
beta.xpath.
ImportStrategy
¶ An enumeration.
-
class
beta.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.xpath.
ProcessContents
¶ An enumeration.
-
class
beta.xpath.
SchemaLocationStrategy
¶ An enumeration.
-
class
beta.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.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.xpath.
Version
¶ An enumeration.
-
class
beta.xpath.
XsdVersion
¶ An enumeration.