W3C home > Mailing lists > Public > public-linked-json@w3.org > April 2012

Re: Clarification on blank node idioms

From: Gregg Kellogg <gregg@kellogg-assoc.com>
Date: Mon, 2 Apr 2012 12:46:47 -0400
To: Danny Ayers <danny.ayers@gmail.com>
CC: Markus Lanthaler <markus.lanthaler@gmx.net>, "public-linked-json@w3.org" <public-linked-json@w3.org>
Message-ID: <35C4D1E8-F0A6-4963-9FAF-FCBFF5FAE5A6@greggkellogg.net>
On Apr 2, 2012, at 9:24 AM, Danny Ayers wrote:

> Hi Markus,
> Thanks. The use of "_:blank" is clear now I've seen an example, but
> really wasn't obvious from the spec, I'd still suggest a doc tweak.

Danny, do you think that [1] isn't clear? Or that it is referenced too far down in the document?

At times, it becomes necessary to be able to express information without being able to specify the subject. Typically, this type of node is called an unlabeled node or a blank node. In JSON-LD, unlabeled node identifiers are automatically created if a subject is not specified using the @idkeyword. However, authors may provide identifiers for unlabeled nodes by using the special _ (underscore) prefix. This allows to reference the node locally within the document but not in an external document.

> Re. typing of objects, right, it makes sense now you mention
> literals/scalars. In this case when the context says the object of a
> statement is an @id as well as the actual statement it's redundant,
> but I guess that still might be useful as a sanity-checking
> annotation.

Typically, you wouldn't use both the expanded form and a compact form if you specify the datatype in the context, but it's certainly allowed.


[1] http://json-ld.org/spec/latest/json-ld-syntax/#identifying-unlabeled-nodes

> Cheers,
> Danny.
> On 2 April 2012 12:28, Markus Lanthaler <markus.lanthaler@gmx.net> wrote:
>> 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
> -- 
> http://dannyayers.com
> http://webbeep.it  - text to tones and back again
Received on Monday, 2 April 2012 16:54:47 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:53:19 UTC