Changes for page Technical details
Last modified by lzehl on 2021/07/05 18:57
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -18,137 +18,52 @@ 18 18 === The openMINDS schema template syntax === 19 19 20 20 (% style="text-align: justify;" %) 21 -All openMINDS metadata models use a light-weighted schema template syntax for defining the expectedmetadata. The correspondingly formatted schema files use the extension: **##.schema.tpl.json##**.21 +All openMINDS metadata models use a light-weighted schema template syntax for defining the metadata. The correspondingly formatted schema files use the extension: **##.schema.tpl.json##**. 22 22 23 23 (% style="text-align: justify;" %) 24 -Although, as the file extension suggests, this openMINDS schema template syntax is inspired by JSON-Schema, it facilitates or even excludes technical aspects that are generally expected for the openMINDS schemas making t hemmore human-readable, especially for untrained eyes.Behind the scenes, within the openMINDS integration pipeline (cf. below), this schema template syntax is then interpreted and flexibly translated to various formal metadata formats (e.g., JSON-Schema).24 +Although, as the file extension suggests, this openMINDS schema template syntax is inspired by JSON-Schema, it facilitates or even excludes technical aspects that are generally expected for the openMINDS schemas making it more human-readable, especially for untrained eyes. 25 25 26 26 (% style="text-align: justify;" %) 27 - Despitethe simplification in comparison to JSON-Schema,theopenMINDS schema templatesare also,at thecore,speciallyformattedJSONfilesusingaparticularsyntax,meaningspecialkey-valuepairshatdefinethevalidationrules ofaschema.27 +Behind the scenes, within the openMINDS integration pipeline (cf. below), this schema template syntax is then interpreted and flexibly translated to various formal metadata formats (e.g., JSON-Schema). Please find in the following a full documentation of the openMINDS schema template syntax and how it needs to be interpreted. 28 28 29 29 (% style="text-align: justify;" %) 30 - Pleasefind inthefollowinga full documentationoftheopenMINDS schematemplateyntaxand how it's key-value pairs need to be defined and interpreted.30 +===== Target & context templates ===== 31 31 32 32 (% style="text-align: justify;" %) 33 - =====Target&concept templates=====33 +All openMINDS schemas have to have a **##"_type"##** to be recognized as target templates. In other words, the **##"_type"##** is used to define the openMINDS namespace of a corresponding schema using the following naming convention: 34 34 35 -(% style="text-align: justify;" %)36 - Same as in JSON-Schema, all openMINDS schema templates define the expected name (written in**##lowerCamelCase##**) and value ofthe metadata, typically calledproperty, underthe key **##properties##** asnested dictionaries.Furthermore, the namesof obligatory metadata can beisted under thekey **##required##**. Hereageneralized example:35 +(% style="text-align: center;" %) 36 +**##"_type": "https:~/~/openminds.ebrains.eu/<<schema-model>>/<<schema-name>>"##**, 37 37 38 -{{code language="json"}} 39 -{ 40 - "properties": { 41 - "propertyNameA": {}, 42 - "propertyNameB": {}, 43 - "propertyNameC": {} 44 - }, 45 - "required": [ 46 - "propertyNameA", 47 - "propertyNameC" 48 - ] 49 -} 50 -{{/code}} 51 - 52 52 (% style="text-align: justify;" %) 53 - In addition, an openMINDSschema//has tohave// a key **##"_type"##** to be recognized as **target template**.In otherwords,the**##"_type"##**is used todefinethe openMINDSnamespaceofacorresponding schemausingaparticularnamingconvention.Hereagainageneralizedexample:39 +where **##<<schema-model>>##** has to be replaced with the label of the openMINDS metadata model the corresponding schema belongs to and **##<<schema-name>>##** exchanged with the label of that schema. 54 54 55 -{{code language="json"}} 56 -{ 57 - "_type": "https:~/~/openminds.ebrains.eu/<<schema-model>>/<<schema-name>>", 58 - "properties": {} 59 -} 60 -{{/code}} 61 - 62 62 (% style="text-align: justify;" %) 63 - Notethat**##<<schema-model>>##**hasto bereplaced with the labeloftheopenMINDS metadatamodeltowhichthecorrespondingschemabelongsto,and**##<<schema-name>>##** hastobereplacedwiththecorrespondingnameoftheschema(written in **##CamelCase##**).42 +If an openMINDS schema template file //DOES NOT// define a **##"_type"##**, it is interpreted as a context template which requires an extension to become a target template. 64 64 65 65 (% style="text-align: justify;" %) 66 - Ifan openMINDS schema template//doesnot//defineakey**##"_type"##** (asin the firstexampleabove), itis interpretedasa**concept template**which//has to be//extendedtoatarget template.45 +Context templates are and should be used when multiple openMINDS schemas (target templates) have the same subset of properties. This common subset of properties can then be defined within a single context schema instead of each target template which facilitates the long-term maintenance of these properties. 67 67 68 68 (% style="text-align: justify;" %) 69 - Concepttemplates are and should be used when multiple target templates have the same subset of properties, because they facilitate the long-termmaintenance of those sharedproperties:Instead of defining the same properties repeatedly within multiple target templates, the common subset can be defined within a single concept template and passed on to all extending target templates.48 +===== String properties ===== 70 70 71 71 (% style="text-align: justify;" %) 72 - To define that a target template is the extension of a concept template, the target template can state under**##"_extends"##** the relative path to theconcept template. For example, the openMINDS core targettemplate **##Dataset##** extends the core concept template**##researchProduct##** as indicated here:51 +(//**coming soon**//) 73 73 74 -{{code language="json"}} 75 -{ 76 - "_type": "https:~/~/openminds.ebrains.eu/core/Dataset", 77 - "_extends": "products/researchProduct.schema.tpl.json" 78 -} 79 -{{/code}} 80 - 81 81 (% style="text-align: justify;" %) 82 - Notethat this convention requires the concept and corresponding target templates to be located in the same openMINDS metadata modelrepository. Note also that forproperties,the following rules apply for target and concept template:54 +===== Numerical properties ===== 83 83 84 -1. A concept template has to define some properties which will be inherited by all extending target templates. 85 -1. If a concept template additionally states that some of these properties are required, all extending target templates will require the same properties. 86 -1. A target template can require properties of the concept template, that are not explicitly required within the concept template. In such a case, the other target templates extending the same concept template will not require those properties. 87 -1. A target template can (but does not have to) define and require additional properties that were not defined and required in the concept template. These additionally defined and required properties will not be shared with the other target templates extending the same concept template. 88 - 89 89 (% style="text-align: justify;" %) 90 -How to define the expected value of a property will be explained for the different property types in the following sections. 91 - 92 -(% style="text-align: justify;" %) 93 -===== Properties expecting a string value ===== 94 - 95 -(% style="text-align: justify;" %) 96 -Properties that expect values of type string can be defined in large parts in the same way as in JSON-Schema. Without any further formatting requirements the definition of such a property looks like this: 97 - 98 -{{code language="json"}} 99 -{ 100 - "properties": { 101 - "freeStringProperty": { 102 - "type": "string" 103 - } 104 - } 105 -} 106 -{{/code}} 107 - 108 -(% style="text-align: justify;" %) 109 -In accordance with JSON-Schema, it is possible, though, to further define a selected list of built-in formats that are accepted for the expected string. Supported are all [[built-in formats of JSON-Schema Draft 7.0>>https://json-schema.org/understanding-json-schema/reference/string.html#built-in-formats||rel="noopener noreferrer" target="_blank"]]. Assuming that my string property only accepts a value of format "email", the openMINDS syntax is the following: 110 - 111 -{{code language="json"}} 112 -{ 113 - "properties": { 114 - "emailProperty": { 115 - "type": "string", 116 - "_formats": [ 117 - "email" 118 - ] 119 - } 120 - } 121 -} 122 -{{/code}} 123 - 124 -(% style="text-align: justify;" %) 125 -Also like JSON-Schema, it is possible to define a customized regular expression pattern for the expected string, supporting the [[ECMA-262 regex-dialect>>https://www.ecma-international.org/publications-and-standards/standards/ecma-262/]]. Assuming that my string property only accepts a Gregorian calendar year, the corresponding openMINDS syntax look like this: 126 - 127 -{{code language="json"}} 128 -{ 129 - "properties": { 130 - "yearProperty": { 131 - "type": "string", 132 - "pattern": "([0-9]{4})" 133 - } 134 - } 135 -} 136 -{{/code}} 137 - 138 -(% style="text-align: justify;" %) 139 -===== Properties expecting a numerical value ===== 140 - 141 -(% style="text-align: justify;" %) 142 142 (//**coming soon**//) 143 143 144 144 (% style="text-align: justify;" %) 145 -===== Propertiesexpecting another object=====60 +===== Object properties ===== 146 146 147 147 (% style="text-align: justify;" %) 148 148 (//**coming soon**//) 149 149 150 150 (% style="text-align: justify;" %) 151 -===== Propert iesexpectingan arrayof values =====66 +===== Property arrays ===== 152 152 153 153 (% style="text-align: justify;" %) 154 154 (//**coming soon**//)