goxsd

package module
v0.0.1-r3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2021 License: MIT Imports: 13 Imported by: 0

README

goxsd

Build Status Go Reference

Goxsd is a tool for generating XML decoding Go structs from an XSD schema specification. It does not yet implement the full XSD specificaiton, but goes sufficiently far to be useful for at least some use cases.

Installation

go install github.com/danil/goxsd@v0.0.1-r3

Usage

goxsd will default its output to stdout if an output file name is not given. Apart from a destination file, goxsd also accepts an export flag to toggle generation of exported struct names on (default is to generate unexported structs), and a prefix to be prepended to each struct name.

Any import statement in the XSD will be parsed and followed, interpreting the path as relative to the current XSD file.

Usage: goxsd [options] <xsd_file>

Options:
  -o <file>     Destination file [default: stdout]
  -p <package>  Package name [default: goxsd]
  -e            Generate exported structs [default: false]
  -x <prefix>   Struct name prefix [default: ""]

goxsd is a tool for generating XML decoding/encoding Go structs, according
to an XSD schema.

TODOs

  • Complete handling of more XSD elements is needed

  • XSD namespaces are currently completely ignored, opening for undefined behavior if two namespaces are parsed with conflicting element- or type names.

  • At some point, I would also like to generate validation code, that could check various rules and constraints expressed in the XSD

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuilder

func NewBuilder(schemas []xsdSchema) *builder

NewBuilder creates a new initialized builder populated with the given xsdSchema slice.

func ParseXSDFile

func ParseXSDFile(fname string) ([]xsdSchema, error)

Types

type Generator

type Generator struct {
	Package  string
	Prefix   string
	Exported bool
	// contains filtered or unexported fields
}

Generator is responsible for generating Go structs based on a given XML schema tree.

func (Generator) Do

func (g Generator) Do(out io.Writer, roots []*xmlTree) error

Directories

Path Synopsis
cmd
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL