Re: Relative IRI in @context?

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