pyxsd.xpath =========== .. py:module:: pyxsd.xpath .. autoapi-nested-parse:: XPath evaluation substrate for the pyxsd transformation engine. The package contains the diagnostic capability probes, the continuation seam, and the standalone, schema-aware expression environment. It does not import stylesheet execution code: expressions compile and evaluate without a transformation, initial template, result builder, or mode. Classes ------- .. autoapisummary:: pyxsd.xpath.CompiledExpression pyxsd.xpath.XPathEngine pyxsd.xpath.XPathStaticContext pyxsd.xpath.ExpressionEnvironment pyxsd.xpath.Focus Package Contents ---------------- .. py:class:: CompiledExpression An immutable expression compiled against one static context. .. py:attribute:: source :type: str .. py:attribute:: static_context :type: pyxsd.xpath.environment.XPathStaticContext .. py:attribute:: version :type: str .. py:attribute:: continuation_plan :type: pyxsd.xpath.continuation.CompiledExpression | None :value: None .. py:attribute:: variable_names :type: frozenset[str] .. py:attribute:: free_variable_names :type: frozenset[str] .. py:class:: XPathEngine(version = '3.1', *, xslt_functions = True) Compile and evaluate standalone XPath expressions. .. py:property:: version :type: str .. py:property:: xslt_functions :type: bool Whether XSLT-only functions such as ``key`` are registered. .. py:property:: parser_class :type: type[Any] .. py:method:: compile(source, static_context = None) Parse *source* and freeze every static decision it depends on. .. py:method:: evaluate(compiled, environment, *, focus = None) Evaluate one compiled expression with invocation-local dynamic state. When ``environment.parser_cache`` is supplied, the parser and its symbol table are reused across evaluations of the same static configuration; every dynamic-context component still comes from *environment*. .. py:class:: XPathStaticContext Immutable parser configuration shared by compiled expressions. ``functions`` declares host functions that the parser may resolve at compile time. Keys are prefixed lexical QNames (``"m:f"``) or Clark names whose namespace has a prefix in ``namespaces``. The declaration carries arity only; the callable is supplied by each :class:`ExpressionEnvironment`. .. py:attribute:: namespaces :type: collections.abc.Mapping[str, str] .. py:attribute:: default_namespace :type: str | None :value: None .. py:attribute:: variable_types :type: collections.abc.Mapping[str, str] .. py:attribute:: functions :type: collections.abc.Mapping[str, FunctionArity] .. py:attribute:: schema :type: pyxsd.xdm.schema.SchemaPool | None :value: None .. py:attribute:: base_uri :type: str | None :value: None .. py:attribute:: default_collation :type: str | None :value: None .. py:attribute:: xsd_version :type: str | None :value: None .. py:attribute:: xslt_version :type: str | None :value: None .. py:attribute:: compatibility_mode :type: bool :value: False .. py:method:: function_arity(name) Return the declared arity for *name*, trying Clark/prefix forms. .. py:method:: expand_name(name) Expand a prefixed lexical QName with this context's namespaces. .. py:method:: lexical_name(name) Return a prefixed lexical form for a Clark name, if a prefix exists. .. py:class:: ExpressionEnvironment One invocation's dynamic XPath values. Construction copies every mapping. ``current_datetime`` and the implicit timezone are fixed here, so repeated evaluations through the same environment observe stable dynamic values. Resources are exactly the explicitly supplied documents/collections/text resources; absence is a resource denial, never a silent filesystem or network read. .. py:attribute:: variables :type: collections.abc.Mapping[str, Any] .. py:attribute:: functions :type: collections.abc.Mapping[str, Any] .. py:attribute:: function_overrides :type: collections.abc.Mapping[str, Any] .. py:attribute:: key_indexes :type: collections.abc.Mapping[str, collections.abc.Mapping[Any, collections.abc.Sequence[pyxsd.xdm.nodes.XdmNode]]] .. py:attribute:: documents :type: collections.abc.Mapping[str, pyxsd.xdm.nodes.XdmDocument] .. py:attribute:: collections :type: collections.abc.Mapping[str, collections.abc.Sequence[pyxsd.xdm.nodes.XdmNode]] .. py:attribute:: default_collection :type: collections.abc.Sequence[pyxsd.xdm.nodes.XdmNode] :value: () .. py:attribute:: text_resources :type: collections.abc.Mapping[str, str] .. py:attribute:: decimal_formats :type: collections.abc.Mapping[str | None, collections.abc.Mapping[str, str]] .. py:attribute:: current_datetime :type: datetime.datetime | None :value: None .. py:attribute:: implicit_timezone :type: elementpath.datatypes.datetime.Timezone | str | datetime.tzinfo | datetime.timedelta | None :value: None .. py:attribute:: base_uri :type: str | None :value: None .. py:attribute:: parser_cache :type: object | None :value: None .. py:attribute:: adapter_registry :type: object | None :value: None .. py:attribute:: key_lookup :type: collections.abc.Callable[[pyxsd.xdm.values.XdmItem | None, tuple[pyxsd.xdm.values.XdmSequence, ...]], pyxsd.xdm.values.XdmSequence] | None :value: None .. py:attribute:: id_lookup :type: collections.abc.Callable[[pyxsd.xdm.values.XdmItem | None, tuple[pyxsd.xdm.values.XdmSequence, ...], bool], pyxsd.xdm.values.XdmSequence] | None :value: None .. py:attribute:: idref_lookup :type: collections.abc.Callable[[pyxsd.xdm.values.XdmItem | None, tuple[pyxsd.xdm.values.XdmSequence, ...]], pyxsd.xdm.values.XdmSequence] | None :value: None .. py:property:: current_date_time :type: datetime.datetime Alias matching the XPath function's spelling. .. py:property:: timezone :type: elementpath.datatypes.datetime.Timezone The normalized implicit timezone. .. py:class:: Focus An explicit XPath focus with the absent/empty distinction preserved. ``Focus.absent()`` means no context item exists; an expression that needs one raises ``XPDY0002``. ``Focus.empty()`` is an explicitly empty focus and evaluates to the empty sequence without entering the expression. The two are never converted into one another. .. py:attribute:: kind :type: FocusKind .. py:attribute:: item :type: pyxsd.xdm.values.XdmItem | None :value: None .. py:attribute:: position :type: int :value: 1 .. py:attribute:: size :type: int :value: 1 .. py:method:: absent() :classmethod: .. py:method:: empty() :classmethod: .. py:method:: singleton(item, *, position = 1, size = 1) :classmethod: .. py:property:: is_absent :type: bool .. py:property:: is_empty :type: bool