RE: Clarification on blank node idioms

Hi Danny,

> After not having looked at the spec for months, I'm in the process of
> manually converting a bit of Turtle into JSON-LD. I stumbled at this
> point:
> 
> <http://hyperdata.org/Hello>
>  foaf:maker [ foaf:nick "danja" ] .
> 
> Text-searching the spec ("blank nodes") I found:
> 
> http://json-ld.org/spec/latest/json-ld-syntax/#identifying-unlabeled-
> nodes
>
> ...which didn't seem to help at all. How would the above be expressed
> using the "_:blank" style?

Generally blank nodes are generated automatically when you convert to RDF. If you want to label an object with a specific blank node you use the idiom described in the spec.

So the above example (which also just has implicit blank nodes) would be expressed as follows:

{
  "@context": {
    "maker": "http://xmlns.com/foaf/0.1/maker",
    "nick": "http://xmlns.com/foaf/0.1/nick"
  },
  "@id": "http://hyperdata.org/Hello",
  "maker": {
    "@id": "_:blank",
    "nick": "danja"
  }
}


> One thing I'm still uncertain about is that although the JSON-LD above
> produced the triples I was after, the context part doesn't distinguish
> what kind of a node the object of maker/subject of nick was. This
> appears to be possible using the context:
> 
>  "@context": {
>   "maker": {
>         "@id": "http://xmlns.com/foaf/0.1/maker",
>         "@type": "@id"
>      },
> 
> - but doesn't make any difference to the resulting triples.

The reason for this is that you set the value to an object and not a literal (string, number, boolean in JSON). If you would have set it to "http://example.org/maker" you would have to add that @type declaration.


> Leading to the question: why would/should anyone bother putting node
> type info into the context?

It's used for type coercing with scalars/literals. As explained above. Since you use an object as value, JSON-LD automatically generates an identifier for that object and "knows" that it is an IRI (when converted to Turtle for example).


Hope this helps,
Markus


--
Markus Lanthaler
@markuslanthaler

Received on Monday, 2 April 2012 10:29:04 UTC