Open jakubklimek opened 4 years ago
I have a similar issue with scoped contexts and IRI expansion using scoped @base
or @vocab
definitions. Only the first scope context is used, the other is ignored. Adding this here, and linking to https://github.com/json-ld/json-ld.org/issues/734 .
To test: two examples. One using @base
and one using @vocab
:
@base
{
"@context": {
"@base": "http://example.com/entity/test/",
"@vocab": "http://example.com/schema/test/",
"b": {
"@context": {
"@base": "http://example.com/test/"
},
"@type": "@id"
},
"a": {
"@context": {
"@base": "http://example.com/test/"
},
"@type": "@id"
}
},
"@id": "justATest",
"b": "1234",
"a": "5678"
}
This should give
But instead gives
@vocab
Different context, now using the @vocab
mechanism... same results:
{
"@context": {
"@base": "http://example.com/entity/test/",
"@vocab": "http://example.com/schema/test/",
"b": {
"@context": {
"@vocab": "http://example.com/test/"
},
"@type": "@vocab"
},
"a": {
"@context": {
"@vocab": "http://example.com/test/"
},
"@type": "@vocab"
}
},
"@id": "justATest",
"b": "1234",
"a": "5678"
}
Results:
@context
Just including the example from the @base
method... This context defines a
first, and then b
. Now the effect is the other way around. The value for a
is properly expanded, and the one for b
isn't.
{
"@context": {
"@base": "http://example.com/entity/test/",
"@vocab": "http://example.com/schema/test/",
"a": {
"@context": {
"@base": "http://example.com/test/"
},
"@type": "@id"
},
"b": {
"@context": {
"@base": "http://example.com/test/"
},
"@type": "@id"
}
},
"@id": "justATest",
"b": "1234",
"a": "5678"
}
Results:
There is probably a bug in handling scoped contexts. This is the same as https://github.com/json-ld/json-ld.org/issues/734 In the snippet below,
začátek
andkonec
(beginning and end in Czech) have equivalent contexts. However, when used in data, they behave differently. Namely the context inkonec
is ignored, while whenzačátek
is used, the context is applied. When thezačátek
definition is removed from the context,konec
starts working. This can be tested in json-ld playground.