w3c / json-ld-framing

JSON-LD 1.1 Framing Specification
https://w3c.github.io/json-ld-framing/
Other
25 stars 20 forks source link

Allow class-scoped framing #29

Open azaroth42 opened 6 years ago

azaroth42 commented 6 years ago

It would be useful to allow individual classes to have their own frames, such that a class which can appear at many points in the structure can be defined only once and then the definition inherited.

For example, a class like Type / Concept / Tag might appear anywhere in a structure associated with any other class. Currently (I believe) you would need to define all possible structures to ensure that the Type was framed consistently.

gkellogg commented 6 years ago

What do you think this might look like? Framing serves as a "program by example", and I'm not sure what such a frame might look like.

azaroth42 commented 5 years ago

I can't recall what the issue was, closing :)

azaroth42 commented 5 years ago

Ahha, and in coming back to an implementation, I recall the issue. It's related to https://github.com/w3c/json-ld-syntax/issues/19 and https://github.com/w3c/json-ld-api/issues/33.

Framing is a program-by-example or templating system, but it requires the absolute structure to be known from the root node down. We have a "Type" (or Concept, or Tag) that has a structure we'd like to see repeated every time it is referenced, but don't know all of the places in the structure where it might occur.

So we'd like the following to be able to be specified in a frame, without knowing the structure for property, just to make a frame for resources that have a type of Tag:

{
  "tag": {
    "id": "http://example.org/tag1",
    "type": "Tag",
    "label": "example tag"
  },
  "property": {
    "more_properties": {
      "tag": {
        "id": "http://example.org/tag1",
        "type": "Tag",
        "label": "example tag"
      }
    }
  }
}

Rather than the second instance being just the URI.

azaroth42 commented 5 years ago

In terms of potential syntax, the best I can come up with is a new keyword (I hear the groans from around the world) that would be a wildcard for properties. It can't be a second graph shape in @graph as the processor wouldn't know which shape was the top, and which was the child template. It can't use @nest as then you wouldn't be able to frame nested (structural, transparent) properties.

e.g. something like:

{
  "@anywhere": { 
    "tag": {
      "type": {"id": "Tag", "@embed": always"}
      "label": {"@embed": "always"}
    }
  },
  "property": { ... }
}
iherman commented 5 years ago

This issue was discussed in a meeting.

iherman commented 5 years ago

This issue was discussed in a meeting.

iherman commented 5 years ago

This issue was discussed in a meeting.

AtesComp commented 4 years ago

Since the @graph keyword (and using no @graph keyword) implies that "the absolute structure to be known from the root node down", then maybe using a @subgraph keyword would specifies a matching substructure (and might be used multiple times). Non-matching portions should be included "as is" from the input graph. This looks like a search and replace operation.