Skip to main content

zxsd — XSD compiler and bounded C validator

Build and test Documentation OpenSSF Scorecard PyPI License

zxsd compiles a supported XML Schema (XSD) subset into immutable C descriptors. The target application links those descriptors with a portable C99 runtime to validate XML without parsing the schema at runtime.

  • zxsdc runs on the build host and generates deterministic C source and headers.
  • libzxsd validates complete documents, raw byte fragments, or parser events.
  • Optional generated bindings read and write typed C structures using caller-owned storage.
  • Resource limits are fixed at compile time; zero-heap builds are supported.

Python, filesystem access, networking, and an XSD parser are never required on the target.

Status: draft/experimental. zxsd implements a documented XSD 1.0 subset, not the complete specification. Unsupported schema constructs fail explicitly. During 0.x, upgrades require rebuilding the runtime and generated code.

Documentation · XSD support matrix · Getting started · Typed bindings · Zephyr · Compatibility

Quick start

Generate a schema-specific validator:

python3 zxsdc tests/device.xsd -o generated

The generated header exposes a validation entry point:

#include "device.zxsd.h"

zxsd_result_t result = device_validate(xml);
if (result.code != ZXSD_OK) {
    /* result.message, result.offset and result.path describe the error. */
}

The installed CMake package can generate and compile the validator as part of the application build:

find_package(zxsd CONFIG REQUIRED)

add_executable(application main.c)
zxsd_generate(TARGET application SCHEMA device.xsd)
target_link_libraries(application PRIVATE zxsd::zxsd)

Add BINDINGS to zxsd_generate() to generate typed C structures and read/write functions. The host compiler is also available as python -m pip install zxsdc. See Getting started for source builds, installation, and non-CMake integration.

What it validates

The supported subset includes:

  • simple and complex types, derivation, lists, unions, and facets;
  • sequences, choices, all, groups, occurrences, and wildcards;
  • namespaces, schema composition, substitution groups, and recursive types;
  • xsi:nil, xsi:type, defaults, fixed values, and abstract declarations;
  • unique, key, keyref, and the restricted XSD identity XPath language;
  • a bounded XSD regular-expression subset with Unicode categories and blocks.

The exact contract, including partial and unsupported features, is maintained in SUPPORT.md. Compiler acceptance alone is not treated as conformance.

Runtime modes

  • Document validation: validate a NUL-terminated XML document with one call.
  • Incremental XML: feed arbitrary byte fragments from a socket, file, or HTTP client.
  • Event validation: send expanded start, attribute, text, and end events from another parser.
  • Typed bindings: validate and materialize selected schemas into generated C structures.
  • Streaming bindings: receive selected typed subtrees while validating the document once.

All modes use the same generated schema descriptors. Inputs that exceed a configured depth, text, identity, model, or input limit fail with a structured error instead of growing memory without a bound.

Embedded use

The runtime is portable C99 and is tested on Linux, macOS, Windows, and Zephyr. ZXSD_NO_HEAP=ON removes standard-library allocation; schemas with identity constraints can use an explicit application allocator. zxsdc --zephyr-config generates Kconfig recommendations and compile-time limit checks from the schema.

Zephyr uses the allocation-free XML backend by default. Mini-XML 4 is an optional adapter for validating an existing Mini-XML tree, on the host or on Zephyr when a Mini-XML module provides CONFIG_MXML.

See the host sample, Zephyr samples, and resource-usage guide for complete integrations.

Conformance

Project-owned positive and negative tests gate every documented feature. An optional W3C XSD 1.0 harness inventories the official suite while keeping passed, failed, unsupported, expected-failure, and skipped results distinct.

See Conformance and test coverage.

zxsd is licensed under Apache-2.0.

Assistance

Development assisted by GPT-5.6 Sol.

Metadata

Release files for zxsdc 0.20.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zxsdc 0.20.0
File Size Uploaded Provenance Actions
zxsdc-0.20.0.tar.gz 70.8 kB With provenance Details for zxsdc-0.20.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zxsdc 0.20.0
File Interpreter ABI Platform Actions
zxsdc-0.20.0-py3-none-any.whl Python 3 none any Details for zxsdc-0.20.0-py3-none-any.whl

Total release size: 144.9 kB

Release files / zxsdc-0.20.0.tar.gz

Download URL zxsdc-0.20.0.tar.gz
Size 70.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f57844aaa5f7de28c6085c69595148b8db0ca46a2b4dc73cca8dc2603cf784e8
BLAKE2b-256 checksum
How to use checksums
3a7ff61b0d8a0a0d4ae1ceab019fbfe60faf7e09001f2742c363a6a2705f75a4
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 29, 2026.

Transparency log

Release files / zxsdc-0.20.0-py3-none-any.whl

Download URL zxsdc-0.20.0-py3-none-any.whl
Size 74.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2ab1dae904d512571f908b6addccdb0862fca6f3c320618f04a23cf8f2f69ed
BLAKE2b-256 checksum
How to use checksums
05ecc5c96432ccb2a5541dd030c1719b558e85ca689b56e81819b23a05ff92c1
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 29, 2026.

Transparency log

Security for zxsdc 0.20.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.

Select from 2 files

Attestation for zxsdc-0.20.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 29, 2026.

Transparency log

A 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.20.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page