- From: Markus Lanthaler <markus.lanthaler@gmx.net>
- Date: Sun, 15 Dec 2013 13:16:36 +0100
- To: "'Alexander Dutton'" <alexander.dutton@oucs.ox.ac.uk>, "'Alexander Dutton'" <alexander.dutton@it.ox.ac.uk>
- Cc: <public-lod@w3.org>
Hi Alex, On Sunday, December 15, 2013 12:46 PM, Alexander Dutton wrote: > Morning, > > I'm playing with adding extra bits to a HAL document > (http://stateless.co/hal_specification.html), so that I can get some > RDF linked data out of it. Here's an example HAL document: > > > { > > "label": "happy", > > "_links": { > > "self": {"href": "http://example.com/happy"}, > > "narrower": {"href": "http://example.com/ecstatic"} > > } > > } Could you explain what triples you would like to get out of this > I can then extend this to look like: > > > { > > "@context": { > > "skos": "http://www.w3.org/2004/02/skos/core#", > > "label": "skos:prefLabel", > > "narrower": "skos:narrower", > > }, > > "@id": "http://id.example.com/happy", > > "@type": "skos:Concept", > > "label": "happy", > > "_links": { > > "self": { > > "@id": "http://id.example.com/happy", > > "href": "http://example.com/happy" > > }, > > "narrower": { > > "@id": "http://id.example.com/ecstatic", > > "href": "http://example.com/ecstatic" > > }, > > } > > } > > The point is that the document should still be meaningful to HAL > clients, which can ignore the extra @context, @id and @type properties. > > However, I don't know how to get a JSON-LD parser past the "_links" > key. The link relation types (i.e., the predicates) would be lost because they are outside your link objects. You thus need to duplicate them again inside the link objects. The other trick you need to use is to map "_links" to a blank node and set its container to @index so that doesn't get ignored. The triples containing blank nodes as predicate are discarded (unless you set a special flag) by default when converting to RDF. Your document would then look as follows: { "@context": { "skos": "http://www.w3.org/2004/02/skos/core#", "_links": { "@id": "_:links", "@container": "@index" }, "label": "skos:prefLabel", "narrower": { "@id": "skos:narrower", "@type": "@id" } }, "@id": "http://id.example.com/happy", "@type": "skos:Concept", "label": "happy", "_links": { "self": { "href": "http://example.com/happy" }, "narrower": { "@id": "http://id.example.com/happy", "narrower": "http://example.com/ecstatic", "href": "http://example.com/ecstatic" } } } Which results in the following triples: <http://id.example.com/happy> rdf:typy skos:Concept . <http://id.example.com/happy> skos:prefLabel "happy" . <http://id.example.com/happy> skos:narrower <http://example.com/ecstatic> . Is assume this is what you wanted to achieve, right? It would be much simple though to just ignore the _links property altogether and duplicate the links directly in the object itself: { "@context": { "skos": "http://www.w3.org/2004/02/skos/core#", "label": "skos:prefLabel", "narrower": { "@id": "skos:narrower", "@type": "@id" } }, "@id": "http://id.example.com/happy", "@type": "skos:Concept", "label": "happy", "narrower": "http://example.com/ecstatic", "_links": { "self": {"href": "http://example.com/happy"}, "narrower": {"href": "http://example.com/ecstatic"} } } > As far as we're concerned it's meaningless and its children > could/should > be included one level up (but that result in the document no longer > being HAL). I thought {"@container": "@index"} might be the answer, but > that means that /the current key has meaning, and its children don't/, > which is the wrong way round for my use case. > > Is there an answer? I hope I gave you two above :-) Cheers, Markus -- Markus Lanthaler @markuslanthaler
Received on Sunday, 15 December 2013 12:17:12 UTC