Re: JSON-LD (Was:Re: Vaccination Certificate Test Suite)

On 4/26/21 8:03 AM, Nikos Fotiou wrote:
> I will begin by apologizing for the dump questions, but I still haven't completely understood JSON-LD. I have two questions regarding https://w3c-ccg.github.io/vaccination-vocab/context/v1/index.json

Nikos, no reason to apologize... these are all great questions *and* you found
a few bugs in the experimental Vaccination Vocabulary JSON-LD Context, which
is always of great benefit to the community -- so, thank you! :)

> 1) What is the purpose of lines 7-10, i.e.,
>         "description": "http://schema.org/description",
>         "identifier": "http://schema.org/identifier",
>         "name": "http://schema.org/name",
>         "image": "http://schema.org/image"
> and why these attributes are redefined inside VaccinationCertificate attribute (lines 18-21)?

Yes, that's strange that they're defined at the top and then re-defined. We'd
have to ask Tobias, who wrote the context, why he chose to do that. The
Vaccination Certificate Vocabulary uses "JSON-LD Scoped Contexts", which are
an advanced feature of JSON-LD. These are "type-scoped", which basically means
"these definitions ONLY apply when a particular type is used".

So, if you look at this line:

https://github.com/w3c-ccg/vaccination-vocab/blob/master/context/v1/index.json#L11

The definitions under VaccinationCertificate, such as "description" and
"image" ONLY apply if the type of the object is "VaccinationCertificate".

More on scoped contexts here:

https://www.w3.org/TR/json-ld11/#scoped-contexts

> 2)  In various places there is the following line
> "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
> 
> Firstly, I thought that the @type property would lead to something machine readable so that type checks are automated. Even if this is not the case, http://www.w3.org/2001/XMLSchema#dateTime contains no information about this type. Is there any implicit agreement that this URL corresponds to a "date"? The closest I found by following links was that 
> https://www.w3.org/TR/xmlschema11-2/#dateTime
> 
> But even this, it says: "dateTime uses the date/timeSevenPropertyModel, with no properties except timezoneOffset permitted to be absent." Hence **if** this is the correct type, all the examples are not correct since they do not include the time part, in the `birthDate` attribute which is of that type. 

You've found a bug in the JSON-LD Context... those values should be:

http://www.w3.org/2001/XMLSchema#date

which is defined here:

https://www.w3.org/TR/xmlschema11-2/#date

JSON-LD is NOT a schema constraint language. It is not designed to do what
JSON Schema does. Instead, it is a semantics expression language that attempts
to be highly aligned with the way JSON developers use JSON out in the real world.

So, the thing that these lines do:

https://github.com/w3c-ccg/vaccination-vocab/blob/master/context/v1/index.json#L34-L37

is basically state "If you see `dateOfVaccination`, the long form of that
identifier is `https://w3id.org/vaccination#dateOfVaccination`, and you should
assume it is a date-time value as defined in XML Schema."

That statement is, of course, wrong. Instead, it should be "If you see
`dateOfVaccination`, the long form of that identifier is
`https://w3id.org/vaccination#dateOfVaccination`, and you should assume it is
a `date` value as defined in XML Schema."

The difference being XML Schema dateTime vs. date. All that said, perhaps
Tobias meant to define it as a dateTime (which means all of the tests are
wrong), or we really do want it to be a date (which means the JSON-LD Context
is wrong).

I'll wait for Tobias to chime in to provide his thought process before
suggesting changes.

-- manu

-- 
Manu Sporny - https://www.linkedin.com/in/manusporny/
Founder/CEO - Digital Bazaar, Inc.
blog: Veres One Decentralized Identifier Blockchain Launches
https://tinyurl.com/veres-one-launches

Received on Monday, 26 April 2021 14:00:41 UTC