Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xuri/xgen
XSD (XML Schema Definition) parser and Go/C/Java/Rust/TypeScript code generator
https://github.com/xuri/xgen
code-generator ecma-376 generator go golang ooxml ooxml-parser w3c w3c-specification xml xml-parser xml-parsing xsd xsd-schema
Last synced: about 18 hours ago
JSON representation
XSD (XML Schema Definition) parser and Go/C/Java/Rust/TypeScript code generator
- Host: GitHub
- URL: https://github.com/xuri/xgen
- Owner: xuri
- License: bsd-3-clause
- Created: 2019-06-22T13:56:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-22T13:15:45.000Z (5 months ago)
- Last Synced: 2024-12-14T11:04:05.551Z (8 days ago)
- Topics: code-generator, ecma-376, generator, go, golang, ooxml, ooxml-parser, w3c, w3c-specification, xml, xml-parser, xml-parsing, xsd, xsd-schema
- Language: Go
- Homepage:
- Size: 126 KB
- Stars: 340
- Watchers: 18
- Forks: 82
- Open Issues: 31
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-go-extra - xgen - 06-22T13:56:05Z|2022-07-20T14:50:20Z| (Go Generate Tools / Routers)
README
# xgen
## Introduction
xgen is a library written in pure Go providing a set of functions that allow you to parse XSD (XML schema definition) files. This library needs Go version 1.10 or later. The full API docs can be seen using go's built-in documentation tool, or online at [go.dev](https://pkg.go.dev/github.com/xuri/xgen).
`xgen` commands automatically compiles XML schema files into the multi-language type or class declarations code.
Install the command line tool first.
If you're using Go 1.17 and later, installing executables with `go install`
```sh
go install github.com/xuri/xgen/cmd/xgen@latest
```If you're using Go 1.16 and earlier, installing executables with `go get`
```sh
go get -u -v github.com/xuri/xgen/cmd/...
```The command below will walk on the `xsd` path and generate Go language struct code under the `output` directory.
```text
$ xgen -i /path/to/your/xsd -o /path/to/your/output -l Go
```Usage:
```text
$ xgen [ ...] ...
-i Input file path or directory for the XML schema definition
-o Output file path or directory for the generated code
-p Specify the package name
-l Specify the language of generated code (Go/C/Java/Rust/TypeScript)
-h Output this help and exit
-v Output version and exit
```## XSD (XML Schema Definition)
XSD, a recommendation of the World Wide Web Consortium ([W3C](https://www.w3.org)), specifies how to formally describe the elements in an Extensible Markup Language ([XML](https://www.w3.org/TR/xml/)) document. It can be used by programmers to verify each piece of item content in a document. They can check if it adheres to the description of the element it is placed in.
XSD can be used to express a set of rules to which an XML document must conform in order to be considered "valid" according to that schema. However, unlike most other schema languages, XSD was also designed with the intent that determination of a document's validity would produce a collection of information adhering to specific data types. Such a post-validation infoset can be useful in the development of XML document processing software.
## Contributing
Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change. XSD is compliant with [XML Schema Part 1: Structures Second Edition](https://www.w3.org/TR/xmlschema-1/).
## Licenses
This program is under the terms of the BSD 3-Clause License. See [https://opensource.org/licenses/BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause).
Logo is designed by [xuri](https://xuri.me). Licensed under the [Creative Commons 3.0 Attributions license](http://creativecommons.org/licenses/by/3.0/).