Skip to content

@nested node with own vocab has conflicting value overriden #204

@PonteIneptique

Description

@PonteIneptique

From what I gather from the JSON-LD 1.1 specs, there is no problem providing its own @context to a @nested node. Yet, if the parent @context has a conflicting property name, it gets completely ignored in favor of the root vocab:

from pyld import jsonld
import json
JSON = """ {
   "@context": {
    "dublinCore": {
      "@id": "http://foo.bar/dc",
      "@context": {
         "title": "http://purl.org/dc/terms/title"
      }
    },
    "title": "http://foo.bar/title"
   },
    "@id": "http://foo.bar/obj/test",
    "title": "test",
    "dublinCore": {
      "title": "Chapter 1: Jonathan Harker's Journal"
    }
}"""
doc = json.loads(JSON)
nquads = jsonld.to_rdf(doc, options={'format': 'application/n-quads'})
print(nquads)

prints

<http://foo.bar/obj/test> <http://foo.bar/dc> _:b0 .
<http://foo.bar/obj/test> <http://foo.bar/title> "test" .
_:b0 <http://purl.org/dc/terms/title> "Chapter 1: Jonathan Harker's Journal" .

But nested does not care about the vocab

from pyld import jsonld
import json

JSON = """ {
   "@context": {
    "dublinCore": {
      "@id": "@nest",
      "@context": {
         "title": "http://purl.org/dc/terms/title"
      }
    },
    "title": "http://foo.bar/title"
   },
    "@id": "http://foo.bar/obj/test",
    "title": "test",
    "dublinCore": {
      "title": "Chapter 1: Jonathan Harker's Journal"
    }
}"""
doc = json.loads(JSON)
nquads = jsonld.to_rdf(doc, options={'format': 'application/n-quads'})
print(nquads)

and prints

<http://foo.bar/obj/test> <http://foo.bar/title> "Chapter 1: Jonathan Harker's Journal" .
<http://foo.bar/obj/test> <http://foo.bar/title> "test" .

which seems wrong according to the JSON-LD 1.1 specs ?

[Edit: I edited to make the example as light as possible]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions