JSON-LD representation of all examples is invalid
pietercolpaert opened this issue · 9 comments
When parsing any example in the smart data models space, I get:
Failed to retrieve https://smart-data-models.github.io/dataModel.Transportation/BikeHireDockingStation/examples/example.jsonld: Error: IRIs can not be mapped to other IRIs, found: 'CCS/SAE': 'https://uri.fiware.org/ns/data-models#CCS/SAE'
How to resolve: fix the context in https://schema.lab.fiware.org/ld/context.jsonld
to not include a relative IRI as a property.
Suggestion on how to avoid regressions in the future: have a unit test with pre-commit hook in the repos to test the JSON-LD and assert a couple of triples to emit when parsing the JSON-LD files to RDF.
Is the problem URIs of the type 'https://uri.fiware.org? (It really takes you nowhere)
No, that would be good thing to fix, but it’s not the cause of this bug that breaks the use of the Smart Data Models in any Linked Data client. The root cause is the default fiware context is invalid JSON-LD due to a property that is interpreted as a relative URI is being mapped to another URI.
Please check the validity of your LD documents before any commit.
You can use the npm library json-ld or rdf-parse for that (if you also want to support other RDF serializations).
Test it yourself from the browser here: https://rdf-play.rubensworks.net/#url=https%3A%2F%2Fsmart-data-models.github.io%2FdataModel.Transportation%2FBikeHireDockingStation%2Fexamples%2Fexample.jsonld&proxy=https%3A%2F%2Fproxy.linkeddatafragments.org%2F
I guess you mean that extended terms cannot be a relative location into another file like most, if not all, of the terms in the context?
so instead of having
https://uri.fiware.org/ns/data-models#StreetlightModel
it should be i.e.
https://uri.fiware.org/ns/data-models/StreetlightModel
am I right?
https://uri.fiware.org/ns/data-models#xxx
is fine ✅https://uri.fiware.org/ns/data-models#xxx/yyy
is not. ❌https://uri.fiware.org/ns/data-models/xxx
is fine ✅https://uri.fiware.org/ns/data-models/xxx/yyy
is a bit weird but is also legal. ✅
Best to stick to one element at the end so you can create the @context
as shown:
{
"@context": {
"type": "@type",
"id": "@id",
"fiware": "https://uri.fiware.org/ns/data-models#",
"Building": "fiware:Building",
"Device": "fiware:Device",
... etc
}
https://uri.fiware.org/ns/data-models#xxx/yyy
is not. x
No, this is also a valid URI (RFC3986). The problem only lies in your use of JSON-LD, where in the context you use a label that is mistaken for a relative URI.
The problem only lies in your use of JSON-LD, where in the context you use a label that is mistaken for a relative URI.
OK, so it's the key that is the issue, not the value.
I guess there were four keys (all of them coming from the old context). @pietercolpaert could check it again?
Houray! It works now indeed!
Unrelated to this issue (which I’ll close now) is that the Linked Data itself from these examples contain quite some issues and if you want to call this NGSI-LD it would be nice if this would be given a bit more love so that Linked Data agents can actual query across these subject pages :) Check for example https://rdf-play.rubensworks.net/#url=https%3A%2F%2Fsmart-data-models.github.io%2FdataModel.Transportation%2FBikeHireDockingStation%2Fexamples%2Fexample.jsonld&proxy=https%3A%2F%2Fproxy.linkeddatafragments.org%2F