estk / xmlschemer

Code generator for xml schema files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XMLSchemer

The big idea here is that xml data formats like gpx kml and event xml-schema are specified in xml-schema and using that schema we can generate a model to interact with those data formats.

Usage

Basic usage:

cargo run -- -i [Input File] -o [Output rust file]

To generate code for the fixtures:

cargo run -- -i tests/fixtures/gpx.xsd -o ./tests/gen/gpx.rs

Debug logging

This project uses the pretty_env_logger crate, logging could be done for example by:

RUST_LOG=xmlschemer=trace cargo run -- -i tests/fixtures/gpx.xsd -o ./tests/gen/gpx.rs

Status

Currently the big limitations of this project are that serialization is waiting on serde-xml-rs, and that types defined using extensions of abstract types do not work. The failing tests reflect that these two features are not working yet.

The plan is to work on type inheritance then to proceed to serialization. Additionally this project uses a fork of the serde-xml-rs project that allows namespaces to be parsed out of xml, I'm working on getting that merged upstream here.

Still to do:

  • Type hirearchy
    • use serde flatten to build child types
    • Follow parents up to their root
    • make connection between parent and child types
    • When a child is found, parent types should be converted to enums which can either be themselves (if not abstract) or any of their children.
  • Handle Abstract types
  • Load External namespaces
  • Find an alternative to Prepending "Upcase"
  • Serialization
  • Allow selection of struct-vec polymorphism vs vec-enum
  • Cleanup schema codegen
  • Review struct visibility
  • Generate code for simpleType restrictions with a validation lib
  • change codegen to return a Result
  • selective imports in generated files
  • comment on generated files that explain that they are generated

Done:

  • Move resolution stuff into its own module
  • Review logging
  • Gen for atom.xsd
  • Fix double upcase
  • Handle xsd:ID
  • Handle refs correctly:
  • Split codegen return value into (defs: Ident, type: TokenStream)
  • Generate code for xs:extension
  • Unsure if its a requirement but parse namespaces?
  • Lookup namespaces and resolve types properly

About

Code generator for xml schema files


Languages

Language:Rust 100.0%