Skip to content

Commit

Permalink
Merge pull request #44 from isimluk/refactor-extract-isElementInlined
Browse files Browse the repository at this point in the history
Refactor: Extact method: isElementInlined
  • Loading branch information
isimluk authored Jan 15, 2022
2 parents 7eb7300 + f41001a commit 448f42d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/xsd/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,16 @@ func (sch *Schema) registerImportedModule(module *Schema) {

// Some elements are not defined at the top-level, rather these are inlined in the complexType definitions
func (sch *Schema) registerInlinedElement(el *Element, parentElement *Element) {
if sch.isElementInlined(el) {
if el.Name == "" {
panic("Not implemented: found inlined xsd:element without @name attribute")
}
el.prefixNameWithParent(parentElement)
sch.inlinedElements = append(sch.inlinedElements, *el)
}
}

func (sch *Schema) isElementInlined(el *Element) bool {
found := false
for idx := range sch.Elements {
e := &sch.Elements[idx]
Expand All @@ -272,13 +282,7 @@ func (sch *Schema) registerInlinedElement(el *Element, parentElement *Element) {
break
}
}
if !found {
if el.Name == "" {
panic("Not implemented: found inlined xsd:element without @name attribute")
}
el.prefixNameWithParent(parentElement)
sch.inlinedElements = append(sch.inlinedElements, *el)
}
return !found
}

type Import struct {
Expand Down

0 comments on commit 448f42d

Please # to comment.