Skip to main content

<yaxp-cli ⚡> Yet Another XSD Parser

Project description

<yaxp ⚡>

Yet Another XSD Parser

Introduction

Using roxmltree to parse XML files.

Converts xsd schema to:

  • json
  • arrow
  • avro
  • protobuf
  • jsonschema
  • json representation of spark schema
  • duckdb

User Guide

Python

  • create and activate a Python virtual environment (or use poetry, uv, etc.)
  • install maturin (cargo install, pip install into venv, etc.)
(.venv)  ~/projects/yaxp/crates/pyaxp $
🔗 Found pyo3 bindings
🐍 Found CPython 3.12 at ~/projects/yaxp/crates/pyaxp/.venv/bin/python
📡 Using build options features from pyproject.toml
warning: ~/projects/yaxp/Cargo.toml: unused manifest key: workspace.name
    Blocking waiting for file lock on build directory
   Compiling pyo3-build-config v0.23.4
   Compiling pyo3-macros-backend v0.23.4
   Compiling pyo3-ffi v0.23.4
   Compiling pyo3 v0.23.4
   Compiling pyo3-macros v0.23.4
   Compiling yaxp-common v0.1.0 (~/Users/jeroen~/projects/yaxp/crates/yaxp-common)
   Compiling pyaxp v0.1.0 (~/Users/jeroen~/projects/yaxp/crates/pyaxp)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.03s
📦 Built wheel for CPython 3.12 to /var/folders/gr/gl3fzn_n0_g4fzpcfv2g40gh0000gn/T/.tmp3wQ0CY/pyaxp-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
✏️  Setting installed package as editable
🛠 Installed pyaxp-0.1.0
(.venv)  ~/projects/yaxp/crates/pyaxp $
Python 3.12.3 (main, Apr 15 2024, 17:43:11) [Clang 17.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyaxp import parse_xsd
>>> import json
>>> j = parse_xsd("example.xsd")
>>> type(j)
<class 'dict'>
>>> print(json.dumps(j, indent=4))
{
    "namespace": null,
    "schema_element": {
        "id": "Main_Element",
        "name": "Main_Element",
        "data_type": null,
        "min_occurs": "1",
        "max_occurs": "1",
        "min_length": null,
        "max_length": null,
        "min_exclusive": null,
        "max_exclusive": null,
        "min_inclusive": null,
        "max_inclusive": null,
        "pattern": null,
        "fraction_digits": null,
        "total_digits": null,
        "values": null,
        "is_currency": false,
        "xpath": "Main_Element/Main_Element",
        "nullable": null,
        "elements": [
            {
                "id": "Field1",
                "name": "Field1",
                "data_type": "string",
                "min_occurs": "1",
                "max_occurs": "1",
                "min_length": null,
                "max_length": "15",
                "min_exclusive": null,
                "max_exclusive": null,
                "min_inclusive": null,
                "max_inclusive": null,
                "pattern": null,
                "fraction_digits": null,
                "total_digits": null,
                "values": null,
                "is_currency": false,
                "xpath": "Main_Element/Main_Element/Field1",
                "nullable": false,
                "elements": []
            },
            {
                "id": "Field2",
                "name": "Field2",
                "data_type": "string",
                "min_occurs": "1",
                "max_occurs": "1",
                "min_length": null,
                "max_length": "20",
                "min_exclusive": null,
                "max_exclusive": null,
                "min_inclusive": null,
                "max_inclusive": null,
                "pattern": null,
                "fraction_digits": null,
                "total_digits": null,
                "values": null,
                "is_currency": false,
                "xpath": "Main_Element/Main_Element/Field2",
                "nullable": false,
                "elements": []
            },
            {
                "id": "Field3",
                "name": "Field3",
                "data_type": "string",
                "min_occurs": "1",
                "max_occurs": "1",
                "min_length": null,
                "max_length": "10",
                "min_exclusive": null,
                "max_exclusive": null,
                "min_inclusive": null,
                "max_inclusive": null,
                "pattern": null,
                "fraction_digits": null,
                "total_digits": null,
                "values": null,
                "is_currency": false,
                "xpath": "Main_Element/Main_Element/Field3",
                "nullable": false,
                "elements": []
            }, ...

TODO

  • Add pyo3/maturin support
  • Add tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyaxp-0.1.3.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyaxp-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (224.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file pyaxp-0.1.3.tar.gz.

File metadata

  • Download URL: pyaxp-0.1.3.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.1

File hashes

Hashes for pyaxp-0.1.3.tar.gz
Algorithm Hash digest
SHA256 82c1a8ee4ab98153b970227ed2a149254cbaf1ecd0da424f67ad4918929d7e5a
MD5 241896d42d062f90b180fa94edd8e008
BLAKE2b-256 04b4ccd23ccfe90e06a4ee1e146ef8a1c193547eac3c13cfc2c60d92c004d10a

See more details on using hashes here.

File details

Details for the file pyaxp-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyaxp-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80426f47a8ceafb54bb85fd69ac832e5d77d47e4a9ac664851fdda57a87a78d5
MD5 c6f52615dde697030c1b590ede96c2e1
BLAKE2b-256 539180e803c17906fc516d81837ffeb2246a3dae011961c6f2c6d69cfdfa0235

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page