Skip to content

feat: Next-Gen Polyglot XML Schema Compiler & Toolchain (Epic #22) - #33

Merged
nth-bailey merged 20 commits into
mainfrom
feat/polyxml-compiler
Sep 20, 2026
Merged

nth-bailey merged 20 commits into
mainfrom
feat/polyxml-compiler

Conversation

@nth-bailey

Copy link
Copy Markdown
Collaborator

Summary

Closes #22
Closes #23
Closes #24
Closes #25
Closes #26
Closes #27
Closes #28
Closes #29
Closes #30
Closes #31
Closes #32

This PR delivers the Next-Gen Polyglot XML Schema Compiler & Toolchain for PolyXML, introducing a high-performance W3C XSD 1.0 & 1.1 compiler and code generator in pure Rust. It parses XML Schemas into a canonical, language-agnostic Intermediate Representation (IR), resolves recursive cycles via Tarjan's Strongly Connected Components algorithm, and generates idiomatic data models and high-performance codecs across 7 modern programming languages:

🎯 Supported Language Targets

  1. Python 3.12+ ([Target: Python] Modern Python 3.12+ Codegen (@dataclass & Pydantic v2) #24):

  2. Rust 2021/2024 ([Target: Rust] Zero-Copy Rust 2021/2024 Codegen (struct + enum with Cow<'a, str>) #25, [Phase 3 / Runtime Codecs] Zero-Copy Streaming Deserializer & Serializer Codec Synthesis for Rust & Python #32):

  3. Modern C++20 / C++23 ([Target: C++] Modern C++20/C++23 Codegen (struct, std::variant, std::optional, Concepts) #26):

    • Value types, std::variant choice representations, and C++20 concepts (PolyXmlElement).
    • Smart pointer cycle cuts (std::unique_ptr<T>).
    • CMake and Meson project export integration.
    • Formatted via clang-format.
  4. Java 21+ ([Target: Java] Java 21+ Modern Codegen (record + sealed interface) #27):

    • Modern immutable Java records and sealed interface choice models with exhaustive pattern matching.
    • Cyclic reference graph resolution.
    • Jakarta Bean Validation annotations (@Pattern, @Size, @Min, @Max).
    • Formatted via Google Java Format.
  5. TypeScript 5+ ([Target: TypeScript] TypeScript 5+ & Zod Codegen (Discriminated Unions & Strict Types) #28):

    • Idiomatic TypeScript interfaces and discriminated unions.
    • Production Zod runtime validation schemas with z.lazy() recursion.
    • Formatted via Prettier.
  6. Go 1.22+ ([Target: Go] Go 1.22+ Struct Codegen (struct with XML tags & Choice Validation) #29):

    • Idiomatic Go structs with standard encoding/xml tags and pointer cycle cuts.
    • Custom UnmarshalXML choice types guaranteeing mutual exclusivity.
    • Formatted via gofmt.
  7. C# 12 / .NET 8+ ([Target: C#] C# 12 / .NET 8+ Codegen (record class / record struct) #30):

    • Modern record definitions with primary constructors and System.Xml.Serialization attributes.
    • Polymorphic xs:choice abstract records.
    • IValidatableObject implementation with regex and facet constraints.
    • Formatted via csharpier.

🛠️ CLI & Workspace Toolchain (#31)

  • polyxml generate: Multi-language, single-invocation code generation with --lang, --out, --backend, --zero-copy, --codecs, and --dry-run.
  • polyxml build: Declarative workspace orchestration powered by polyxml.toml.
  • polyxml validate: Fast static XML Schema structure and cycle topology validation.

🛡️ Quality Gate & Verification

  • Rust: cargo fmt --check, cargo clippy --workspace --all-targets -D warnings (0 warnings).
  • Python: ruff check, ruff format --check, and 100% statement & branch coverage (pytest --cov --cov-branch --cov-fail-under=100).
  • Workspace Tests: All unit and integration tests passing, including end-to-end compilation tests for Python, Rust, C++, Java, TypeScript, Go, and C#.

…s codegen (#27)

- Added pure-Rust Java 21+ code generation in polyxml-core
- Generates canonical public record definitions for complex types (rejecting legacy JavaBeans)
- Generates public sealed interfaces with exhaustive member records for xs:choice
- Value-backed public enum types with fromValue/getValue
- Restriction facet validation in compact constructors
- CLI support for --lang java and --package flag
- Full unit and CLI E2E tests verified against javac -Werror (JDK 21)
…codegen (#26)

- Pure-Rust C++20/C++23 code generator backend with zero Xerces-C++ runtime dependencies
- Emits clean aggregate-initializable C++20 structs with defaulted equality (operator== ... = default)
- Maps xs:choice to std::variant with canonical overloaded pattern-matching visitor helper
- Maps recursive cycles to std::unique_ptr<T> based on Tarjan SCC cycle cuts
- Emits scoped enum class with constexpr to_string and from_string conversion helpers
- Restriction facet validation methods (validate() const noexcept) and C++20 XmlModel concept
- Supports both standard header-only (.hpp) mode and C++20 Modules (.cppm) mode
- Generates CMake (CMakeLists.txt, PolyXMLConfig.cmake) and Meson (meson.build) integration definitions
- Full CLI support for --lang cpp and --namespace flag with clang-format integration
- Comprehensive unit and E2E tests verified against g++ -std=c++20 -Wall -Wextra -Wpedantic -Werror
… and redefines

- Handle anonymous complexType/simpleType on global and local elements via name override
- Propagate list cardinality for elements within unbounded compositors (sequence/choice/all)
- Guard against treating repeated choice models (maxOccurs > 1) as single-variant unions
- Implement 3-color cycle-safe topological sorting in Python, Rust, and TS to prevent stack overflow
- Support <xsd:redefine> alongside <xsd:include> in schema parser
- Guard against self-inheritance when extension base equals struct name
- Ingest empty <xsd:complexType name='...'/> and <xsd:simpleType name='...'/> tags into SchemaIR
- Fix Decimal import omission when Decimal primitive is only used in global elements
- Sanitize Python keywords (field, dataclass, self) and non-ASCII identifier prefixes
@nth-bailey
nth-bailey merged commit ddfc204 into main Sep 20, 2026
27 of 28 checks passed
@nth-bailey
nth-bailey deleted the feat/polyxml-compiler branch September 20, 2026 04:27
nth-bailey pushed a commit that referenced this pull request Sep 20, 2026
# [0.12.0](v0.11.1...v0.12.0) (2026-09-20)

### Features

* Next-Gen Polyglot XML Schema Compiler & Toolchain (Epic [#22](#22)) ([#33](#33)) ([ddfc204](ddfc204)), closes [#23](#23) [#31](#31) [#24](#24) [#25](#25) [#32](#32) [#28](#28) [#27](#27) [#26](#26) [#29](#29) [#30](#30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment