- From: Markus Lanthaler <markus.lanthaler@gmx.net>
- Date: Thu, 13 Nov 2014 00:07:00 +0100
- To: <public-hydra@w3.org>
Hi, On 12 Nov 2014 at 20:12, ☮ elf Pavlik ☮ wrote: > On 11/12/2014 06:17 PM, Hendy Irawan wrote: > Hi Hendry, > > To my understanding > >> In the Hydra spec I see hydra being represented as: >> >> 1. "@context": { >> "hydra": "http://www.w3.org/ns/hydra/core#", > namespace / prefix in *local* context so hydra:foo will extend to > http://www.w3.org/ns/hydra/core# Yeah, this defines a prefix "hydra" which is mapped to "http://www.w3.org/ns/hydra/core#". So all compact URLs of the form hydra:suffix will get expanded by a JSON-LD processor to http://www.w3.org/ns/hydra/core#suffix >> 2. "@context": "http://www.w3.org/ns/hydra/context.jsonld", > here we have *remote* context, processor may need to do HTTP request > with Content-Type application/ld+json to get it and then process document As Pavlik said, this references a remote context. That remote context defines terms that you can then directly use in your JSON-LD document (meaning you don't have to use prefixes etc.). You can for example simply write { "@context": "http://www.w3.org/ns/hydra/context.jsonld", "@type": "Collection", "totalItems": 125, "member": [ .... ] } >> 3. "@id": "http://www.w3.org/ns/hydra/core", > URI of hydra core vocabulary itself (!= jsonld context, since any other > RDF serialization can use it) You probably found that in appendix A of the spec [1] which shows the definition of the Hydra vocabulary. It's a bit unfortunate that the properties are reordered, but if you scroll to the end of that appendix you'll see that it is really the vocabulary (or the owl:Ontology) that is being defined here. >> Which one is correct? How does a JSON-LD client knows that (presumably?) >> all three URIs are the same thing? > > so all of them meant something different, and one just need to choose > depending on what one tries to refer to Which one is right, depends on what you want to do. If you want to use prefixes in your JSON-LD document, use the prefix definition shown at the beginning. If you don't want to use prefixes, simply import the remote context by adding either "@context": "http://www.w3.org/ns/hydra/context.jsonld", or "@context": "http://www.w3.org/ns/hydra/core", to your document. Both return exactly the same document. I'm still a bit on the fence myself what's easier to understand for users. I'm currently leaning towards the latter as it is shorter and one URL less to remember. >> If I write a pure Hydra document with a single @context, what should I use: >> >> 1. "@context": "http://www.w3.org/ns/hydra/core#", This is fine, yes. >> 2. "@context": "http://www.w3.org/ns/hydra/context.jsonld", This is basically the same as the one above. It just does an additional HTTP redirection. Both really return the same document and that all that counts for a remote context. >> What's the difference? Effectively there isn't any. >> And which one is "easiest" for a (rather naive) >> client to consume, but still ability to distinguish properties from >> different namespaces? (Without being a "full" compliance to entire spec) How naïve is the client? Is it able to process JSON-LD? If so, there's no difference. If it doesn't, then well... it depends on what you hardcoded into your client :-) HTH, Markus [1] http://www.hydra-cg.com/spec/latest/core/#the-hydra-core-vocabulary-in-json-ld -- Markus Lanthaler @markuslanthaler
Received on Wednesday, 12 November 2014 23:07:30 UTC