XSDFormer
XSDFormer deforms XML schema definitions (XSDs) into Protobuf definitions. It also generates Python code to convert parsed XML into the corresponding Protobuf representation.
It supports enough of the XSD specification to convert the ClinVar and BioC schemas; full support for all XSD features is a non-goal.
Why convert from XSD to Protobuf?
While XML and XSDs (or alternatively JSON and JSON schemas) are powerful for defining complex, human-readable data structures, they have some drawbacks, especially in high-performance applications or when dealing with large datasets.
Performance and Size
- Parsing Speed: XML is a text-based format and can be slow to parse. Protobuf is a binary format that is designed for speed and efficiency. Converting XML data to Protobuf can result in significantly faster parsing times.
- Storage Space: XML is verbose, with opening and closing tags that add to the file size. Protobuf's binary format is much more compact, leading to smaller file sizes. This is a major advantage for storing large datasets or for transmitting data over a network. Effectively compressing XML requires a schema-specific dictionary, or compressing multiple records together so that the dictionary of tag/key names can be reused. However this limits the possibility for random access enabled by compressing records individually.
Developer Experience
- Generated Code: Protobuf compilers generate code in many languages, providing a simple and consistent way to work with the data.
- Type Safety: The Protobuf schema provides strong typing, which can help to prevent bugs. Parsing the wire format requires the protobuf definition, meaning that the data is tied to its typed representation. Conversely XML representations are only optionally validated by a schema, and so by default type information is lost during parsing (everything is treated as text).
By converting XSDs to Protobuf definitions, xsd-former allows
developers to take advantage of the benefits of Protobuf while still
working with data that is originally defined in an XML schema.
Output formats
From a single XSD (or DTD) source, XSDFormer can emit:
- Protobuf (
.proto) —--proto-out. - Python XML→protobuf converters —
--py-out/--py-module. - JSON Schema —
--json-schema-out(from the XSD, or directly from a.protovia theprotosubcommand). - TypeSpec (
.tsp) —--typespec-out(see below).
TypeSpec output
TypeSpec is a compact, authorable schema
language that fans out to OpenAPI, JSON Schema, and protobuf — and from
those to pydantic and zod. XSDFormer emits a .tsp so the same model
that backs the stored protobufs can also drive backend pydantic models
and frontend zod validators, all interconvertible.
# Default: clean, readable TypeSpec (string-valued enums, native scalars).
# Suited to pydantic/zod generation.
xsdformer xsd schema.xsd --typespec-out schema.tsp
# DTD sources work too (e.g. PubMed).
xsdformer dtd pubmed.dtd --typespec-out pubmed.tsp --proto-package pubmed
# proto-compat: adds @typespec/protobuf decorations (@package, @field,
# integer-valued enums) so `tsp -> proto` can be run as a regression
# check that it matches the directly generated proto.
xsdformer xsd schema.xsd --typespec-out schema.tsp --proto-compat
The .tsp is a derived artifact — regenerated from the XSD alongside
the proto, never hand-edited. The governing invariant is that
xsd → proto and xsd → tsp → proto agree at the wire/semantic level
(field numbers, field types, enum numbers); cosmetic differences
(oneof grouping, nested-vs-hoisted placement, comments, ordering) are
tolerated. See docs/adr/0001-typespec-output-format.md
for the full design.
Metadata
Release files for xsd-former 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xsd_former-1.5.0.tar.gz | 263.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xsd_former-1.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 322.6 kB
Release files / xsd_former-1.5.0.tar.gz
| Download URL | xsd_former-1.5.0.tar.gz |
|---|---|
| Size | 263.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0720d550497ca2560013e8ecc91fa65bd781813a4e48cb2480c8da5935d01ac7
|
|
BLAKE2b-256 checksum How to use checksums |
8135c605f02459ddb6febcf03115831d7c473d105cce7a58a3d30c6b3f584c2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / xsd_former-1.5.0-py3-none-any.whl
| Download URL | xsd_former-1.5.0-py3-none-any.whl |
|---|---|
| Size | 58.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aec96dbbb03bbf45d4e182301c438a809248829cde3d025132e0137948730b2d
|
|
BLAKE2b-256 checksum How to use checksums |
0960afe50d97e5effbca5f6dba9666a071c6aea7da7f7e1e0b66458debb261c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for xsd-former 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for xsd_former-1.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.