W3C home > Mailing lists > Public > public-linked-json@w3.org > October 2013

Re: Bug with @reverse and blank nodes?

From: Gregg Kellogg <gregg@greggkellogg.com>
Date: Sun, 20 Oct 2013 09:57:28 -0700
Cc: public-linked-json@w3.org, Dave Longley <dlongley@digitalbazaar.com>, Markus Lanthaler <markus.lanthaler@gmx.net>
Message-Id: <4E2DAE10-9BAA-4C1B-9133-90B73212D546@greggkellogg.com>
To: Pierre-Antoine Champin <pierre-antoine.champin@liris.cnrs.fr>
On Oct 20, 2013, at 2:21 AM, Pierre-Antoine Champin <pierre-antoine.champin@liris.cnrs.fr> wrote:

> Hi,
> 
> I add a surprise today using @reverse with  blank node:
> 
> {
>   "@context": {
>     "foo": "http://example.org/foo",
> 
>     "bar": { "@reverse": "http://example.org/", "@type": "@id" }
>   },
>   "foo": "Foo",
>   "bar": "http://example.org/origin"
> 
> }
> 
> produces the following graph:
> 
> <http://example.org/origin> <http://example.org/> _:b1 .
> 
> _:b0 <http://example.org/foo> "Foo" .
> 
> with *two different bnodes*!...
> 
> I have the same behaviour with PyLD and the online playground, so may be this is a deliberate feature of the JSON-LD algorithm (I didn't go and check the API document, I admit...). But if it is so there should be a big warning sign in the syntax document, because this is *very* counter-intuitive.

My Ruby parser also produces this result, which implies that it's a consequence of the way the algorithm is stated in JSON-LD-API. I agree that it's counter-intuitive and inconsistent with the use of an IRI subject. Even specifying a labeled blank node as the subject causes two different blank nodes to be generated. I think it's a spec bug.

If I add the subject _:foo, the node expands to the following:

{
  "@id": "_:foo",
  "@reverse": {
    "http://example.org/": [
      {"@id": "http://example.org/origin"}
    ]
  },
  "http://example.org/foo": [
    {"@value"=>"Foo"}
  ]
}

I think the problem comes when in the flattening algorithm, which results in the following node map:

{
  "@default": {
    "_:b0": {"@id": "_:b0"},
    "http://example.org/origin": {
      "@id": "http://example.org/origin",
      "http://example.org/": [{"@id": "_:b1"}]
    },
    "_:b1": {"@id": "_:b1"}
  }
}

I believe it comes down to step 6.1 of the Node Map Generation algorithm [1], which says to generate a new blanknode identifier. It was previously invoked from step 6.8.3.1.2 because of the @reverse keyword. Perhaps there is some flag that needs to be passed so that a new blanknode lebel is not generated? Markus or Dave might have some other opinions on this.

Gregg

[1] http://www.w3.org/TR/json-ld-api/#node-map-generation

>   pa


Received on Sunday, 20 October 2013 16:57:59 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:39 UTC