pyxsd.relaxng.introspection

Immutable RELAX NG grammar inventories, stable IDs, and dependency traversal.

The described object is the compiled semantic graph, not the authored syntax. Composition binds every reference and names the surviving element definitions with deterministic, composer-generated keys (element0, element1, …); an authored define name therefore does not appear in the inventory. Every definition component is marked RelaxNGComponentDescription.synthetic and its origins retain the authored evidence that produced it.

Component IDs cover normalized grammar semantics and dependency-content identities, never source paths, object addresses, process hash seeds, or mapping insertion order. Locations and origins are evidence beside those identities: relocating or recompiling identical resource content changes locations, not IDs. Name classes use a canonical, alternative-ordered presentation. Every pattern component, including an interior shared by a legal reference cycle, has a structural identity. Route components use the projection planner’s route ID directly.

Classes

RelaxNGComponentDescription

One immutable component of a compiled RELAX NG grammar.

RelaxNGSchemaDescription

A deterministic grammar inventory.

Functions

describe_schema(schema)

Return the immutable grammar inventory, valid schema or not.

describe_component(schema, component_id)

Return one exact component, raising KeyError for any other ID.

find_components(schema, *[, text, kind, namespace])

Filter by literal case-insensitive text, component kind, and namespace.

related_components(schema, component_id, *, direction, ...)

Breadth-first component traversal, excluding the seed and duplicates.

Module Contents

class pyxsd.relaxng.introspection.RelaxNGComponentDescription

One immutable component of a compiled RELAX NG grammar.

kind is grammar, define, pattern, name-class, datatype, route, or resource. namespace is an expanded-name namespace only (never a datatype-library URI). name is a local name for exact element/attribute patterns and exact name classes, an expanded element name for routes, a datatype type name for datatypes, and the first canonical resource ID for resources; otherwise it is absent. A definition’s name is the composer-generated key. synthetic is true only for these generated definitions, not for patterns or routes; authored define names survive only as origins. owner_id is None for the grammar and "grammar" for all other components: it denotes inventory ownership, not an authored parent. name_class is the canonical presentation of an element/attribute/route/name-class name class. Datatype components carry their normalized library, type, and ordered parameters. There are deliberately no XSD-only fields: no global_declaration, Python binding, occurrence count, or default. Origins union every contributing site. Location is the smallest origin by source ID then source/path/attribute, except resources: their location is the first sorted reference’s location (possibly absent), ordered by containing ID, reference, base, xml:base, canonical ID, then location.

id: str
kind: str
name: str | None
namespace: str | None
location: pyxsd.locations.IssueLocation | None
origins: pyxsd.relaxng.origins.OriginTable
owner_id: str | None
pattern_kind: str | None
name_class: str | None
datatype_library: str | None
datatype_name: str | None
datatype_parameters: tuple[tuple[str, str], ...]
synthetic: bool
class pyxsd.relaxng.introspection.RelaxNGSchemaDescription

A deterministic grammar inventory.

start_ids names the compiled start pattern component. Components are sorted by kind rank and then ID; dependencies is the compilation’s canonical resource closure verbatim, including every dependency record whose content merges into one resource component.

start_ids: tuple[str, ...]
components: tuple[RelaxNGComponentDescription, ...]
dependencies: tuple[pyxsd.relaxng.resources.ResourceDependency, ...]
pyxsd.relaxng.introspection.describe_schema(schema)

Return the immutable grammar inventory, valid schema or not.

An invalid compilation still exposes its grammar, start pattern, definitions, patterns, and resource dependencies. Projection routes are omitted without asking an invalid schema for schema.projection; the report and its verdict are never changed.

Parameters:

schema (pyxsd.relaxng.schema.RelaxNGSchema)

Return type:

RelaxNGSchemaDescription

pyxsd.relaxng.introspection.describe_component(schema, component_id)

Return one exact component, raising KeyError for any other ID.

Parameters:
Return type:

RelaxNGComponentDescription

pyxsd.relaxng.introspection.find_components(schema, *, text=None, kind=None, namespace=None)

Filter by literal case-insensitive text, component kind, and namespace.

None leaves a filter unrestricted; an empty namespace selects components without an expanded-name namespace. Text is matched literally over the ID, name, namespace, pattern kind, canonical name class, and datatype library/type; no caller expression is evaluated.

Parameters:
Return type:

tuple[RelaxNGComponentDescription, …]

pyxsd.relaxng.introspection.related_components(schema, component_id, *, direction, depth)

Breadth-first component traversal, excluding the seed and duplicates.

Parameters:
Return type:

tuple[RelaxNGComponentDescription, …]