|
| 1 | +--- |
| 2 | +title: Turning a folder into an RO-Crate |
| 3 | +teaching: 4 |
| 4 | +exercises: 3 |
| 5 | +--- |
| 6 | + |
| 7 | +::::::::::::::::::::::::::::::::::::::: objectives |
| 8 | +- Creating a skeleton RO-Crate Metadata File |
| 9 | +- Use the JSON-LD pre-amble to enable Linked Data |
| 10 | +:::::::::::::::::::::::::::::::::::::::::::::::::: |
| 11 | + |
| 12 | +:::::::::::::::::::::::::::::::::::::::: questions |
| 13 | +- How can I start a new RO-Crate? |
| 14 | +:::::::::::::::::::::::::::::::::::::::::::::::::: |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +## Turning a folder into an RO-Crate |
| 19 | + |
| 20 | +In the simplest form, to describe some data on disk, |
| 21 | +an _RO-Crate Metadata File_ is placed in a folder |
| 22 | +alongside a set of files or folders. |
| 23 | + |
| 24 | +First create a new folder `crate1/` |
| 25 | +and add a single file `data.csv` to represent our dataset: |
| 26 | + |
| 27 | +``` |
| 28 | +"Date","Minimum temperature (°C)","Maximum temperature (°C)","Rainfall (mm)" |
| 29 | +2022-02-01,16.0,28.4,0.6 |
| 30 | +2022-02-02,16.3,17.2,12.4 |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +Next, to turn this folder into an RO-Crate, |
| 35 | +we need to add the _RO-Crate Metadata File_, which has a fixed filename. |
| 36 | +Create the file `ro-crate-metadata.json` |
| 37 | +using [Visual Studio Code](https://code.visualstudio.com/) or your favourite editor, |
| 38 | +then add the following JSON: |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "@context": "https://w3id.org/ro/crate/1.1/context", |
| 43 | + "@graph": [ |
| 44 | + |
| 45 | + ] |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +Your folder should now look like this: |
| 50 | + |
| 51 | +{alt='Any folder can be made into an RO-Crate by adding `ro-crate-metadata.json`'} |
| 52 | + |
| 53 | +The presence of the reserved `ro-crate-metadata.json` filename |
| 54 | +means that `crate1` (and its children) can now be considered to be an **RO-Crate**. |
| 55 | +We call the top-level folder of the crate for the **RO-Crate Root** |
| 56 | +and can now refer to its content with relative file paths. |
| 57 | + |
| 58 | +We also need to make some declaration within the JSON file to turn it into a valid _RO-Crate Metadata Document_, |
| 59 | +explained in the next session. |
| 60 | + |
| 61 | + |
| 62 | +## JSON-LD preamble |
| 63 | + |
| 64 | +The preamble of `@context` and `@graph` are JSON-LD structures |
| 65 | +that help provide global identifiers to the JSON keys and types |
| 66 | +used in the rest of the RO-Crate document. |
| 67 | +These will largely map to definitions in the [schema.org](http://schema.org/) vocabulary, |
| 68 | +which can be used by RO-Crate extensions to provide additional metadata beyond the RO-Crate specifications. |
| 69 | +It is this feature of JSON-LD that helps make RO-Crate extensible for many different purposes |
| 70 | +-- this is explored further in the specification's [appendix on JSON-LD](https://www.researchobject.org/ro-crate/1.1/appendix/jsonld.html). |
| 71 | +In short, only JSON keys (_properties_) and types defined this way can be used within the RO-Crate Metadata Document. |
| 72 | + |
| 73 | +However, in the general case it should be sufficient to follow the RO-Crate JSON examples directly without deeper JSON-LD understanding. |
| 74 | +The RO-Crate Metadata Document contains a flat list of _entities_ as JSON objects in the `@graph` array. |
| 75 | +These entities are cross-referenced using `@id` identifiers, rather than being deeply nested. |
| 76 | +This is one major difference from JSON structures you may have experienced before. |
| 77 | +The `@type` keyword associates an object with a predefined type from the JSON-LD context. |
| 78 | +Almost any property can alternatively be used with an `[]` array to provide multiple values. |
| 79 | + |
| 80 | +The rest of this tutorial, |
| 81 | +and indeed most of the [RO-Crate specification](https://www.researchobject.org/ro-crate/1.1/), |
| 82 | +specify which entities can be added to the `@graph` array. |
| 83 | + |
| 84 | + |
| 85 | +:::::::::::::::::::::::::::::::::::::::: keypoints |
| 86 | +- Adding a RO-Crate Metadata file to a folder turns it into an RO-Crate |
| 87 | +- The RO-Crate Root is the top-level folder of the crate |
| 88 | +- RO-Crate uses schema.org as base vocabulary |
| 89 | +- The JSON-LD context enables optional Linked Data processing |
| 90 | +- Descriptions are listed flatly as entities in the @graph array |
| 91 | +:::::::::::::::::::::::::::::::::::::::::::::::::: |
| 92 | + |
0 commit comments