- From: Hendy Irawan <ceefour666@gmail.com>
- Date: Thu, 13 Nov 2014 01:23:00 -0430
- To: Markus Lanthaler <markus.lanthaler@gmx.net>
- Cc: public-hydra@w3.org
- Message-ID: <CAAZLYpuqU6VDpTdWHVxi_jDYKsa9gatbVC+OvusZQZDCQ4=a5w@mail.gmail.com>
Thank you Elf, Markus, Peb, wow I didn't expect very detailed responses in
a very short period of time!
I was confused because I thought @context is like namespace URI, but it
turns out there are actually three concepts:
1. Embedded JSON-LD context. "@context": { ...
2. Linked JSON-LD context. "@context": "http://...
3. Vocabulary URI. {"hydra": "http://...
What made it even for confusing is that "http://www.w3.org/ns/hydra/core#"
can serve both as a vocabulary URI *and* a linked JSON-LD context.
The difference would've been clear in a pseudo XML syntax :
<context nsUri="http://www.w3.org/ns/hydra/core#"> // yes
<context nsUri="http://www.w3.org/ns/hydra/c
<http://www.w3.org/ns/hydra/core#>ontext.jsonld"> // no way!
vs
<context src="http://www.w3.org/ns/hydra/core#"> // valid
<context src="http://www.w3.org/ns/hydra/c
<http://www.w3.org/ns/hydra/core#>ontext.jsonld"> // also valid
In JSON representation it's less clear.
Also the first time I look at JSON-LD schema.org examples:
1. <script type="application/ld+json">
2. {
3. "@context" : "http://schema.org",
4. "@type" : "Event",
5. "name" : "Typhoon with Radiation City",
6. "startDate" : "2013-09-14T21:30",
I thought @context is the nsURI, because schema.org's nsURI is "
http://schema.org/" (yes, missing the "/" but to a human's eye it feels the
same.. and in practice, it *is* the same!).
I can confirm that running: curl -v -H 'Accept: application/ld+json' '
http://schema.org'
gives the a JSON-LD context.
(Ironically, running curl -v -H 'Accept: application/rdf+xml' '
http://schema.org/' does *not* give out the schema.org OWL ontology,
neither when using text/turtle)
So... Is it really an idiom to use *exactly* the nsURI as the JSON-LD
context document URI? I'm not sure, but to me ".../context.jsonld" is
clearer and more explicit, both in meaning and visually to a human eye.
For instance:
1. Can an OWL ontology be represented in JSON-LD? (should it?)
2. Assuming it can, what is its media type? Based on RDF/OWL media type
application/rdf+xml, then the OWL JSON-LD media type would be...
application/ld+json (unless one really wants application/owl+ld+json?)
For: curl -v -H 'Accept: application/ld+json' 'http://schema.org/'
Should it return the JSON-LD context, or the JSON-LD representation of the
OWL ontology?
Having context.jsonld seems clearer to me, especially that JSON-LD Context
spec comes *after* OWL spec. In my mind, http://schema.org/ is a website to
humans and an ontology to computers. Not a JSON-LD context...?
Or a JSON-LD context is *actually* an OWL ontology in disguise? Looking at
the Hydra JSON-LD context... this seems to be the case... (?)
... I feel like I'm inside the Matrix ...
I'm currently developing an open e-commerce Hypermedia API that uses both
JSON-LD and Hydra plus common vocabularies (
http://soluvas.github.io/commerceplug/) so I apologize if this discussion
is out-of-place. This discussion seems more relevant to JSON-LD mailing
list than Hydra... In any case, please let me know if you have suggestion.
Thanks very much.
Hendy
Hendy Irawan - on Twitter <http://twitter.com/hendybippo> - on LinkedIn
<http://id.linkedin.com/in/hendyirawan>
Web Developer | Bippo Indonesia <http://www.bippo.co.id/> | Akselerator
Bisnis | Bandung
On Wed, Nov 12, 2014 at 6:37 PM, Markus Lanthaler <markus.lanthaler@gmx.net>
wrote:
> 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 Thursday, 13 November 2014 05:53:28 UTC