Re: Relative URI Handling in JSON-LD

> On Sep 27, 2017, at 5:26 PM, Kingsley Idehen <kidehen@openlinksw.com> wrote:
> 
> On 9/27/17 4:47 PM, Gregg Kellogg wrote:
>> JSON-LD will require expanded IRIs to be absolute (as does an N-Triples transformation of Turtle). The “base”: “” overrides to document location, and inhibits the creation of absolute IRIs. While you should be able to do this, the result won’t be valid expanded JSON-LD or RDF.
>> 
>> Gregg
> 
> Gregg,
> 
> Okay, so what about the following which also doesn't work (note same
> approach works for @id key where value is "#BrewEats":
> 
> {
>   "@context":
>   {
>      "schema": "http://schema.org/ <http://schema.org/>",
>     "@base": "#" 
>   },
>     "@id": "#BrewEats",
>     "@type": "schema:Restaurant",
>     "schema:name": "Brew Eats",
>     "databaseId": "23987520”
> }

About the best you can do is the following:

{
  "@context":
  {
     "schema": "http://schema.org/",
    "@base": “",
    "@vocab": "_:"
  },
    "@id": "#BrewEats",
    "@type": "schema:Restaurant",
    "schema:name": "Brew Eats",
    "databaseId": "23987520"
}

My implementation (http://rdf.greggkellogg.net/distiller?command=expand&format=jsonld&output_format=jsonld <http://rdf.greggkellogg.net/distiller?command=expand&format=jsonld&output_format=jsonld>), accepts “@base”: “#” (or “”), but the javascript version does not. To not loose databaseid, you need to set “@vocab”, but this must be an absolute IRI or  a BNode (for prefixing values), otherwise, the property is ignored. Getting “Breweats” out as a relative URI seems to work reasonably consistently across at least, as it is document relative.

Note that, without setting “@base”, a processor will use the document location for setting values of “@id” and other values which are evaluated as URIs.

Turtle, I believe, don’t impose the same requirement on properties being absolute IRIs, but JSON-LD may often be used to extract data from a document for which some JSON is ignored. A pending issue #333 [2] would provide some support for preserving unmapped JSON as a typed literal, and this should make it into the 1.1 CG work, but I don’t believe it would address this particular use case.

Is there some specific reason to want to use document-relative properties? With enough support, we could consider it for 1.1, but I’m not clear on a real-world use case. Relative values of “@id” seem to be reasonably well supported, even if the result is considered invalid.

Gregg

> [1]
> http://kingsley.idehen.net/DAV/home/kidehen/Public/Linked%20Data%20Documents/Nanotations/basic-test2.txt <http://kingsley.idehen.net/DAV/home/kidehen/Public/Linked%20Data%20Documents/Nanotations/basic-test2.txt>
> -- updated test doc reflecting the example above.

[2] https://github.com/json-ld/json-ld.org/issues/333 <https://github.com/json-ld/json-ld.org/issues/333>

> Kingsley 
> 
> 
>> On Sep 27, 2017, at 1:20 PM, Kingsley Idehen <kidehen@openlinksw.com> wrote:
>>> All,
>>> 
>>> Can anyone shed light on the ability to use relative HTTP URIs to
>>> identify relations (keys in json parlance) via JSON-LD [1] ?
>>> 
>>> I have an RDF-Turtle example that I am struggling to replicate in JSON-LD.
>>> 
>>> Links:
>>> 
>>> [1] https://twitter.com/kidehen/status/913134180317515777 -- depicts the
>>> dilemma I've encountered
>>> 
>>> [2]
>>> http://kingsley.idehen.net/DAV/home/kidehen/Public/Linked%20Data%20Documents/Nanotations/basic-test2.txt
>>> -- sample
>>> 
>>> -- 
>>> Regards,
>>> 
>>> Kingsley Idehen          
>>> Founder & CEO 
>>> OpenLink Software   (Home Page: http://www.openlinksw.com)
>>> 
>>> Weblogs (Blogs):
>>> Legacy Blog: http://www.openlinksw.com/blog/~kidehen/
>>> Blogspot Blog: http://kidehen.blogspot.com
>>> Medium Blog: https://medium.com/@kidehen
>>> 
>>> Profile Pages:
>>> Pinterest: https://www.pinterest.com/kidehen/
>>> Quora: https://www.quora.com/profile/Kingsley-Uyi-Idehen
>>> Twitter: https://twitter.com/kidehen
>>> Google+: https://plus.google.com/+KingsleyIdehen/about
>>> LinkedIn: http://www.linkedin.com/in/kidehen
>>> 
>>> Web Identities (WebID):
>>> Personal: http://kingsley.idehen.net/public_home/kidehen/profile.ttl#i
>>>       : http://id.myopenlink.net/DAV/home/KingsleyUyiIdehen/Public/kingsley.ttl#this
>>> 
>>> 
>> 
> 
> -- 
> Regards,
> 
> Kingsley Idehen       
> Founder & CEO 
> OpenLink Software   (Home Page: http://www.openlinksw.com <http://www.openlinksw.com/>)
> 
> Weblogs (Blogs):
> Legacy Blog: http://www.openlinksw.com/blog/~kidehen/ <http://www.openlinksw.com/blog/~kidehen/>
> Blogspot Blog: http://kidehen.blogspot.com <http://kidehen.blogspot.com/>
> Medium Blog: https://medium.com/@kidehen <https://medium.com/@kidehen>
> 
> Profile Pages:
> Pinterest: https://www.pinterest.com/kidehen/ <https://www.pinterest.com/kidehen/>
> Quora: https://www.quora.com/profile/Kingsley-Uyi-Idehen <https://www.quora.com/profile/Kingsley-Uyi-Idehen>
> Twitter: https://twitter.com/kidehen <https://twitter.com/kidehen>
> Google+: https://plus.google.com/+KingsleyIdehen/about <https://plus.google.com/+KingsleyIdehen/about>
> LinkedIn: http://www.linkedin.com/in/kidehen <http://www.linkedin.com/in/kidehen>
> 
> Web Identities (WebID):
> Personal: http://kingsley.idehen.net/public_home/kidehen/profile.ttl#i <http://kingsley.idehen.net/public_home/kidehen/profile.ttl#i>
>        : http://id.myopenlink.net/DAV/home/KingsleyUyiIdehen/Public/kingsley.ttl#this <http://id.myopenlink.net/DAV/home/KingsleyUyiIdehen/Public/kingsley.ttl#this>

Received on Friday, 29 September 2017 23:30:27 UTC