pyxsd.relaxng.introspection =========================== .. py:module:: pyxsd.relaxng.introspection .. autoapi-nested-parse:: 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 :attr:`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 ------- .. autoapisummary:: pyxsd.relaxng.introspection.RelaxNGComponentDescription pyxsd.relaxng.introspection.RelaxNGSchemaDescription Functions --------- .. autoapisummary:: pyxsd.relaxng.introspection.describe_schema pyxsd.relaxng.introspection.describe_component pyxsd.relaxng.introspection.find_components pyxsd.relaxng.introspection.related_components Module Contents --------------- .. py:class:: 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. .. py:attribute:: id :type: str .. py:attribute:: kind :type: str .. py:attribute:: name :type: str | None .. py:attribute:: namespace :type: str | None .. py:attribute:: location :type: pyxsd.locations.IssueLocation | None .. py:attribute:: origins :type: pyxsd.relaxng.origins.OriginTable .. py:attribute:: owner_id :type: str | None .. py:attribute:: pattern_kind :type: str | None .. py:attribute:: name_class :type: str | None .. py:attribute:: datatype_library :type: str | None .. py:attribute:: datatype_name :type: str | None .. py:attribute:: datatype_parameters :type: tuple[tuple[str, str], ...] .. py:attribute:: synthetic :type: bool .. py:class:: 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. .. py:attribute:: start_ids :type: tuple[str, ...] .. py:attribute:: components :type: tuple[RelaxNGComponentDescription, ...] .. py:attribute:: dependencies :type: tuple[pyxsd.relaxng.resources.ResourceDependency, ...] .. py:function:: 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. .. py:function:: describe_component(schema, component_id) Return one exact component, raising :class:`KeyError` for any other ID. .. py:function:: 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. .. py:function:: related_components(schema, component_id, *, direction, depth) Breadth-first component traversal, excluding the seed and duplicates.