Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a property several time when framing #122

Closed
Murloc6 opened this issue Jul 20, 2021 · 1 comment
Closed

Use a property several time when framing #122

Murloc6 opened this issue Jul 20, 2021 · 1 comment

Comments

@Murloc6
Copy link

Murloc6 commented Jul 20, 2021

We are trying to round trip json-ld with framing.

Our input json-ld document is:

{
  "@context": {
    "td": "http://my-url#",
    "name": "td:name",
    "properties": {
      "@id": "td:property",
      "@container": "@index",
      "@index": "name"
    }
  },
  "@id": "urn:toto",
  "@type": "td:Thing",
  "properties": {
    "myprop": {
      "td:prop1": "123",
      "name": "myprop"
    }
  }
}

We obtain the following triples:

<urn:toto> <http://my-url#property> _:b0 .
<urn:toto> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://my-url#Thing> .
_:b0 <http://my-url#name> "myprop" .
_:b0 <http://my-url#prop1> "123" .

On this way, everything is fine since the property "name" is used to generate a single triple.
When we want to frame these data to obtain the exact same json-ld document, the "name" property disappeared since it has been used as an "@Index".

In other words, we obtain this:

  "properties": {
    "myprop": {
      "td:prop1": "123"
    }
  }

And we would like to have this:

"properties": {
    "myprop": {
      "td:prop1": "123",
      "name": "myprop"
    }
  }

Do you know a way to define the frame (or the context) to use the property twice (as "@Index" and as an explicit key-value)?

playground example

@gkellogg
Copy link
Member

I think you're trying to use Property Indexing to represent this information, but you're expecting the result to contain duplicate results.

The idea of Property Indexing is that you can have multiple values (node objects, in this case) that are indexed by a common property, perhaps having different values. The example in the spec has a property for "athletes" which is indexed on the jobTitle of each athlete. So, there is a top level object with an "athletes" property which, if not for indexing, would have an array value with entries for each athlete, containing their own jobTitle. Specifying this as a property index map uses that value for the index, instead of as a property of the node object.

For your example, you have multiple values of "property", which is indexed by "name", so having the name as the index value and as a property of the node object would be redundant, as we've already said to use this value as the index. There is no way to express in a frame that you want repeat that property value inside the node object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants