W3C home > Mailing lists > Public > public-linked-json@w3.org > August 2014

Re: Relative IRI in @context?

From: Gregg Kellogg <gregg@greggkellogg.net>
Date: Mon, 4 Aug 2014 12:40:05 -0700
Cc: JSON-LD <public-linked-json@w3.org>
Message-Id: <94EB76F6-ADE1-4E89-8484-F904E840F674@greggkellogg.net>
To: Sebastian Heath <sebastian.heath@gmail.com>
On Aug 4, 2014, at 11:01 AM, Sebastian Heath <sebastian.heath@gmail.com> wrote:

> Hi,
> 
> This may be a quick thread since perhaps I'm doing something wrong, but...
> 
> I'd like to use a relative URI in @context. As in,
> 
> {
> 
> "@context": "context.jsonld",
> 
> "@graph": [ ... rest of the jsonld ... ]
> 
> }

Yes, this is legitimate; if you see processing step 3.2.1 of the Context Processing Algorithm [1]:

[[[
Set context to the result of resolving value against the base IRI ...
]]]

So, in this case, "context.jsonld" is resolved relative to the BASE IRI of the document containing it.

> When I use the jsonld command line tool from the node package I get
> 
> 'jsonld.NormalizeError: Could not convert input to RDF dataset before
> normalization.'
> 
> The file is otherwise valid JSON and it works when I stick in a
> fully-qualified IRI.

As you can see, the problem is that when using a command line tool, the document has no BASE IRI. It may be that the tool gives you the option of establishing one.

> context.jsonld is a file on the local file system. Is there a better
> way to specify it? I've also served it via python's simple http server
> but also no luck using a relative IRI in @context.

If you were to use the Ruby JSON-LD CLI, you could do this with the following:

    jsonld --uri 'file:/"`pwd` input.jsonld

Other tools may give you different options.

> Use case is pretty straightforward in terms of sharing a context
> among many files in a directory that can easily be served by just it
> on a server. I do not want to have to set up a permanent IRI for the
> context as that would mean it couldn't move with the files.
> 
> Or am I doing something obviously wrong?

Gregg

[1] http://www.w3.org/TR/json-ld-api/#context-processing-algorithm

> Thanks,
> 
> Sebastian.
> 
Received on Monday, 4 August 2014 19:40:36 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:42 UTC