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