w3c / activitystreams

Activity Streams 2.0
https://www.w3.org/TR/activitystreams-core/
Other
276 stars 61 forks source link

OrderedCollection with multiple items values. #507

Closed timothee-haudebourg closed 4 years ago

timothee-haudebourg commented 4 years ago

Please Indicate One:

Please Describe the Issue:

The as:items property is not defined as a functional property, allowing users to define multiple values for this property. I can see how it is not a problem for Collection, but it seems to me that it becomes one with OrderedCollection. If there are multiples occurrences of items for a single ordered collection, there are no ways to know how the items of the collection are actually ordered, right?

Here is an illustration of the issue in a JSON-LD document:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "summary": "Sally's notes",
  "type": "OrderedCollection",
  "totalItems": 2,
  "orderedItems": [
    {
      "type": "Note",
      "name": "Meeting 2016-11-17"
    },
  ],
  "orderedItems": [
    {
      "type": "Note",
      "name": "Reminder for Going-Away Party"
    }
  ]
}

How to interpret this? Is this supposed to be valid? Should the reader just give up in finding the order between the two items?

nightpool commented 4 years ago

so, one thing to keep in mind is that (as i understand it) JSON-LD doesn't allow you to have duplicate keys, only duplicate values, using an array syntax. So your example would actually look something like

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "summary": "Sally's notes",
  "type": "OrderedCollection",
  "totalItems": 2,
  "orderedItems": [
    [
      {
        "type": "Note",
        "name": "Meeting 2016-11-17"
      },
    ],
    [
      {
        "type": "Note",
        "name": "Reminder for Going-Away Party"
      }
    ]
  ]
}

So we can already see that there is going to be some conflict between ordered lists / multi properties. As I understand JSON-LD, the "ordering" of the list comes from the @container property specified in the context document here:

"orderedItems": {
  "@id": "as:items",
  "@type": "@id",
  "@container": "@list"
},

The default container is @set, and you can see that items doesn't have any special container:

"items": {
  "@id": "as:items",
  "@type": "@id"
},

So putting all of this together, I think the way to understand multiple items values is that giving a list of items is exactly the same as giving multiple definitions of items, and JSON-LD only supports the former. The orderedItems property just has a special bit of syntax that makes it clear these items are ordered.

timothee-haudebourg commented 4 years ago

Thanks for the explanation :) However my question was not focused on JSON-LD, and I just used it as an example. It was a more general question about the RDF model defining Activity Streams. In this model, nothing forbids us to define multiples values for the items property in an OrderedCollection.

In an implementation strictly following the formal definition (which I'm trying to make), as I understand it, there is no way to define a unique ordering between the items of an instance of OrderedCollection in general.

nightpool commented 4 years ago

Yes, I think that's correct. As I found out when researching #508, as:items was originally a functional property, and then that restriction was removed: https://github.com/w3c/activitystreams/commit/f05bfa76fd5a7149269c6e7027e2568e36993e84, probably to make sure it was compatible with both ordered and unordered lists.

Another thing to keep in mind is that rdf:Lists don't have a restriction on the amount/ordering of properties either. Even if there was only one items list, that list may have multiple first values, or multiple rest values. Ultimately though, ActivityStreams is based on the normative JSON serialization defined at https://www.w3.org/TR/activitystreams-core, so while it can be represented as RDF, it's not defined in those terms. There may be things that are valid in RDF that aren't valid as part of ActivityStreams syntax.

timothee-haudebourg commented 4 years ago

Thanks for the clarification, that answers the question.