Skip to content

Commit

Permalink
Fixes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
c4milo committed Sep 12, 2015
1 parent bcc9cd0 commit 4f7aad4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 41 deletions.
1 change: 0 additions & 1 deletion gowsdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ func (g *GoWSDL) genTypes() ([]byte, error) {
"replaceReservedWords": replaceReservedWords,
"makePublic": makePublic,
"comment": comment,
"targetNamespace": func() string { return g.wsdl.TargetNamespace },
}

//TODO resolve element refs in place.
Expand Down
78 changes: 38 additions & 40 deletions types_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,6 @@ var typesTmpl = `
Value {{toGoType .Extension.Base}}{{template "Attributes" .Extension.Attributes}}
{{end}}
{{define "ComplexTypeGlobal"}}
{{$name := replaceReservedWords .Name | makePublic}}
type {{$name}} struct {
XMLName xml.Name ` + "`xml:\"{{targetNamespace}} {{.Name}}\"`" + `
{{if ne .ComplexContent.Extension.Base ""}}
{{template "ComplexContent" .ComplexContent}}
{{else if ne .SimpleContent.Extension.Base ""}}
{{template "SimpleContent" .SimpleContent}}
{{else}}
{{template "Elements" .Sequence}}
{{template "Elements" .Choice}}
{{template "Elements" .SequenceChoice}}
{{template "Elements" .All}}
{{template "Attributes" .Attributes}}
{{end}}
}
{{end}}
{{define "ComplexTypeLocal"}}
{{$name := .Name}}
{{with .ComplexType}}
type {{$name | replaceReservedWords | makePublic}} struct {
XMLName xml.Name ` + "`xml:\"{{targetNamespace}} {{$name}}\"`" + `
{{if ne .ComplexContent.Extension.Base ""}}
{{template "ComplexContent" .ComplexContent}}
{{else if ne .SimpleContent.Extension.Base ""}}
{{template "SimpleContent" .SimpleContent}}
{{else}}
{{template "Elements" .Sequence}}
{{template "Elements" .Choice}}
{{template "Elements" .SequenceChoice}}
{{template "Elements" .All}}
{{template "Attributes" .Attributes}}
{{end}}
}
{{end}}
{{end}}
{{define "ComplexTypeInline"}}
{{replaceReservedWords .Name | makePublic}} struct {
{{with .ComplexType}}
Expand All @@ -103,16 +65,52 @@ var typesTmpl = `
{{end}}
{{range .Schemas}}
{{ $targetNamespace := .TargetNamespace }}
{{range .SimpleType}}
{{template "SimpleType" .}}
{{end}}
{{range .Elements}}
{{if not .Type}}
{{template "ComplexTypeLocal" .}}
{{/* ComplexTypeLocal */}}
{{$name := .Name}}
{{with .ComplexType}}
type {{$name | replaceReservedWords | makePublic}} struct {
XMLName xml.Name ` + "`xml:\"{{$targetNamespace}} {{$name}}\"`" + `
{{if ne .ComplexContent.Extension.Base ""}}
{{template "ComplexContent" .ComplexContent}}
{{else if ne .SimpleContent.Extension.Base ""}}
{{template "SimpleContent" .SimpleContent}}
{{else}}
{{template "Elements" .Sequence}}
{{template "Elements" .Choice}}
{{template "Elements" .SequenceChoice}}
{{template "Elements" .All}}
{{template "Attributes" .Attributes}}
{{end}}
}
{{end}}
{{end}}
{{end}}
{{range .ComplexTypes}}
{{template "ComplexTypeGlobal" .}}
{{/* ComplexTypeGlobal */}}
{{$name := replaceReservedWords .Name | makePublic}}
type {{$name}} struct {
XMLName xml.Name ` + "`xml:\"{{$targetNamespace}} {{.Name}}\"`" + `
{{if ne .ComplexContent.Extension.Base ""}}
{{template "ComplexContent" .ComplexContent}}
{{else if ne .SimpleContent.Extension.Base ""}}
{{template "SimpleContent" .SimpleContent}}
{{else}}
{{template "Elements" .Sequence}}
{{template "Elements" .Choice}}
{{template "Elements" .SequenceChoice}}
{{template "Elements" .All}}
{{template "Attributes" .Attributes}}
{{end}}
}
{{end}}
{{end}}
`

0 comments on commit 4f7aad4

Please sign in to comment.