pyxsd.schematron.limits¶
Immutable budget declarations for Schematron compilation and validation.
None leaves a budget unlimited, which preserves the core’s behavior on
trusted input. A configured budget is a non-negative integer and the bound is
inclusive: observing exactly the configured work count succeeds, and the next
unit raises SchematronLimitError. Boolean
and non-integer values are rejected rather than coerced. Exhaustion never
turns into semantic invalidity.
Compilation and validation limits are separate types because expansion and
report-retention bounds differ from XSLT execution bounds. execution
reuses the existing ExecutionLimits so one
validation charges nested expression work to the same budget contract as the
internal XSLT host.
Classes¶
Optional budgets for resolve, expansion, and expression compilation. |
|
Optional budgets for one validation invocation. |
|
One stage's running observation of the configured budgets. |
Module Contents¶
- class pyxsd.schematron.limits.SchematronCompileLimits¶
Optional budgets for resolve, expansion, and expression compilation.
max_resourcescounts admitted source resources, including the root.max_expanded_elementscounts source elements produced by include, external-extends, and abstract expansion together, so one value bounds the combined work of both stages rather than each stage on its own.max_expressionscounts compiled query expressions. A zero budget admits no unit of that work.
- class pyxsd.schematron.limits.SchematronValidationLimits¶
Optional budgets for one validation invocation.
max_outcomesbounds retained outcomes;max_sequence_itemsbounds any single sequence the driver materializes or retains, in particular arule/@visit-eachresult and a schema-parameter default. The check happens on the returned sequence’s length before the driver traverses, charges per-item work for, or previews it, so a large selection raises without multiplying work per item or retaining the sequence. The XPath engine still materializes one dispatch’s result;execution.max_stepscannot interrupt work inside that dispatch, somax_sequence_itemsis the sequence-size bound, notmax_steps.executioncarries the XSLT execution budgets used by the expression host. A zeromax_outcomesretains no outcome and therefore raises on the first produced outcome; a zeromax_sequence_itemsrejects any non-empty sequence.- execution: pyxsd.xslt.runtime.frames.ExecutionLimits¶
- class pyxsd.schematron.limits.SchematronBudgetCounter(stage, limits=None)¶
One stage’s running observation of the configured budgets.
A counter is per compilation or per validation; it counts each budget name independently and never mutates its limits value.
stagenames the work being charged. The counter accepts only budgets that belong to the supplied limits type, so a validation counter cannot charge a compile-only budget by accident.- Parameters:
stage (str)
limits (SchematronCompileLimits | SchematronValidationLimits | None)
- consume(budget, amount=1)¶
Record amount units of budget, raising when the bound is crossed.