xquery.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 xpath.Expression.compile and xpath.Expression.execute.
There are also utility functions xpath.compile and 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¶
xquery.xpath.ArrayItem
xquery.xpath.AtomicItem
xquery.xpath.Breakpoint
xquery.xpath.BreakpointList
xquery.xpath.CallStackItem
xquery.xpath.CancelFlag
xquery.xpath.CompileError
xquery.xpath.CompileOptions
xquery.xpath.Debugger
xquery.xpath.DecimalFormat
xquery.xpath.DeleteUpdatePrimitive
xquery.xpath.DynamicContext
xquery.xpath.Error
xquery.xpath.Executable
xquery.xpath.Expression
xquery.xpath.ExtensionItem
xquery.xpath.ExternalFunctionObject
xquery.xpath.ExternalFunctions
xquery.xpath.FunctionItem
xquery.xpath.InsertAfterUpdatePrimitive
xquery.xpath.InsertAttributesUpdatePrimitive
xquery.xpath.InsertBeforeUpdatePrimitive
xquery.xpath.InsertIntoAsFirstUpdatePrimitive
xquery.xpath.InsertIntoAsLastUpdatePrimitive
xquery.xpath.InsertIntoUpdatePrimitive
xquery.xpath.InsertUpdatePrimitive
xquery.xpath.Instruction
xquery.xpath.InstructionList
xquery.xpath.Item
xquery.xpath.MapItem
xquery.xpath.Module
xquery.xpath.NodeItem
xquery.xpath.PutUpdatePrimitive
xquery.xpath.RenameUpdatePrimitive
xquery.xpath.ReplaceElementContentUpdatePrimitive
xquery.xpath.ReplaceNodeUpdatePrimitive
xquery.xpath.ReplaceValeUpdatePrimitive
xquery.xpath.ReplaceValueUpdatePrimitive
xquery.xpath.Result
xquery.xpath.ResultList
xquery.xpath.RuntimeError
xquery.xpath.RuntimeOptions
xquery.xpath.Sequence
xquery.xpath.SerializationParams
xquery.xpath.Session
xquery.xpath.TextLocation
xquery.xpath.Tracepoint
xquery.xpath.TracepointList
xquery.xpath.TypeConverter
xquery.xpath.UpdatePrimitive
xquery.xpath.Variable
xquery.xpath.WhitespaceHandler
xquery.xpath.XmlDocumentOptions
Enumeration classes¶
xquery.xpath.BreakPosition
xquery.xpath.BreakReason
xquery.xpath.DebugAction
xquery.xpath.DeliveryFormat
xquery.xpath.ExecutionMode
xquery.xpath.ImportStrategy
xquery.xpath.NormalizationForm
xquery.xpath.ProcessContents
xquery.xpath.SchemaLocationStrategy
xquery.xpath.SerializationMethod
xquery.xpath.Standalone
xquery.xpath.Version
xquery.xpath.XsdVersion
Functions¶
- xquery.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 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 xpath.CompileOptions are supported and are used to initialize the internally created options object.
- xquery.xpath.execute(unicode expression_text, *, Session session, initial_context=None, **kwargs)¶
- Compile and execute the xpath expression.
Returns an xpath.Sequence, or raises an exception if an error is encountered. The keyword arguments corresponding to the properties of xpath.CompileOptions and 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