jsonld.js icon indicating copy to clipboard operation
jsonld.js copied to clipboard

Framing algorithm misses subjects with @default key in the frame

Open laszbalo opened this issue 9 years ago • 2 comments

Consider this dummy document:

{
  "@context": {
    "ex": "http://example.org/vocab#"
  },
  "ex:a": "a",
  "ex:c": {
    "ex:foo": "bar"
  } 
}

and this frame:

{
  "@context": {
    "ex": "http://example.org/vocab#"
  },
  "@requireAll": true,
  "ex:foo": {
    "@default": "baz"
  }
}

Your current implementation returns with following document:

{
  "@context": {
    "ex": "http://example.org/vocab#"
  },
  "@graph": [
    {
      "@id": "_:b1",
      "ex:foo": "bar"
    }
  ]
}

However, I belive, that the result should contain both subjects, like this: (actually this is the result what I want to achieve)

{
  "@context": {
    "ex": "http://example.org/vocab#"
  },
  "@graph": [
    {
      "@id": "_:b0",
      "ex:a": "a",
      "ex:c": {
        "@id": "_:b1",
        "ex:foo": "bar"
      },
      "ex:foo": "baz"
    },
    {
      "@id": "_:b1",
      "ex:foo": "bar"
    }
  ]
}

In the draft version 1.1, under step 3.6, it says:

Otherwise, a subject matches if requireAll is true and all the non-keyword properties in frame exist in node with any value, or properties missing in node each have a property in frame which has a dictionary value containing only the key @default with any value.

In my case:

  • requireAll is set to true explicitly, despite true is the default
  • property ex:foo missing from the node but exists in frame; also
  • has a dictionary value containing only the key @default with the value of "baz"

Did I misunderstand how the algorithm works or is this a feature which has not been implemented yet?

By the way, tried out @lanthaler's processor and it returns both subjects, which I think is the correct behavior. permalink

laszbalo avatar Nov 03 '16 17:11 laszbalo

Seems like a bug or a not implemented to me; will need to look more closely.

dlongley avatar Nov 03 '16 18:11 dlongley

@davidlehn -- can you take a look here?

dlongley avatar May 26 '20 23:05 dlongley