w3c / json-ld-syntax

JSON-LD 1.1 Specification
https://w3c.github.io/json-ld-syntax/
Other
111 stars 22 forks source link

`"@prefix": false` behavior not specified #339

Closed hsolbrig closed 4 years ago

hsolbrig commented 4 years ago

The spec asserts that one can assert that a de-facto non-prefix should act like a prefix if "@prefix":true, but there is no discussion about the opposite situation. We've got a spec that looks like:

{
  "@context": {
    "an id": "http://example.org/predicate#"
  },
  "an id": true
}

When this is serialized in turtle format using rdflib-jsonld 1.1 branch, it emits:

@prefix an id: <http://example.org/predicate#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

[] an id: true .

Which isn't valid. I try to override it with

{
  "@context": {
    "an id": {"@id": "http://example.org/predicate#", 
              "@prefix": false}
  },
  "an id": true
}

The behavior didn't change. I can't find anything in the spec that does say what the behavior of "@prefix": false should be. Can we clarify (NOT a prefix I hope) so I can request a change in the rdflib code?

gkellogg commented 4 years ago

The spec asserts that one can assert that a de-facto non-prefix should act like a prefix if "@prefix":true, but there is no discussion about the opposite situation.

The API document says that @prefix sets the value of the prefix flag for the associated term definition, which is in turn used when looking for terms to use when either expanding or compacting IRIs.

We've got a spec that looks like:

{
  "@context": {
    "an id": "http://example.org/predicate#"
  },
  "an id": true
}

When this is serialized in turtle format using rdflib-jsonld 1.1 branch, it emits:

@prefix an id: <http://example.org/predicate#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

[] an id: true .

Which isn't valid. I try to override it with

{
  "@context": {
    "an id": {"@id": "http://example.org/predicate#", 
              "@prefix": false}
  },
  "an id": true
}

The behavior didn't change. I can't find anything in the spec that does say what the behavior of "@prefix": false should be. Can we clarify (NOT a prefix I hope) so I can request a change in the rdflib code?

Any interpretation of these IRIs when serializing to Turtle using rdflib is outside the bounds of our specs, which deal with just turning the JSON-LD into RDF Triples/Quads. The library may be making its own decisions by looking at terms in the context and presuming that they can be used as prefixes.

When I serialize this to Turtle using my own processor I come up with the following:

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

 [<http://example.org/predicate#> true] .
hsolbrig commented 4 years ago

So do we remain silent on the "@prefix": false behavior?

gkellogg commented 4 years ago

I think the API doc is clear. I think we can probably add wording in the syntax document to describe this behavior, as it would be editorial, but we can discuss.