Skip to content

Commit

Permalink
golang: Include compact type name in blank nodes
Browse files Browse the repository at this point in the history
If a compact type is available, use in the name of the blank nodes to
make them easier to read
  • Loading branch information
JPEWdev committed Jan 16, 2025
1 parent 870b21f commit ad858c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/shacl2code/lang/templates/golang/shaclobjectset.go.j2
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ func (self *SHACLObjectSetObject) Encode(encoder *json.Encoder) error {
continue
}

o.ID().Set(fmt.Sprintf("_:%d", blank_count))

o.ID().Set(fmt.Sprintf("_:%s%d", o.GetType().GetCompactTypeIRI().GetDefault(""), blank_count))
blank_count += 1
top_objects[o] = true
}
Expand Down
3 changes: 2 additions & 1 deletion tests/expect/golang/context/test-context/shaclobjectset.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ func (self *SHACLObjectSetObject) Encode(encoder *json.Encoder) error {
continue
}

o.ID().Set(fmt.Sprintf("_:%d", blank_count))

o.ID().Set(fmt.Sprintf("_:%s%d", o.GetType().GetCompactTypeIRI().GetDefault(""), blank_count))
blank_count += 1
top_objects[o] = true
}
Expand Down
3 changes: 2 additions & 1 deletion tests/expect/golang/nocontext/test/shaclobjectset.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ func (self *SHACLObjectSetObject) Encode(encoder *json.Encoder) error {
continue
}

o.ID().Set(fmt.Sprintf("_:%d", blank_count))

o.ID().Set(fmt.Sprintf("_:%s%d", o.GetType().GetCompactTypeIRI().GetDefault(""), blank_count))
blank_count += 1
top_objects[o] = true
}
Expand Down

0 comments on commit ad858c4

Please sign in to comment.