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

declare datatype in $linkedData #576

Open
VladimirAlexiev opened this issue Sep 19, 2022 · 6 comments
Open

declare datatype in $linkedData #576

VladimirAlexiev opened this issue Sep 19, 2022 · 6 comments
Labels
help wanted Extra attention is needed post-1.0 This is for issues that are important but should not block 1.0

Comments

@VladimirAlexiev
Copy link
Contributor

VladimirAlexiev commented Sep 19, 2022

In a JSONLD context one can and should declare the datatypes of props, so that a JSON payload string is mapped to the appropriate datatype.

  • (This is unlike the expected range of an object property, which cannot be declared, because the type of all such props is @is)

This is especially important for literals that don't have native JSON type (xsd:date, xsd:dateTime).
It's also important for numbers, which are subject to rounding/mangling in JSON. Eg this JSONLD payload:

{"@context":{
   "xsd":"http://www.w3.org/2001/XMLSchema#",
   "foo": {"@type":"xsd:boolean","@id":"https://example.org/foo"},
   "foo1":{"@type":"xsd:boolean","@id":"https://example.org/foo1"},
   "bar": {"@type":"xsd:decimal","@id":"https://example.org/bar"},
   "bar1":{"@type":"xsd:decimal","@id":"https://example.org/bar1"},
   "baz": {"@type":"xsd:integer","@id":"https://example.org/baz"}
  },
  "foo":"true","foo1":true,"bar":"12.345678901234567890","bar1":12.345678901234567890,"baz":123456789012345678901234567890}

is converted to this ntriples at https://json-ld.org/playground/.
Notice the rounding of bar1, and the syntactically incorrect value of baz:

_:b0 <https://example.org/bar1> "1.234567890123457E1"^^<http://www.w3.org/2001/XMLSchema#decimal> .
_:b0 <https://example.org/bar> "12.345678901234567890"^^<http://www.w3.org/2001/XMLSchema#decimal> .
_:b0 <https://example.org/baz> "1.234567890123457E29"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:b0 <https://example.org/foo1> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
_:b0 <https://example.org/foo> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .

It's less important for booleans because the values are not subject to rounding.

Examples:

  1. credentials/USMCACertificationOfOrigin.yml:
  importerUnknown:
    title: Importer Unknown
    description: >-
      If the identity of the importer is unknown, or there are various
      importers, please check the appropriate box.
    type: boolean
    $linkedData:
      term: importerUnknown
      '@id': https://w3id.org/traceability#importerUnknown

could add

      '@type': 'xsd:boolean'
  1. common/IATAAirWaybill.yml:
  executedOn:
    title: Executed on (Date)
    description: >-
      The date of execution of the air waybill shall be inserted in the sequence
      of day, month and year. The month shall be expressed alphabetically,
      either abbreviated or in full. Box 32A.
    type: string
    $linkedData:
      term: executedOn
      '@id': https://w3id.org/traceability#executionTime
      '@type': http://www.w3.org/2001/XMLSchema#dateTime

already has @type, but maybe the JSON type should be changed from string to something better?

  1. common/Transport.yml:
  plannedDepartureDate:
    title: Planned Departure Date
    description: The planned date of departure.
    type: string
    $linkedData:
      term: plannedDepartureDate
      '@id': https://schema.org/Date

Must change to this ( I assume JSON Schema has type dateTime)

    type: dateTime 
    $linkedData:
       term: plannedDepartureDate
       '@id': traceability:plannedDepartureDate
       '@type': xsd:dateTime
@OR13
Copy link
Collaborator

OR13 commented Jan 3, 2023

We need a way to visualize this, and break it down into smaller chunks so it can be addressed.

@BenjaminMoe
Copy link
Contributor

The action to take on this issue would be to write a script to produce the numbers for this issue.

@nissimsan
Copy link
Collaborator

Proposal: introduce a chart similar to undefinedTerms which we can use to track progress on missing datatypes.

This ticket needs to be broken into smaller issues. Somehow.

@nissimsan nissimsan added the help wanted Extra attention is needed label Jan 3, 2023
@nissimsan nissimsan self-assigned this Jan 3, 2023
@nissimsan
Copy link
Collaborator

Assigned myself to produce an example of a relevant schema, so we can get agreement of what a proper, fully datatyped schema should look like.

@nissimsan
Copy link
Collaborator

Very similar to #573

@nissimsan
Copy link
Collaborator

At its most basic, this could be just a couple of counters like this:
image

@mkhraisha mkhraisha added the post-1.0 This is for issues that are important but should not block 1.0 label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed post-1.0 This is for issues that are important but should not block 1.0
Projects
None yet
Development

No branches or pull requests

5 participants