Skip to content

Commit

Permalink
Skip export of xsd:complexType that shares the name as existing xsd:e…
Browse files Browse the repository at this point in the history
…lement
  • Loading branch information
isimluk committed May 28, 2020
1 parent de3e50b commit 01e199a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/template/pkged.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/template/types.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ import (


// XSD ComplexType declarations
{{range .ComplexTypes }}
{{range .ExportableComplexTypes }}
type {{ .GoName }} string
{{end}}
16 changes: 16 additions & 0 deletions pkg/xsd/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@ func (sch *Schema) Empty() bool {
return len(sch.Elements) == 0 && len(sch.ComplexTypes) == 0
}

func (sch *Schema) ExportableComplexTypes() []ComplexType {
elCache := map[string]bool{}
for _, el := range sch.Elements {
elCache[el.GoName()] = true
}

var res []ComplexType
for _, typ := range sch.ComplexTypes {
_, found := elCache[typ.GoName()]
if !found {
res = append(res, typ)
}
}
return res
}

func (sch *Schema) GetAttribute(name string) *Attribute {
for idx, attr := range sch.Attributes {
if attr.Name == name {
Expand Down

0 comments on commit 01e199a

Please # to comment.