pyxsd.integrations.pydantic =========================== .. py:module:: pyxsd.integrations.pydantic .. autoapi-nested-parse:: Generate standalone Pydantic models and typed snapshots of bound XML. Install ``pyxsd[pydantic]``. Models validate the projected data contract; whole-document XML validation remains ``Document.revalidate()``. Classes ------- .. autoapisummary:: pyxsd.integrations.pydantic.ModelSet Functions --------- .. autoapisummary:: pyxsd.integrations.pydantic.clean_field_schema pyxsd.integrations.pydantic.models Module Contents --------------- .. py:function:: clean_field_schema(schema) Remove the internal ``None`` placeholder from one field schema. A missing optional non-nillable field has an internal ``None`` default in the model, but that is not a nullable input/default in the JSON Schema contract. XSD and RELAX NG schema hooks share this exact cleanup. .. py:class:: ModelSet(schema) A compiled-schema-scoped registry of generated Pydantic models. .. py:attribute:: schema .. py:method:: model_for(*, element, path = ()) Resolve a global declaration or an unambiguous local declaration path. .. py:method:: from_document(document, *, revalidate = False) Snapshot a bound document; request fresh XML validation explicitly. .. py:method:: from_node(node, *, element, path = ()) Snapshot an occurrence matching the selected compiled declaration. .. py:function:: models(schema: pyxsd.schema.Schema) -> ModelSet models(schema: pyxsd.relaxng.schema.RelaxNGSchema) -> pyxsd.relaxng.pydantic_adapter.RelaxNGModelSet Create a model registry without requiring instance XML. A compiled XSD schema still returns the existing :class:`ModelSet`. A compiled RELAX NG schema returns its route registry; the RELAX NG adapter is imported lazily so XSD-only use never imports RELAX NG projection code.