structured-data / linter

Structured Data linter
The Unlicense
84 stars 16 forks source link

strange schema.org/location error output #81

Open jvandriel opened 1 year ago

jvandriel commented 1 year ago

Every time the linter runs into markup containing statements about a schema.org/Person's homeLocation or workLocation it generates an error message:

property schema:location: Subject <http://example.org/#WileECoyote> not compatible with domainIncludes (schema:Action,schema:Event,schema:InteractionCounter,schema:Organization)

Somehow the location property (parent property of the others) gets shown in the output, which rightfully triggers the error message, though I am clueless as to why this property gets added. Is this a bug in the schema.org vocabulary or in the Linter?

What's extra confusing is that I only have seen it happen in regards to Person statements.

Markup example:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@id": "#WileECoyote",
  "@type": "Person",
  "name": "Wile E. Coyote",
  "workLocation": {
    "@id": "#FantasyLand",
    "@type": "Country",
    "name": "Fantasy land"
  }
}
</script>
gkellogg commented 1 year ago

Thanks for bringing up the issue. I think it is, indeed, a bug in the linter, but a challenging one to fix. Person is a valid range of workLocation, even though it is not of location. But, because of that way that subPropertyOf works, :a :workLocation :b. implies :a :location :b..

The definition of workLocation is:

:workLocation a rdf:Property ;
    rdfs:label "workLocation" ;
    :domainIncludes :Person ;
    :rangeIncludes :ContactPoint,
        :Place ;
    rdfs:comment "A contact location for a person's place of work." ;
    rdfs:subPropertyOf :location .

From RDFS, we can see via rdfs5:

``xxx rdfs:subPropertyOf yyy . yyy rdfs:subPropertyOf zzz . => xxx rdfs:subPropertyOf zzz .

The fact that _location` does not have Person in its range is not an error, as RDFS doesn't have error conditions. The linter is inferring a problem given the inferred triples.

The fix is probably to filter out errors of this kind, but that's going to be hard to do.

gkellogg commented 1 year ago

Actually, the way to address it is probably to add a rule such as the following:

aaa rdfs:subPropertyOf bbb .
aaa schema:domainIncludes ddd .

=>

bbb schema:domainIncludes ddd .

Same thing for schema:rangeIncludes.

jvandriel commented 1 year ago

Thanks for the reaction @gkellogg.

I can imagine you have a ton of other things to do before tackling this. I'm already happy to know I wasn't seeing ghosts for once.

If you'll ever get around to fixing it it'd be great, if not, at least it's documented in this issue.

jvandriel commented 11 months ago

Just for the sakes of documenting the issue in case people are searching for it, here's another example of the same issue:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@id": "#ShortStory",
  "@type": ["DefinedTerm", "http://www.wikidata.org/entity/Q49084"],
  "termCode": "ShortStory",
  "url": "https://schema.org/ShortStory",
  "inDefinedTermSet": "https://schema.org",
  "sameAs": "https://en.wikipedia.org/wiki/Short_story"
}
</script>