json-ld / json-ld.org

JSON for Linked Data's documentation and playground site
https://json-ld.org/
Other
856 stars 152 forks source link

improved document @context not parsed correctly in playground #720

Closed James-Hudson3010 closed 4 years ago

James-Hudson3010 commented 4 years ago

I started with this json-ld document:

{
    "@context": {        
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "hr": "http://learningsparql.com/ns/humanResources#",
        "d": "http://learningsparql.com/ns/data#",
        "sh": "http://www.w3.org/ns/shacl#"
    },
    "@id": "hr:ClassShape",
    "@type": "sh:NodeShape",
    "sh:targetSubjectsOf": { "@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" },
    "sh:path": { "@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" },
    "sh:hasValue": { "@id": "http://www.w3.org/2000/01/rdf-schema#Class" },
    "sh:nodeKind": { "@id": "http://www.w3.org/ns/shacl#IRI" }
 }

And wanted to simplify the terms a little, so I used the information found in Example 4 and created:

{
    "@context": {        
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "hr": "http://learningsparql.com/ns/humanResources#",
        "d": "http://learningsparql.com/ns/data#",
        "sh": "http://www.w3.org/ns/shacl#",

        "sh:targetSubjectsOf": { "@type": "@id" },
        "sh:path":             { "@type": "@id" },
        "sh:hasValue":         { "@type": "@id" },
        "sh:nodeKind":         { "@type": "@id" }
    },
    "@id": "hr:ClassShape",
    "@type": "sh:NodeShape",
    "sh:targetSubjectsOf": "rdf:type",
    "sh:path": "rdf:type",
    "sh:hasValue": "rdfs:Class",
    "sh:nodeKind": "sh:IRI"
 }

As best I can determine, they should produce equivalent graphs in https://json-ld.org/playground/, but they do not.

gkellogg commented 4 years ago

They seem to produce the same triples to me. Are you looking at the N-Quads tab results?

James-Hudson3010 commented 4 years ago

I was looking at the "Visualized" tab. The graphs are different.

Perhaps just a quirk of how the graph is created on essentially the same thing.

But, then it is strange that the graph would be different...

gkellogg commented 4 years ago

The visualized tab is showing JSON structure, which could vary wildly between otherwise equivalent graphs. The key is in the generated triples.

Typically the expanded graphs will be equal too, but even then, two different expanded JSON-LD files could result in the same triples.

Framing could be used to normalize the JSON-LD representation, though.