w3c-ccg / traceability-vocab

A traceability vocabulary for describing relevant Verifiable Credentials and their contents.
https://w3id.org/traceability
Other
34 stars 35 forks source link

wrong use of ItemList #569

Closed VladimirAlexiev closed 1 year ago

VladimirAlexiev commented 2 years ago

The following schemas use https://schema.org/ItemList:

That's a rather specific class that should only be used for ordered lists, and there's no way to specify the class of elements. More precisely, its itemListElement must be ListItem, which must have a position (integer) and item that's Thing (i.e. unspecific class).

Here are 2 specific cases to illustrate the error:

AgricultureActivity.yml:

  actor:
    title: Actor
    description: The actual person or persons performing the activity.
    type: array
    items:
      $ref: ./Person.yml
    $linkedData:
      term: actor
      '@id': https://w3id.org/traceability#Person
      '@type': https://schema.org/ItemList

You cannot state "a list of Persons", and the Person.yml schema doesn't have any fields pertaining to ordered lists, nor does the example embedded in AgricultureActivity.yml.

  pgaShipmentStatusItems:
    title: PGA Shipment Status Items
    description: List of PGA Status Messages pertaining to per-line items
    type: array
    items:
      $ref: ./PGAShipmentStatus.yml
    $linkedData:
      term: pgaShipmentStatusItems
      '@id': https://schema.org/ItemList
      '@type': https://schema.org/ItemList

The problems are the same.


If you need an ordered list of items, you can do specify this in the JSONLD context:

"pgaShipmentStatusItems": {"@type":"@id", "@id","traceability:pgaShipmentStatusItems", "@collection":"@list"}

Then it will be emitted as an rdf:List that doesn't have integer position fields but uses a linked list to preserve order. It looks nice in turtle, eg:

<list> traceability:pgaShipmentStatusItems ("one" "two" "three")

But such list uses blank nodes and looks like the following RDF structure:

<list> traceability:pgaShipmentStatusItems 
  [a rdf:List; rdf:first "one"; rdf:rest
    [a rdf:List; rdf:first "two"; rdf:rest
      [a rdf:List; rdf:first "three"; rdf:rest rdf:nil]]]

Despite JSONLD's syntactic support for rdf:List, you probably will want to avoid it and use your own structure, eg a simplification of schema:ItemList:

<list> a traceability:PGAShipmentStatusList traceability:member
  [a traceability:PGAShipmentStatus; traceability:position 1; traceability:recordNo: "SO701"...],
  [a traceability:PGAShipmentStatus; traceability:position 2; traceability:recordNo: "SO702"...],
  [a traceability:PGAShipmentStatus; traceability:position 3; traceability:recordNo: "SO703"...].
brownoxford commented 1 year ago

@rhofvendahl can you please take a peek at this?

rhofvendahl commented 1 year ago

@VladimirAlexiev Thanks for pointing this out, and for the explanation!

It looks as though the '@type'is used almost entirely for ItemList and identifier, both of which (as you've pointed out) are used incorrectly. Unless there are any objections I'd like to leave correct implementation of '@type' for future PRs and for now just remove the offending code.

nissimsan commented 1 year ago

types are now removed - closing this issue. We might want to introduce types on a case by case bases on dedicated tickets.

VladimirAlexiev commented 1 year ago

@nissimsan it's still used in 7 schemas: https://github.com/w3c-ccg/traceability-vocab/search?q=ItemList&type=code Please reopen.

nissimsan commented 1 year ago

Nice search, @VladimirAlexiev.

The simple solution seems to be just removing '@type': https://schema.org/ItemList?

VladimirAlexiev commented 1 year ago

I'm afraid that the https://github.com/w3c-ccg/traceability-vocab/pull/686 fix doesn't do much.

Another example from RevocationList2020Status.yml:

  revocationListIndex:
    title: revocationListIndex
    type: string
    $linkedData:
      term: revocationListIndex
      '@id': https://schema.org/itemListElement
  revocationListCredential:
    title: revocationListCredential
    type: string
    $linkedData:
      term: revocationListCredential
      '@id': https://schema.org/LinkRole
example: |-
  {
    "type" : ["RevocationList2020Status"],
    "revocationListIndex" : "0",
    "revocationListCredential": "https://example.gov/revocation-lists/urn:uuid:3bc24f87-b47b-43a0-b5bf-b9fde7913746"
  }

There are several mistakes here:

OR13 commented 1 year ago

This is now controlled by https://github.com/w3c/vc-bitstring-status-list

I suggest we close this issue