Skip to main content

Generates XML documents from XSD schemas

Project description

XML Generator

PyPI - Version PyPI - Downloads DeepWiki

Generates XML documents based on XSD schemas with the ability to customize data through a YAML configuration file.

Simplifies the creation of test or demonstration XML data for complex schemas.

Features

  • Generation of XML documents based on XSD schemas
  • Customization of generated values via a YAML configuration file
  • Validation of generated documents
  • Command-line interface for convenient use

Installation

Installation via pip

pip install xmlgenerator

Install executable file manually (linux)

curl -LO https://github.com/lexakimov/xmlgenerator/releases/download/v0.5.3/xmlgenerator-linux-amd64
chmod +x xmlgenerator-linux-amd64
sudo install xmlgenerator-linux-amd64 /usr/local/bin/xmlgenerator

Install shell completions (linux)

# also available: zsh, tcsh
xmlgenerator -C bash | sudo tee /etc/bash_completion.d/xmlgenerator

Usage

The generator command is xmlgenerator

Flags and parameters:

usage: xmlgenerator [-h] [-c <config.yml>] [-o <output.xml>] [-p] [-n alias=namespace] [-v <validation>] [-ff]
                    [-e <encoding>] [-s <seed>] [-d] [-V] [-C <shell>]
                    xsd [xsd ...]

Generates XML documents from XSD schemas

positional arguments:
  xsd                              paths to xsd schema(s) or directory with xsd schemas

options:
  -h, --help                       show this help message and exit
  -c, --config <config.yml>        pass a YAML configuration file
  -o, --output <output.xml>        save the output to a directory or file
  -p, --pretty                     prettify the output XML
  -n, --namespace alias=namespace  define XML namespace alias (repeatable flag)
  -v, --validation <validation>    validate the generated XML document (none, schema, schematron; default: schema)
  -ff, --fail-fast                 terminate execution on a validation error (default: true)
  -e, --encoding <encoding>        the output XML encoding (utf-8, windows-1251; default: utf-8)
  -s, --seed <seed>                set the randomization seed
  -d, --debug                      enable debug mode
  -V, --version                    show the current version
  -C, --completion <shell>         print a shell completion script (bash, zsh, tcsh)

Examples:

  • Generate XML from a single schema and print to console:

    xmlgenerator path/to/your/schema.xsd
    
  • Generate XML from all schemas in a directory and save to the output folder using a configuration file:

    xmlgenerator -c config.yml -o output/ path/to/schemas/
    
  • Generate XML from a specific schema, save to a file with pretty formatting and windows-1251 encoding:

    xmlgenerator -o output.xml -p -e windows-1251 path/to/your/schema.xsd
    
  • Generate XML with validation disabled:

    xmlgenerator -v none path/to/your/schema.xsd
    

Configuration

The generator can be configured using a YAML file passed via the -c or --config option.

Description and examples of configuration are in CONFIGURATION.

Validation

Generated XML documents are checked for conformance against the schema used for generation. By default, validation against the source XSD schema is used.

If a document does not conform to the schema, execution stops immediately. This behavior can be disabled using the flag -ff false or --fail-fast false.

To disable validation, use the flag -v none or --validation none.

Contribution

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Build from source

  1. Clone the repository:

    git clone https://github.com/lexakimov/xmlgenerator.git
    cd xmlgenerator
    
  2. Create and activate a virtual environment (recommended):

    python -m venv .venv
    
    • For Linux/macOS:
      source .venv/bin/activate
      
    • For Windows (Command Prompt/PowerShell):
      .\.venv\Scripts\activate
      
  3. Install dependencies:

    pip install -r requirements.txt
    

4.1. Install the package:

Install in develop mode (code changes will be immediately reflected):

pip install -e .

4.2. Otherwise, build single executable:

python build_native.py

Running Tests

pytest

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contacts

For any questions or issues, please contact [lex.akimov23@gmail.com].

You can also create an Issue on GitHub to report bugs or suggest improvements.

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

xmlgenerator-0.7.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

xmlgenerator-0.7.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file xmlgenerator-0.7.0.tar.gz.

File metadata

  • Download URL: xmlgenerator-0.7.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for xmlgenerator-0.7.0.tar.gz
Algorithm Hash digest
SHA256 f67fd1ce5b2f6c99352a8cef893af650e429628c24df30b94a604a659623c055
MD5 bf542ce0968f18b14f332ab4fc6bac99
BLAKE2b-256 959aa58dd6a23968e1e21fb8141024f4d01821eed2ecf0acbe4e7f3b85709a2d

See more details on using hashes here.

File details

Details for the file xmlgenerator-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: xmlgenerator-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for xmlgenerator-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 83b6fcc083a611ff9b0e648ed58734b9facf8dfbade66ade967bac2f17fbb81a
MD5 faf1b3540afa18d03fa7fb6027a2f80c
BLAKE2b-256 8acd53996c4df96567638a7698f3f860c2699575761348660e446ec664b57541

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