digitalbazaar / cborld

A Javascript CBOR-LD processor for web browsers and Node.js apps.
https://json-ld.github.io/cbor-ld-spec/
BSD 3-Clause "New" or "Revised" License
21 stars 17 forks source link

Scoped Contexts Processing Algorithm #61

Open filip26 opened 2 years ago

filip26 commented 2 years ago

Hi, please look at this example:

document

{
  "@context": "https://raw.githubusercontent.com/filip26/iridium-cbor-ld/main/src/test/resources/com/apicatalog/cborld/encoder/0025-context.jsonld",
  "a": "Note",
  "x": { "a": "x", "b": "y", "d": 106 },
  "y": {"a": "x", "b": "y", "c": 102 }
}

context

{
  "@context": {
    "@vocab": "https://www.w3.org/ns/activitystreams#",
    "y": {
      "@id": "idy",
      "@context": {
          "a": "@type",
          "b": "@id",
          "c": "longitude"
      }
    },  
    "a": "@type",
    "x": {
      "@id": "idx",
      "@context": {
     "a": "@id",
     "b": "@type",
     "d": "latitude"
       }
    }
  }
}

The output produced by the library is:

[{ 0: ...0025-context.jsonld, 
  100: Note, 
  102: { 100: 102, 106: y, 108: 106 }, 
  104: { 100: x, 106: 104, 110: 102 } }]

where

100: a, 102: x, 104: y,  105: b, 108: d  110: c

why is not @type x.b : y and y.a: x encoded?

by using encoded examples produced by the library as a source to reverse engineering, I've got this result:

[{ 0: ...0025-context.jsonld, 
   100: Note, 
    102: { 100: 102, 106: 104, 108: 106 }, 
    104: { 100: 102, 106: 104, 110: 102 } }]

Thank you!

filip26 commented 2 years ago

digging more into it, if you remove a: @type from scoped context for y then the result is

[{ 0: ...0025-context.jsonld, 
  100: Note, 
  102: { 100: x, 106: y, 108: 106 }, 
  104: { 100: x, 106: 104, 110: 102 } }]
dlongley commented 3 months ago

We should add tests that show whatever the right behavior here is, ensure we pass them, and then close the issue.