pyxsd.introspection

Immutable, native schema descriptions independent of optional projections.

Component IDs describe declarations, not generated Python object identities. Descriptions are a snapshot of a compiled schema; compile again after changing schema sources or overlays. Particle trees, rather than member occurrence summaries alone, retain the relationships between choices and repeated groups.

Attributes

Classes

FacetDescription

An effective facet; patterns retain AND-of-OR restriction groups.

WildcardDescription

A wildcard's effective namespace and validation policy.

ParticleDescription

A compiled particle, including group boundaries and declaration links.

MemberDescription

An XML member, accessor and type; particle trees govern group constraints.

IdentityDescription

An authored key, unique or keyref, without claiming XPath equivalence.

ComponentDescription

One declaration with native constraints and generated binding metadata.

SchemaDescription

A deterministic schema inventory; roots are global element IDs.

Functions

describe_schema(schema)

Return the native inventory, without requiring schema validity.

describe_component(schema, component_id)

Return one exact declaration, raising KeyError for an unknown 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 declaration traversal, excluding the seed and duplicates.

Module Contents

pyxsd.introspection.COMPONENT_KINDS
class pyxsd.introspection.FacetDescription

An effective facet; patterns retain AND-of-OR restriction groups.

name: str
value: Any
representation: str = 'value'
class pyxsd.introspection.WildcardDescription

A wildcard’s effective namespace and validation policy.

namespace: str
process_contents: str
target_namespace: str | None
not_namespace: tuple[str, ...]
not_qname: tuple[str, ...]
class pyxsd.introspection.ParticleDescription

A compiled particle, including group boundaries and declaration links.

kind: str
min_occurs: int
max_occurs: int | None
component_id: str | None
children: tuple[ParticleDescription, ...]
wildcard: WildcardDescription | None = None
open_content: bool = False
class pyxsd.introspection.MemberDescription

An XML member, accessor and type; particle trees govern group constraints.

kind: str
xml_name: str
python_name: str
python_type: str
component_id: str | None
min_occurs: int
max_occurs: int | None
default: str | None
fixed: str | None
nillable: bool
use: str | None
facets: tuple[FacetDescription, ...]
occurrence_precision: Literal['exact', 'conservative'] = 'conservative'
class pyxsd.introspection.IdentityDescription

An authored key, unique or keyref, without claiming XPath equivalence.

kind: str
name: str | None
selector: str | None
fields: tuple[str, ...]
refer: str | None
class pyxsd.introspection.ComponentDescription

One declaration with native constraints and generated binding metadata.

id: str
kind: str
name: str | None
namespace: str | None
global_declaration: bool
location: pyxsd.locations.IssueLocation | None
owner_id: str | None
python_name: str | None
python_type: str | None
members: tuple[MemberDescription, ...]
particle: ParticleDescription | None
facets: tuple[FacetDescription, ...]
assertions: tuple[str, ...]
default: str | None
fixed: str | None
nillable: bool
mixed: bool
derivation: str | None
base_types: tuple[str, ...]
substitution_group: str | None
attribute_wildcard: WildcardDescription | None
documentation: str | None
identity_constraints: tuple[IdentityDescription, ...]
class pyxsd.introspection.SchemaDescription

A deterministic schema inventory; roots are global element IDs.

target_namespace: str | None
roots: tuple[str, ...]
components: tuple[ComponentDescription, ...]
pyxsd.introspection.describe_schema(schema)

Return the native inventory, without requiring schema validity.

Parameters:

schema (pyxsd.schema.Schema)

Return type:

SchemaDescription

pyxsd.introspection.describe_component(schema, component_id)

Return one exact declaration, raising KeyError for an unknown ID.

Parameters:
Return type:

ComponentDescription

pyxsd.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 unqualified declarations. No caller expression is evaluated.

Parameters:
Return type:

tuple[ComponentDescription, …]

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

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

Parameters:
Return type:

tuple[ComponentDescription, …]