Skip to content

Commit

Permalink
Process xsd:element tags
Browse files Browse the repository at this point in the history
  • Loading branch information
isimluk committed May 20, 2020
1 parent 1935fd9 commit 3e58783
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 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.

8 changes: 7 additions & 1 deletion pkg/template/types.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// Code generated by https://github.com/gocomply/xsd2go; DO NOT EDIT.
{{$packageName := .GoPackageName -}}
package {{ $packageName }}
// TODO

{{range .Elements }}
// Element
type {{ .Name }} struct {
}

{{end}}
11 changes: 11 additions & 0 deletions pkg/xsd/element.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package xsd

import (
"encoding/xml"
)

// Element defines single XML element
type Element struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema element"`
Name string `xml:"name,attr"`
}
5 changes: 3 additions & 2 deletions pkg/xsd/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

// Schema is the root XSD element
type Schema struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema schema"`
TargetNamespace string `xml:"targetNamespace,attr"`
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema schema"`
TargetNamespace string `xml:"targetNamespace,attr"`
Elements []Element `xml:"element"`
}

func Parse(r io.Reader) (*Schema, error) {
Expand Down

0 comments on commit 3e58783

Please # to comment.