pyxsd.xpath¶
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¶
An immutable expression compiled against one static context. |
|
Compile and evaluate standalone XPath expressions. |
|
Immutable parser configuration shared by compiled expressions. |
|
One invocation's dynamic XPath values. |
|
An explicit XPath focus with the absent/empty distinction preserved. |
Package Contents¶
- class pyxsd.xpath.CompiledExpression¶
An immutable expression compiled against one static context.
- static_context: pyxsd.xpath.environment.XPathStaticContext¶
- class pyxsd.xpath.XPathEngine(version='3.1', *, xslt_functions=True)¶
Compile and evaluate standalone XPath expressions.
- compile(source, static_context=None)¶
Parse source and freeze every static decision it depends on.
- Parameters:
source (str)
static_context (pyxsd.xpath.environment.XPathStaticContext | None)
- Return type:
- evaluate(compiled, environment, *, focus=None)¶
Evaluate one compiled expression with invocation-local dynamic state.
When
environment.parser_cacheis supplied, the parser and its symbol table are reused across evaluations of the same static configuration; every dynamic-context component still comes from environment.- Parameters:
compiled (CompiledExpression)
environment (pyxsd.xpath.environment.ExpressionEnvironment)
focus (pyxsd.xpath.environment.Focus | pyxsd.xdm.XdmItem | collections.abc.Sequence[Any] | None)
- Return type:
- class pyxsd.xpath.XPathStaticContext¶
Immutable parser configuration shared by compiled expressions.
functionsdeclares 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 innamespaces. The declaration carries arity only; the callable is supplied by eachExpressionEnvironment.- namespaces: collections.abc.Mapping[str, str]¶
- variable_types: collections.abc.Mapping[str, str]¶
- functions: collections.abc.Mapping[str, FunctionArity]¶
- function_arity(name)¶
Return the declared arity for name, trying Clark/prefix forms.
- Parameters:
name (str)
- Return type:
FunctionArity | None
- expand_name(name)¶
Expand a prefixed lexical QName with this context’s namespaces.
- class pyxsd.xpath.ExpressionEnvironment¶
One invocation’s dynamic XPath values.
Construction copies every mapping.
current_datetimeand 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.- variables: collections.abc.Mapping[str, Any]¶
- functions: collections.abc.Mapping[str, Any]¶
- function_overrides: collections.abc.Mapping[str, Any]¶
- key_indexes: collections.abc.Mapping[str, collections.abc.Mapping[Any, collections.abc.Sequence[pyxsd.xdm.nodes.XdmNode]]]¶
- documents: collections.abc.Mapping[str, pyxsd.xdm.nodes.XdmDocument]¶
- collections: collections.abc.Mapping[str, collections.abc.Sequence[pyxsd.xdm.nodes.XdmNode]]¶
- default_collection: collections.abc.Sequence[pyxsd.xdm.nodes.XdmNode] = ()¶
- text_resources: collections.abc.Mapping[str, str]¶
- decimal_formats: collections.abc.Mapping[str | None, collections.abc.Mapping[str, str]]¶
- current_datetime: datetime.datetime | None = None¶
- implicit_timezone: elementpath.datatypes.datetime.Timezone | str | datetime.tzinfo | datetime.timedelta | None = None¶
- key_lookup: collections.abc.Callable[[pyxsd.xdm.values.XdmItem | None, tuple[pyxsd.xdm.values.XdmSequence, ...]], pyxsd.xdm.values.XdmSequence] | None = None¶
- id_lookup: collections.abc.Callable[[pyxsd.xdm.values.XdmItem | None, tuple[pyxsd.xdm.values.XdmSequence, ...], bool], pyxsd.xdm.values.XdmSequence] | None = None¶
- idref_lookup: collections.abc.Callable[[pyxsd.xdm.values.XdmItem | None, tuple[pyxsd.xdm.values.XdmSequence, ...]], pyxsd.xdm.values.XdmSequence] | None = None¶
- property current_date_time: datetime.datetime¶
Alias matching the XPath function’s spelling.
- Return type:
- property timezone: elementpath.datatypes.datetime.Timezone¶
The normalized implicit timezone.
- Return type:
elementpath.datatypes.datetime.Timezone
- class pyxsd.xpath.Focus¶
An explicit XPath focus with the absent/empty distinction preserved.
Focus.absent()means no context item exists; an expression that needs one raisesXPDY0002.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.- kind: FocusKind¶
- item: pyxsd.xdm.values.XdmItem | None = None¶
- classmethod singleton(item, *, position=1, size=1)¶
- Parameters:
item (pyxsd.xdm.values.XdmItem)
position (int)
size (int)
- Return type: