-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JSON-LD Context Document for Data Package (#874)
* Add JSON-LD Context Document for Data Package * Update schemas/context/README.md Co-authored-by: Dan Feder <[email protected]> --------- Co-authored-by: Dan Feder <[email protected]>
- Loading branch information
Showing
6 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This directory contains non-normative JSON-LD Context Documents to convert Data Package Formats to RDF. | ||
|
||
Right now, it only contains a context for Data Package documents. | ||
Properties `resources`, `profile`, and contributor roles are ignored. | ||
|
||
Note that the use of POSIX paths will reduce the ability for RDF conversion. In particular: | ||
|
||
- property `id`, if given, MUST be a URI | ||
- property `image` with POSIX path will be ignore | ||
- elements with property `path` having a POSIX path value be ignored | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"dcat": "http://www.w3.org/ns/dcat#", | ||
"dct": "http://purl.org/dc/terms/", | ||
"foaf": "http://xmlns.com/foaf/0.1/", | ||
"schema": "https://schema.org/", | ||
"prov": "http://www.w3.org/ns/prov#", | ||
"name": "dct:identifier", | ||
"id": "@id", | ||
"licenses": { | ||
"@id": "dct:license", | ||
"@context":{ | ||
"name": "dct:identifier", | ||
"title": "dct:title", | ||
"path": "@id" | ||
} | ||
}, | ||
"title": "dct:title", | ||
"description": "dct:description", | ||
"homepage": { | ||
"@id": "foaf:homepage", | ||
"@type": "@id" | ||
}, | ||
"version": "dct:version", | ||
"sources": { | ||
"@id": "prov:wasDerivedFrom", | ||
"@context": { | ||
"path": "@id", | ||
"title": "foaf:name", | ||
"email": "foaf:mbox" | ||
} | ||
}, | ||
"contributors": { | ||
"@id": "dct:contributor", | ||
"@context": { | ||
"title": "foaf:name", | ||
"organization": "schema:affiliation", | ||
"email": "foaf:mbox" | ||
} | ||
}, | ||
"keywords": "dcat:keyword", | ||
"image": { | ||
"@id": "foaf:img" | ||
}, | ||
"created": "dct:created" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "name-of-package", | ||
"id": "https://example.org/id/1234", | ||
"licenses": [{ | ||
"name": "ODC-PDDL-1.0", | ||
"path": "http://opendatacommons.org/licenses/pddl/", | ||
"title": "Open Data Commons Public Domain Dedication and License v1.0" | ||
}], | ||
"title": "A nice title", | ||
"description": "whatever...", | ||
"homepage": "http://example.org", | ||
"version": "1.2.3", | ||
"sources": [{ | ||
"title": "Sample Source", | ||
"path": "http://example.org/source", | ||
"email": "[email protected]", | ||
"version": "0.0.1" | ||
}], | ||
"contributors": [{ | ||
"title": "Ex Ample", | ||
"email": "[email protected]", | ||
"path": "http://example.org/staff/ex", | ||
"organization": "Acme", | ||
"role": "author" | ||
}], | ||
"keywords": [ "example", "stuff" ], | ||
"image": "http://example.org/image.png", | ||
"created": "1985-04-12T23:20:50.52Z", | ||
"resources": [{ | ||
"name": "resource-name", | ||
"path": "http://example.org/resource-path.csv" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<http://example.org/source> <http://purl.org/dc/terms/version> "0.0.1" . | ||
<http://example.org/source> <http://xmlns.com/foaf/0.1/mbox> "[email protected]" . | ||
<http://example.org/source> <http://xmlns.com/foaf/0.1/name> "Sample Source" . | ||
<http://opendatacommons.org/licenses/pddl/> <http://purl.org/dc/terms/identifier> "ODC-PDDL-1.0" . | ||
<http://opendatacommons.org/licenses/pddl/> <http://purl.org/dc/terms/title> "Open Data Commons Public Domain Dedication and License v1.0" . | ||
<https://example.org/id/1234> <http://purl.org/dc/terms/contributor> _:b0 . | ||
<https://example.org/id/1234> <http://purl.org/dc/terms/created> "1985-04-12T23:20:50.52Z" . | ||
<https://example.org/id/1234> <http://purl.org/dc/terms/description> "whatever..." . | ||
<https://example.org/id/1234> <http://purl.org/dc/terms/identifier> "name-of-package" . | ||
<https://example.org/id/1234> <http://purl.org/dc/terms/license> <http://opendatacommons.org/licenses/pddl/> . | ||
<https://example.org/id/1234> <http://purl.org/dc/terms/title> "A nice title" . | ||
<https://example.org/id/1234> <http://purl.org/dc/terms/version> "1.2.3" . | ||
<https://example.org/id/1234> <http://www.w3.org/ns/dcat#keyword> "example" . | ||
<https://example.org/id/1234> <http://www.w3.org/ns/dcat#keyword> "stuff" . | ||
<https://example.org/id/1234> <http://www.w3.org/ns/prov#wasDerivedFrom> <http://example.org/source> . | ||
<https://example.org/id/1234> <http://xmlns.com/foaf/0.1/homepage> <http://example.org> . | ||
<https://example.org/id/1234> <http://xmlns.com/foaf/0.1/img> "http://example.org/image.png" . | ||
_:b0 <http://xmlns.com/foaf/0.1/mbox> "[email protected]" . | ||
_:b0 <http://xmlns.com/foaf/0.1/name> "Ex Ample" . | ||
_:b0 <https://schema.org/affiliation> "Acme" . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const util = require('util') | ||
const readFile = util.promisify(require('fs').readFile) | ||
const {assert} = require('chai') | ||
const jsonld = require('jsonld') | ||
|
||
const toRDF = async file => { | ||
const doc = require(file) | ||
doc["@context"] = require("../schemas/context/data-package.json") | ||
const triples = await jsonld.toRDF(doc, {format: 'application/n-quads'}) | ||
return triples.split("\n").sort().filter(Boolean).join("\n")+"\n" | ||
} | ||
|
||
describe('rdf', () => { | ||
it('data-package', async () => { | ||
const rdf = await toRDF('./files/data-package-1.json') | ||
const nt = await readFile('test/files/data-package-1.nt', 'utf-8') | ||
assert.equal(rdf, nt) | ||
}) | ||
}) |