Skip to content

@base ignored in embedded context when remote context is included #175

@balhoff

Description

@balhoff

For this document and jsonld-java 0.8.2:

{
    "@context": [ 
"https://raw.githubusercontent.com/monarch-initiative/monarch-app/master/conf/monarch-context.jsonld",
        {
            "@base": "http://example.org/base/",
            "ex": "http://example.org/",
            "ex:friendOf": {
                "@type": "@id"
            }
        }
    ],
    "@id": "3456",
    "ex:name": "Jim",
    "ex:friendOf": "1234",
    "@type": "Person"
}

The value of @base is not used when calling JsonLdProcessor.expand(). I get this result:

[ {
  "@id" : "3456",
  "@type" : [ "Person" ],
  "http://example.org/friendOf" : [ {
    "@id" : "1234"
  } ],
  "http://example.org/name" : [ {
    "@value" : "Jim"
  } ]
} ]

If I remove the reference to the external context to create this document:

{
    "@context": [ 
        {
            "@base": "http://example.org/base/",
            "ex": "http://example.org/",
            "ex:friendOf": {
                "@type": "@id"
            }
        }
    ],
    "@id": "3456",
    "ex:name": "Jim",
    "ex:friendOf": "1234",
    "@type": "Person"
}

the @base is used to expand IRIs like http://example.org/base/1234:

[ {
  "@id" : "http://example.org/base/3456",
  "@type" : [ "http://example.org/base/Person" ],
  "http://example.org/friendOf" : [ {
    "@id" : "http://example.org/base/1234"
  } ],
  "http://example.org/name" : [ {
    "@value" : "Jim"
  } ]
} ]

Is this expected behavior? This is not the behavior of JSON-LD Playground, which does use the @base from the embedded context when used with a remote context (I posted a question to the JSON-LD mailing list but haven't gotten an answer there). JSON-LD Playground will even make use of @base in a remote context, which seems to be disallowed by the spec: "Please note that the @base will be ignored if used in external contexts."

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions