|
1 | 1 | # Generate RDFS vocabulary files
|
2 | 2 |
|
3 |
| -The script in the directory generates RDFS vocabulary files in JSON and Turtle formats, plus a human readable HTML file containing the vocabulary in RDFa, based on a simple vocabulary definition in a CSV file. Neither the script nor the CSV format is prepared for complex vocabularies; its primary goal is to simplify the generation of simple, straightforward RDFS vocabularies without, for instance, sophisticated OWL statements. |
| 3 | +The script in the directory generates RDFS vocabulary files in JSON and Turtle formats, plus a human readable HTML file containing the vocabulary in RDFa, based on a simple vocabulary definition in a YAML file. This is done using the [yml2vocab](https://github.com/w3c/yml2vocab); more details about the script can also be found in the [yml2vocab readme file](https://github.com/w3c/yml2vocab). |
4 | 4 |
|
5 |
| -## Definition of the vocabulary in the CSV file |
6 |
| - |
7 |
| -The vocabulary is defined in a CSV file, which contains the following columns: `category`, `id`, `property`, `value`, `label`, `upper value`, `domain`, `range`, `comment`, and `deprecated`. The `category` column defines the category of the row, and the interpretation of the row's content (that is, of the other columns) depends on this category. |
8 |
| - |
9 |
| -The `comment` cells may include HTML tags; these will be filtered out for Turtle and JSON-LD, but will be copied into HTML (note, b.t.w., that the markdown syntax for simple formatting, like the use of "`" for code, may also be used) |
10 |
| - |
11 |
| -The available categories, specified by the `category` cells, and the corresponding interpretation of the columns, are: |
12 |
| - |
13 |
| -- `vocab`: the prefix and the URL of the vocabulary that is being specified are provided in the `id` and `value` columns, respectively. |
14 |
| -- `prefix`: definition of a prefix, and corresponding URL, for each external external vocabulary in use, defined by the `id` and `value` columns, respectively. |
15 |
| - |
16 |
| - Note that some prefix/value pairs are defined by default, and it is not necessary to define them here. These are: `dc` (for `http://purl.org/dc/terms/`), `owl` (for `http://www.w3.org/2002/07/owl#`), `rdf` (for `http://www.w3.org/1999/02/22-rdf-syntax-ns#`), `rdfs` (for `http://www.w3.org/2000/01/rdf-schema#`), and `xsd` (for `http://www.w3.org/2001/XMLSchema#`). |
17 |
| -- `ontology`: definition of an "ontology property", that is, a statement made about the vocabulary itself. The (prefixed) property term is defined in the `property` column, and the value in the `value` column. If the value can be parsed as a URL, it is considered to be the URL of an external resource; otherwise, the value is considered to be (English) text. |
18 |
| - |
19 |
| - It is good practice to provide, at least, `dc:description` as an ontology property with a short description of the vocabulary. |
20 |
| - |
21 |
| -- `class`: definition of a class. The `id` column defines the class name (no prefix should be used here); possible superclasses are defined in the `upper value` column as a single term, or as a comma-separated list of terms. There should be a label and a longer description in English text provided in the `label` and `comment` columns, respectively. |
22 |
| - |
23 |
| - A class can be declared as deprecated by setting its `deprecated` column to "yes". |
24 |
| -- `property`: definition of a property. The `id` column defines the property name (no prefix should be used here); possible superproperties are defined in the column `upper value` as a single term, or as a comma-separated list of terms. The domain and range classes can also be provided as a single term, or as a comma separated list thereof, in the `domain` and `range` columns. There should be a label and a longer description in English text, provided by the `label` and `comment` columns, respectively. |
25 |
| - |
26 |
| - A property can be declared as deprecated by setting its `deprecated` column to "yes". |
27 |
| -- `individual`: definition of an individual, i.e., a single resource defined in the vocabulary. The `id` column defines the individual's name (no prefix should be used here); the possible types are defined in the column `upper value` as a single term, or a comma separated list of terms. |
28 |
| - |
29 |
| -## Installation and use |
30 |
| - |
31 |
| -The script is in TypeScript (version 4.6 and beyond) running on top of `node.js` (version 16 and beyond). Take the following steps to install and run the script: |
32 |
| - |
33 |
| -1. Install [`node.js`](https://nodejs.org/) on your local machine. Installation of `node.js` should automatically install the [`npm`](https://www.npmjs.com) package manager. |
34 |
| -2. In the directory of the script, run `npm install` on the command line. This installs all the necessary packages in the `node_modules` subdirectory. |
35 |
| -3. The script can be run through `npm run generate` on the command line. |
36 |
| - |
37 |
| -The vocabulary specification in CSV is in the `vocabulary.csv` file. The script generates the files `vocabulary.ttl`, `vocabulary.jsonld` and `vocabulary.html` for, respectively, the Turtle, JSON-LD, and HTML representations. |
38 | 5 |
|
39 | 6 | ## Content of the directory
|
40 | 7 |
|
41 | 8 | - `Readme.md`: this file.
|
42 |
| -- `vocabulary.csv`: the vocabulary specification. |
43 |
| -- `package.json`: configuration file for `npm`. |
44 |
| -- `template.json`: an HTML template file used by the script; it is the skeleton of the final HTML format, also based on [ReSpec](https://respec.org/docs/). If the file is modified, care should be taken to not change the core structure and the various, possibly empty, HTML elements with `@id` values. The script fills those elements with content when generating the `vocabulary.html` file. |
45 |
| -- `lib` directory: the TypeScript modules for the script. |
46 |
| -- `main.ts`: the TypeScript entry point to the script. |
47 |
| - |
48 |
| -The following files and directories are generated/modified by either the script or `npm`; better not to touch these directly: |
49 |
| - |
50 |
| -- `package-lock.json`: used by `npm` as an internal file for the packages. |
51 |
| -- `node_modules` directory: the various Javascript libraries used by the script. This directory should _not_ be uploaded to github, it is strictly for the local activation of the script. |
52 |
| -- `vocabulary.ttl`, `vocabulary.jsonld`, `vocabulary.html`: the vocabulary representation in different format. These are the only files "visible", conceptually, to the outside. |
53 |
| - |
54 |
| -## Acknowledgement |
| 9 | +- `vocabulary.yml`: the core vocabulary specification. _Any change on the vocabulary must be made by modifying this file;_ see the separate [description](https://github.com/w3c/yml2vocab) of the underlying YAML format, and the way to generate the "real", outward facing facing vocabulary files. |
| 10 | +- `vocabulary.ttl`, `vocabulary.jsonld`, `vocabulary.html`: the vocabulary specification in Turtle, JSON-LD, and HTML+RDFa, respectively. _These files are generated; they should not be modified manually._ |
| 11 | +- `template.json`: an HTML template file used by the script; it is the skeleton of the final HTML format based on [ReSpec](https://respec.org/docs/). If the file is modified, care should be taken not to change the core structure and the various, possibly empty, HTML elements with `@id` values. The script fills those elements with content when generating the `vocabulary.html` file. |
55 | 12 |
|
56 |
| -The original idea, structure, and script (in Ruby) was created by Gregg Kellogg for v1 of the Credentials Vocabulary. The CSV definitions have been slightly updated/changed, and the script itself has been re-written in TypeScript. |
0 commit comments