- From: Dave Longley <dlongley@digitalbazaar.com>
- Date: Fri, 19 Feb 2016 16:41:20 -0500
- To: Adrian Pohl <pohl@hbz-nrw.de>, public-linked-json@w3.org
On 02/19/2016 10:17 AM, Adrian Pohl wrote: > Hello, > > we would like to use what my colleague Jan Schnasse has dubbed "side car > approach" of providing JSON-LD. This means providing a label for each > node in the data – including RDF types – to enable easy consumption of > the data without IRI-lookups for presentation purposes. The following > example shows the general pattern: > > { > "@context":{ > "label":"http://www.w3.org/2000/01/rdf-schema#label", > "subject":{ > "@id":"http://purl.org/dc/terms/subject", > "@type":"@id" > } > }, > "@id":"http://lobid.org/resource/HT018881872", > "@type":[ > { > "@id":"http://purl.org/ontology/bibo/Book", > "label":"Buch" > }, > { > "@id":"http://purl.org/ontology/bibo/Thesis", > "label":"Abschlussarbeit" > } > ], > "title":[ > "Skateboarding" > ], > "otherTitleInformation":[ > "Ethnographie einer urbanen Praxis" > ], > "creator":[ > { > "@id":"http://d-nb.info/gnd/103058788", > "label":"Peters, Christian" > } > ], > "subject":[ > { > "@id":"http://d-nb.info/gnd/4181628-6", > "label":"Skateboardfahren" > }, > { > "@id":"http://d-nb.info/gnd/4031483-2", > "label":"Köln" > } > ] > } > > Though this is valid JSON it isn't valid JSON-LD, see [0]. This is > because the @type – whether aliased to "type" or not – keyword doesn't > allow objects but only takes "an absolute IRI, a relative IRI, a compact > IRI (including blank node identifiers), a term defined in the active > context expanding into an absolute IRI, or an array of any of these" > [1]. See also the section 5.4 Specifying the Type in the JSON-LD spec. [2] > > We noticed that the "side car" approach works when instead of "@type" > another name – e.g. "type" – is used which is mapped to rdf:type in the > context. Example: > > { > "@context":{ > "label":"http://www.w3.org/2000/01/rdf-schema#label", > "type":{ > "@id":"http://www.w3.org/1999/02/22-rdf-syntax-ns#type", > "@type":"@id" > } > }, > "@id":"http://lobid.org/resource/HT018881872", > "type":[ > { > "@id":"http://purl.org/ontology/bibo/Book", > "label":"Buch" > }, > { > "@id":"http://purl.org/ontology/bibo/Thesis", > "label":"Abschlussarbeit" > } > ] > } > > There is no error in the JSON-LD playground for this and the RDF outcome > looks as expected. [3] We are now thinking about using the key "type" > mapped to rdf:type for associating a type with a node and only using > "@type" in the JSON-LD context and for indicating a value type. > > In the recent thread on this list about the "@type" keyword and framing > [4] it became clear that "@type" is necessary for framing so this is an > obvious drawback. "@type" isn't necessary for framing, it's just one way to frame. Framing also supports duck-typing, so you can specify properties that must exist in a node in order for it to pass the frame filter instead of using "@type" to specify a type it must have to pass the filter. > As we are building our JSON-LD structure without > framing, mapping "type" to rdf:type wouldn't be a problem in this > regard. Are there any other reasons from refraining from this or any > arguments for another approach? You also could do this: { "@context":{ "label":"http://www.w3.org/2000/01/rdf-schema#label" }, "@graph": [{ "@id": "http://lobid.org/resource/HT018881872", "@type": [ "http://purl.org/ontology/bibo/Book", "http://purl.org/ontology/bibo/Thesis" ] }, { "@id": "http://purl.org/ontology/bibo/Book", "label": "Buch" }, { "@id": "http://purl.org/ontology/bibo/Thesis", "label": "Abschlussarbeit" }] } That keeps all the data around (no need to fetch anything) and is valid JSON-LD. You could preprocess it to generate an ID-based node map or whatever else you need to more easily get at the data. -- Dave Longley CTO Digital Bazaar, Inc. http://digitalbazaar.com
Received on Friday, 19 February 2016 21:41:44 UTC