Skip to content

Commit

Permalink
strengthent xpath using ids instead of names
Browse files Browse the repository at this point in the history
  • Loading branch information
Frode Sjovatsen committed Aug 15, 2017
1 parent 3a457a4 commit 4e09f49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions common/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func getRelations(doc *xmlquery.Node, c *xmlquery.Node) []string {
return assocs
}

// TODO: This is actualy iterativ and not recursive. This should probably be fixed in the future.
func getRecursivelyAssociationsFromExtends(doc *xmlquery.Node, c *xmlquery.Node) []string {
var assocs []string
extAssocs, extends := getAssociationsFromExtends(doc, c)
Expand All @@ -257,7 +258,7 @@ func getRecursivelyAssociationsFromExtends(doc *xmlquery.Node, c *xmlquery.Node)

func getAssociationsFromExtends(doc *xmlquery.Node, c *xmlquery.Node) ([]string, *xmlquery.Node) {
var assocs []string
extends := xmlquery.Find(doc, fmt.Sprintf("//connectors/connector/properties[@ea_type='Generalization']/../source/model[@name='%s']/../../target/model[@name]", c.SelectAttr("name")))
extends := xmlquery.Find(doc, fmt.Sprintf("//connectors/connector/properties[@ea_type='Generalization']/../source[@idref='%s']/../target", c.SelectAttr("idref")))
if len(extends) == 1 {
assocs = append(assocs, getAssociations(doc, extends[0])...)
return assocs, extends[0]
Expand All @@ -268,12 +269,12 @@ func getAssociationsFromExtends(doc *xmlquery.Node, c *xmlquery.Node) ([]string,

func getAssociations(doc *xmlquery.Node, c *xmlquery.Node) []string {
var assocs []string
for _, rr := range xmlquery.Find(doc, fmt.Sprintf("//connectors/connector/properties[@ea_type='Association']/../source/model[@name='%s']/../../target/role", c.SelectAttr("name"))) {
for _, rr := range xmlquery.Find(doc, fmt.Sprintf("//connectors/connector/properties[@ea_type='Association']/../source[@idref='%s']/../target/role", c.SelectAttr("idref"))) {
if len(rr.SelectAttr("name")) > 0 {
assocs = append(assocs, strings.ToUpper(replaceNO(rr.SelectAttr("name"))))
}
}
for _, rl := range xmlquery.Find(doc, fmt.Sprintf("//connectors/connector/properties[@ea_type='Association']/../target/model[@name='%s']/../../source/role", c.SelectAttr("name"))) {
for _, rl := range xmlquery.Find(doc, fmt.Sprintf("//connectors/connector/properties[@ea_type='Association']/../target[@idref='%s']/../source/role", c.SelectAttr("idref"))) {
if len(rl.SelectAttr("name")) > 0 {
assocs = append(assocs, strings.ToUpper(replaceNO(rl.SelectAttr("name"))))
}
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

const Name string = "fint-model"
const Version string = "1.1.0"
const Version string = "1.1.2"

0 comments on commit 4e09f49

Please sign in to comment.