Skip to content

Commit

Permalink
Propagate backlink to xsd:schema to each and every xsd:element
Browse files Browse the repository at this point in the history
  • Loading branch information
isimluk committed May 25, 2020
1 parent 2e505a7 commit 98f4ace
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/xsd/element.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Element struct {
Name string `xml:"name,attr"`
Ref reference `xml:"ref,attr"`
ComplexType *ComplexType `xml:"complexType"`
schema *Schema `xml:"-"`
}

func (e *Element) Attributes() []Attribute {
Expand All @@ -35,6 +36,7 @@ func (e *Element) XmlName() string {
}

func (e *Element) compile(s *Schema) {
e.schema = s
if e.ComplexType != nil {
// Handle improbable name clash. Consider XSD defining two attributes on the element:
// "id" and "Id", this would create name clash given the camelization we do.
Expand All @@ -50,5 +52,11 @@ func (e *Element) compile(s *Schema) {
// Second GoName may be different depending on the DuplicateCount
goNames[attribute.GoName()] = count
}

elements := e.Elements()
for idx, _ := range elements {
el := &elements[idx]
el.compile(s)
}
}
}

0 comments on commit 98f4ace

Please # to comment.