Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/outofcoffee/go-xml-example-generator
A Go tool that generates sample XML snippets from XSD schemas. Given an XSD schema and an element name, it produces a valid XML sample that matches the schema's structure.
https://github.com/outofcoffee/go-xml-example-generator
example-generator generator golang xml xml-schema
Last synced: 7 days ago
JSON representation
A Go tool that generates sample XML snippets from XSD schemas. Given an XSD schema and an element name, it produces a valid XML sample that matches the schema's structure.
- Host: GitHub
- URL: https://github.com/outofcoffee/go-xml-example-generator
- Owner: outofcoffee
- License: mit
- Created: 2025-01-09T19:05:40.000Z (8 days ago)
- Default Branch: main
- Last Pushed: 2025-01-10T01:23:17.000Z (8 days ago)
- Last Synced: 2025-01-10T01:31:41.344Z (8 days ago)
- Topics: example-generator, generator, golang, xml, xml-schema
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# go-xml-example-generator [![Build and Test](https://github.com/outofcoffee/go-xml-example-generator/actions/workflows/build.yml/badge.svg)](https://github.com/outofcoffee/go-xml-example-generator/actions/workflows/build.yml)
A Go tool/library that generates example XML snippets from XSD schemas. Given an XSD schema and an element name, it produces a valid XML example that matches the schema's structure.
## Features
- Generates example XML for any element defined in an XSD schema
- Handles complex types with nested elements
- Supports common XSD types (string, int, boolean, date, etc.)## Installation
As a command line tool:
```bash
go install github.com/outofcoffee/go-xml-example-generator@latest
```As a dependency in your Go project:
```bash
go get github.com/outofcoffee/go-xml-example-generator
```## Usage
### Command Line
```bash
go-xml-example-generator [xsd_path] [element_name]
```For example:
```bash
go-xml-example-generator schemas/petstore.xsd getPetByIdResponse
```This will output something like:
```xml42
colour```
### As a Library
```go
import "github.com/outofcoffee/go-xml-example-generator/examplegen"// Generate XML from an XSD file
xml, err := examplegen.Generate("path/to/schema.xsd", "elementName")
if err != nil {
log.Fatal(err)
}
fmt.Println(xml)
```## Building from Source
```bash
git clone https://github.com/outofcoffee/go-xml-example-generator.git
cd go-xml-example-generator
go build
```## Running Tests
```bash
go test ./...
```## Dependencies
- github.com/xuri/xgen - XML schema parser
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)
## Author
[outofcoffee](https://github.com/outofcoffee)