Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions ld/api_compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func (api *JsonLdApi) Compact(activeCtx *Context, activeProperty string, element
}

// use any scoped context on activeProperty
if td := activeCtx.GetTermDefinition(activeProperty); td != nil && td.hasContext {
newCtx, err := activeCtx.parse(td.context, make([]string, 0), false, true, false, true)
if td := activeCtx.GetTermDefinition(activeProperty); td != nil && td.HasContext {
newCtx, err := activeCtx.parse(td.Context, make([]string, 0), false, true, false, true)
if err != nil {
return nil, err
}
Expand All @@ -68,7 +68,7 @@ func (api *JsonLdApi) Compact(activeCtx *Context, activeProperty string, element

propType := ""
if td := activeCtx.GetTermDefinition(activeProperty); td != nil {
propType = td.typ
propType = td.Type
}
if _, isMap := compactedValue.(map[string]interface{}); !isMap || propType == "@json" {
return compactedValue, nil
Expand Down Expand Up @@ -97,8 +97,8 @@ func (api *JsonLdApi) Compact(activeCtx *Context, activeProperty string, element
}

// apply property-scoped context after reverting term-scoped context
if td := inputCtx.GetTermDefinition(activeProperty); td != nil && td.context != nil {
newCtx, err := activeCtx.parse(td.context, nil, false, true, false, true)
if td := inputCtx.GetTermDefinition(activeProperty); td != nil && td.Context != nil {
newCtx, err := activeCtx.parse(td.Context, nil, false, true, false, true)
if err != nil {
return nil, err
}
Expand All @@ -124,8 +124,8 @@ func (api *JsonLdApi) Compact(activeCtx *Context, activeProperty string, element
// process in lexicographical order, see https://github.com/json-ld/json-ld.org/issues/616
sort.Strings(types)
for _, tt := range types {
if td := inputCtx.GetTermDefinition(tt); td != nil && td.hasContext {
newCtx, err := activeCtx.parse(td.context, nil, false, false, false, false)
if td := inputCtx.GetTermDefinition(tt); td != nil && td.HasContext {
newCtx, err := activeCtx.parse(td.Context, nil, false, false, false, false)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -274,8 +274,8 @@ func (api *JsonLdApi) Compact(activeCtx *Context, activeProperty string, element
}

nestResult := result
if td := activeCtx.GetTermDefinition(itemActiveProperty); td != nil && td.nest != "" {
nestProperty := td.nest
if td := activeCtx.GetTermDefinition(itemActiveProperty); td != nil && td.Nest != "" {
nestProperty := td.Nest
if err := api.checkNestProperty(activeCtx, nestProperty); err != nil {
return nil, err
}
Expand Down Expand Up @@ -304,8 +304,8 @@ func (api *JsonLdApi) Compact(activeCtx *Context, activeProperty string, element
// if itemActiveProperty is a @nest property, add values to nestResult, otherwise result
nestResult := result

if td := activeCtx.GetTermDefinition(itemActiveProperty); td != nil && td.nest != "" {
nestProperty := td.nest
if td := activeCtx.GetTermDefinition(itemActiveProperty); td != nil && td.Nest != "" {
nestProperty := td.Nest
if err := api.checkNestProperty(activeCtx, nestProperty); err != nil {
return nil, err
}
Expand Down Expand Up @@ -475,8 +475,8 @@ func (api *JsonLdApi) Compact(activeCtx *Context, activeProperty string, element
} else if isIndexContainer {

indexKey := "@index"
if td := activeCtx.GetTermDefinition(itemActiveProperty); td != nil && td.index != "" {
indexKey = td.index
if td := activeCtx.GetTermDefinition(itemActiveProperty); td != nil && td.Index != "" {
indexKey = td.Index
}

containerKey, err := activeCtx.CompactIri(indexKey, nil, true, false)
Expand Down
24 changes: 12 additions & 12 deletions ld/api_expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (api *JsonLdApi) Expand(activeCtx *Context, activeProperty string, element
// Get any property-scoped context for activeProperty
var propertyScopedCtx interface{}
if td := activeCtx.GetTermDefinition(activeProperty); td != nil {
propertyScopedCtx = td.context
propertyScopedCtx = td.Context
}

// second, determine if any type-scoped context should be reverted; it
Expand Down Expand Up @@ -182,8 +182,8 @@ func (api *JsonLdApi) Expand(activeCtx *Context, activeProperty string, element
}

for _, tt := range types {
if td := typeScopedContext.GetTermDefinition(tt); td != nil && td.hasContext {
newCtx, err := activeCtx.parse(td.context, nil, false, false, false, false)
if td := typeScopedContext.GetTermDefinition(tt); td != nil && td.HasContext {
newCtx, err := activeCtx.parse(td.Context, nil, false, false, false, false)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -669,10 +669,10 @@ func (api *JsonLdApi) expandObject(activeCtx *Context, activeProperty string, ex
// use potential scoped context for key
termCtx := activeCtx
td := activeCtx.GetTermDefinition(key)
if td != nil && td.hasContext {
if td != nil && td.HasContext {
// TODO: fix calling a private method
//termCtx, err = activeCtx.Parse(ctx)
termCtx, err = activeCtx.parse(td.context, make([]string, 0), false, true, false, true)
termCtx, err = activeCtx.parse(td.Context, make([]string, 0), false, true, false, true)
if err != nil {
return err
}
Expand All @@ -682,7 +682,7 @@ func (api *JsonLdApi) expandObject(activeCtx *Context, activeProperty string, ex
if termCtx.HasContainerMapping(key, "@language") && isMap {
var expandedValueList []interface{}

dir, hasDir := td.direction, td.hasDirection
dir, hasDir := td.Direction, td.HasDirection

for _, language := range GetOrderedKeys(valueMap) {
expandedLanguage, err := termCtx.ExpandIri(language, false, true, nil, nil)
Expand Down Expand Up @@ -710,7 +710,7 @@ func (api *JsonLdApi) expandObject(activeCtx *Context, activeProperty string, ex
if dir != nil {
v["@direction"] = dir
}
} else if defaultDir := termCtx.values.direction; defaultDir != "" {
} else if defaultDir := termCtx.Values.Direction; defaultDir != "" {
v["@direction"] = defaultDir
}
expandedValueList = append(expandedValueList, v)
Expand All @@ -720,8 +720,8 @@ func (api *JsonLdApi) expandObject(activeCtx *Context, activeProperty string, ex
} else if termCtx.HasContainerMapping(key, "@index") && isMap { // 7.6)
asGraph := termCtx.HasContainerMapping(key, "@graph")
indexKey := "@index"
if tdKey := termCtx.GetTermDefinition(key); tdKey != nil && tdKey.index != "" {
indexKey = tdKey.index
if tdKey := termCtx.GetTermDefinition(key); tdKey != nil && tdKey.Index != "" {
indexKey = tdKey.Index
}
var propertyIndex string
if indexKey != "@index" {
Expand Down Expand Up @@ -761,7 +761,7 @@ func (api *JsonLdApi) expandObject(activeCtx *Context, activeProperty string, ex
if err != nil {
return err
}
} else if tdKey != nil && tdKey.typ == "@json" {
} else if tdKey != nil && tdKey.Type == "@json" {
expandedValue = map[string]interface{}{
"@type": "@json",
"@value": value,
Expand Down Expand Up @@ -913,8 +913,8 @@ func (api *JsonLdApi) expandIndexMap(activeCtx *Context, activeProperty string,

indexCtx := activeCtx
// if indexKey is @type, there may be a context defined for it
if td := activeCtx.GetTermDefinition(key); indexKey == "@type" && td != nil && td.hasContext {
newCtx, err := activeCtx.Parse(td.context)
if td := activeCtx.GetTermDefinition(key); indexKey == "@type" && td != nil && td.HasContext {
newCtx, err := activeCtx.Parse(td.Context)
if err != nil {
return nil, err
}
Expand Down
Loading
Loading