xsd

package module
v0.0.0-...-8341fb0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: BSD-2-Clause Imports: 11 Imported by: 0

README

xsd: XML tagged struct generator for Go

xsd is a Go package that generates tagged struct from XML Schema (xsd). When only the XML file is available, an xsd file can be automatically generated by a XML Schema learner, such as "github.com/kore/XML-Schema-learner".

Documentation

Overview

Doc: http://www.w3schools.com/schema/schema_elements_ref.asp

It is convecient to be used together with a XML Schema learner like: github.com/kore/XML-Schema-learner

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type All

type All struct {
	Elements []Element `xml:"element"`
}

type Annotation

type Annotation struct {
	Documentation string `xml:"documentation"`
}

type Attribute

type Attribute struct {
	Id         string      `xml:"id,attr"`
	Name       string      `xml:"name,attr"`
	Type       string      `xml:"type,attr"`
	Use        string      `xml:"use,attr"`
	Ref        string      `xml:"ref,attr"`
	SimpleType *SimpleType `xml:"simpleType"`
	Annotation Annotation  `xml:"annotation"`
}

func (Attribute) Field

func (a Attribute) Field(namespace string) *ast.Field

func (Attribute) GoName

func (a Attribute) GoName() string

func (Attribute) GoType

func (a Attribute) GoType(namespace string) string

type AttributeGroup

type AttributeGroup struct {
	Attributes      Attributes       `xml:"attribute"`
	AttributeGroups []AttributeGroup `xml:"attributeGroup"`
}

type Attributes

type Attributes []Attribute

type BSONNodeType

type BSONNodeType int
const (
	BSONNormal BSONNodeType = iota
	BSONInline
	BSONOmitted
)

type BSONTag

type BSONTag struct {
	Type      BSONNodeType
	Name      string
	Omitempty bool
}

func (BSONTag) String

func (t BSONTag) String() string

type Choice

type Choice struct {
	Id        string     `xml:"id,attr"`
	Elements  []Element  `xml:"element"`
	Groups    []Group    `xml:"group"`
	Choices   []Choice   `xml:"choice"`
	Sequences []Sequence `xml:"sequence"`
}

func (Choice) Fields

func (c Choice) Fields(plural bool) []*ast.Field

type ComplexType

type ComplexType struct {
	Id              string           `xml:"id,attr"`
	Name            string           `xml:"name,attr"`
	Groups          []Group          `xml:"group"`
	All             []All            `xml:"all"`
	Choices         []Choice         `xml:"choice"`
	Sequences       []Sequence       `xml:"sequence"`
	Attributes      Attributes       `xml:"attribute"`
	AttributeGroups []AttributeGroup `xml:"attributeGroup"`
	SimpleContent   *SimpleContent   `xml:"simpleContent"`
	Annotation      Annotation       `xml:"annotation"`
}

func (ComplexType) Decls

func (t ComplexType) Decls() []ast.Decl

func (ComplexType) GoName

func (t ComplexType) GoName() string

func (ComplexType) TypeName

func (t ComplexType) TypeName() string

type ComplexTypes

type ComplexTypes []ComplexType

type Element

type Element struct {
	Id          string       `xml:"id,attr"`
	Name        string       `xml:"name,attr"`
	Type        string       `xml:"type,attr"`
	ComplexType *ComplexType `xml:"complexType"`
	MinOccurs   string       `xml:"minOccurs,attr"`
	MaxOccurs   string       `xml:"maxOccurs,attr"`
	Annotation  Annotation   `xml:"annotation"`
}

func (Element) Field

func (e Element) Field(plural bool) *ast.Field

func (Element) GoName

func (e Element) GoName() string

func (Element) GoType

func (e Element) GoType() string

type Enumeration

type Enumeration struct {
	Value string `xml:"value,attr"`
}

type Enumerations

type Enumerations []Enumeration

type Extension

type Extension struct {
	Base       string     `xml:"base,attr"`
	Attributes Attributes `xml:"attribute"`
}

type Group

type Group struct {
	Choices   []Choice   `xml:"choice"`
	Sequences []Sequence `xml:"sequence"`
}

type JSONNodeType

type JSONNodeType int
const (
	JSONNormal JSONNodeType = iota
	JSONOmitted
)

type JSONTag

type JSONTag struct {
	Type      JSONNodeType
	Name      string
	Omitempty bool
}

func (JSONTag) String

func (t JSONTag) String() string

type KV

type KV struct {
	Key   string
	Value string
}

type List

type List struct {
}

type Notation

type Notation struct {
}

type Restriction

type Restriction struct {
	Base         string       `xml:"base,attr"`
	Enumerations Enumerations `xml:"enumeration"`
}

type Schema

type Schema struct {
	XMLName         xml.Name         `xml:"schema"`
	SimpleTypes     []SimpleType     `xml:"simpleType"`
	ComplexTypes    ComplexTypes     `xml:"complexType"`
	Groups          []Group          `xml:"group"`
	Attributes      Attributes       `xml:"attribute"`
	AttributeGroups []AttributeGroup `xml:"attributeGroup"`
	Elements        []Element        `xml:"element"`
	Notations       []Notation       `xml:"notation"`
	Annotations     []Annotation     `xml:"annotation"`
}

func (*Schema) Ast

func (s *Schema) Ast(name string) *ast.File

type Sequence

type Sequence struct {
	Id        string     `xml:"id,attr"`
	Elements  []Element  `xml:"element"`
	Groups    []Group    `xml:"group"`
	Choices   []Choice   `xml:"choice"`
	Sequences []Sequence `xml:"sequence"`
	MinOccurs string     `xml:"minOccurs,attr"`
	MaxOccurs string     `xml:"maxOccurs,attr"`
}

func (Sequence) Fields

func (s Sequence) Fields(plural bool) []*ast.Field

type SimpleContent

type SimpleContent struct {
	Extension Extension `xml:"extension"`
}

func (*SimpleContent) Fields

func (s *SimpleContent) Fields(namespace string) []*ast.Field

type SimpleType

type SimpleType struct {
	Id          string       `xml:"id,attr"`
	Name        string       `xml:"name,attr"`
	Restriction *Restriction `xml:"restriction"`
	List        *List        `xml:"list"`
	Union       *Union       `xml:"union"`
}

type Type

type Type interface {
	TypeName() string
	Decls() []ast.Decl
}

type Types

type Types []Type

func (Types) Len

func (a Types) Len() int

func (Types) Less

func (a Types) Less(i, j int) bool

func (Types) Swap

func (a Types) Swap(i, j int)

type Union

type Union struct {
}

type XMLNodeType

type XMLNodeType int
const (
	XMLElement XMLNodeType = iota
	XMLAttr
	XMLCharData
	XMLInnerXML
	XMLComment
	XMLOmitted
)

type XMLTag

type XMLTag struct {
	Type      XMLNodeType
	Name      string
	Omitempty bool
}

func ParseXMLTag

func ParseXMLTag(s string) XMLTag

func (XMLTag) String

func (t XMLTag) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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