json-ld / json-ld.org

JSON for Linked Data's documentation and playground site
https://json-ld.org/
Other
859 stars 152 forks source link

Remote context using DOI doesn't get dereferenced #447

Open gothub opened 7 years ago

gothub commented 7 years ago

I have a document with the remote context specified as a valid DOI:

{
    "@context":"http://doi.org/10.5063/SCHEMA/CODEMETA-1.0",
    "identifier": "https://dx.doi.org/10.6084/m9.figshare.828487",
    "embargoDate": "2014-08-06T10:00:01Z"
}

Expanding this in the Playground gives a document with all properties resolved to schema.org, and not the values specified in the remote context:

[
  {
    "http://schema.org/embargoDate": [
      {
        "@value": "2014-08-06T10:00:01Z"
      }
    ],
    "http://schema.org/identifier": [
      {
        "@value": "https://dx.doi.org/10.6084/m9.figshare.828487"
      }
    ]
  }
]

What the expanded document should be:

[
  {
    "https://codemeta.github.io/terms/embargoDate": [
      {
        "@type": "http://www.w3.org/2001/XMLSchema#dataTime",
        "@value": "2014-08-06T10:00:01Z"
      }
    ],
    "http://purl.org/dc/terms/identifier": [
      {
        "@type": "http://www.w3.org/2001/XMLSchema#string",
        "@value": "https://dx.doi.org/10.6084/m9.figshare.828487"
      }
    ]
  }
]

I see similar behavior using the ruby toolkit. Is dereferencing a DOI not supported, or is there some extra step I need to take to make this work?

dlongley commented 7 years ago

When requesting that context URL, the response you get is an HTTP 303 that has a Location header with a value of: http://data.datacite.org/10.5063%2FSCHEMA%2FCODEMETA-1.0

If you do an HTTP request for that (with Accept: application/ld+json), you get this JSON-LD document:

{"@context":"http:\/\/schema.org","@type":"SoftwareApplication","@id":"https:\/\/doi.org\/10.5063\/SCHEMA\/CODEMETA-1.0","name":"CodeMeta: an exchange schema for software metadata. KNB Data Repository","author":[{"@type":"Agent","name":"Matthew B Jones"},{"@type":"Agent","name":"Carl Boettiger"},{"@type":"Agent","name":"Abby Cabunoc Mayes"},{"@type":"Agent","name":"Arfon Smith"},{"@type":"Agent","name":"Peter Slaughter"},{"@type":"Agent","name":"Kyle Niemeyer"},{"@type":"Agent","name":"Yolanda Gil"},{"@type":"Agent","name":"Martin Fenner"},{"@type":"Agent","name":"Krzysztof Nowak"},{"@type":"Agent","name":"Mark Hahnel"},{"@type":"Agent","name":"Luke Coy"},{"@type":"Agent","name":"Alice Allen"},{"@type":"Agent","name":"Mercè Crosas"},{"@type":"Agent","name":"Ashley Sands"},{"@type":"Agent","name":"Neil Chue Hong"},{"@type":"Agent","name":"Patricia Cruse"},{"@type":"Agent","name":"Dan Katz"},{"@type":"Agent","name":"Carole Goble"}],"publisher":"KNB Data Repository","datePublished":"2016","version":"1.0"}

Which has a @context of http://schema.org. Hence, that context is used.

Also, I noticed that your @type in your example had a typo:

http://www.w3.org/2001/XMLSchema#dataTime => http://www.w3.org/2001/XMLSchema#dateTime

gothub commented 7 years ago

@dlongley Interesting. This DOI is typed as 'text/json', which may be causing the problem. The first URL request should return the resolution of the DOI, which should be

https://raw.githubusercontent.com/codemeta/codemeta/1.0/codemeta.jsonld

but maybe since the Accept type doesn't match the DOI's type, the Datacite metadata page is returned for the Location instead. I'll try changing DOI type to application/ld+json and see if that fixes the problem.

Thanks!