Item:OSW7113f5cf921a4c82ad1872afeff9d01d
Transcend wikitext to store and edit structured & linked data [OSW7113f5cf921a4c82ad1872afeff9d01d] | |
---|---|
ID | OSW7113f5cf921a4c82ad1872afeff9d01d |
UUID | 7113f5cf-921a-4c82-ad18-72afeff9d01d |
Label | Transcend wikitext to store and edit structured & linked data |
Machine compatible name | TranscendWikitextToStoreAndEditStructuredLinkedData |
Statements (outgoing) | |
.. IsRelatedTo OSW Schema |
|
Statements (incoming) | |
|
|
Keywords |
Description
No description found
Item | |
---|---|
Type(s)/Category(s) | Tutorial |
CreativeWork |
---|
Article |
---|
Tutorial | |
---|---|
Prerequisites (required) | |
Prerequisites (optional) | |
Follow-up (recommended) | JSON Tutorial |
Conventional approach: Using a single slot (main) and multiple pages
You can have
content-model = wikitext
for pages, templates, forms, etc.
Some unstructured text
{{MyTemplate
|param1=value1
}}
{{#aparserfunction:}}
or
content-model = json
without any specific rendering
{
"param1": "value1"
}
Problems:
- you can have rendered page content or structured page content
- content is distributed over multiple pages
Conventional approach: Using a single slot (main) and a single page
Store structured data within nested templates in wikitext
Some unstructured text
{{MyDataTemplate
|text=some text
|number=123
|array=1;two;3.0
|nested={{MySubDataTemplate
|param=value
}}
watch out, i am a nested string
{{MySubDataTemplate
|param=value2
}}
}}
{{#aparserfunction:}}
json-equivalent
{
"@type": "MyDataTemplate",
"text": "some text",
"number": 123,
"array": [1,"two",3.0],
"nested": [{
"@type": "MySubDataTemplate",
"param": "value"
},
"watch out, i am a nested string",
{
"@type": "MySubDataTemplate",
"param": "value"
}]
}
Problems
- Extensions like SMW only cover reading mappend template params as json
- Extensions like PageForms require a individual form to edit the data
- => In general you need a template-parser (e. g. wikitext to json) in your client software at least to edit/write data in general
- => Doing so requires guessing of data types and correct interpretation of arrays
Luckily we have Multi-Content-Revisions (MCR)
Lets add a jsondata
slot
Slot | Content Model |
---|---|
main | wikitext |
jsondata | json |
main
Some unstructured text
{{#aparserfunction:}}
jsondata
{
"@type": "MyDataTemplate",
"text": "some text",
"number": 123,
"array": [1,"two",3.0]
}
Would be nice to validate the json data
Lets add a jsonschema
slot for Category pages
Slot | Content Model |
---|---|
main | wikitext |
jsondata | json |
jsonschema | json |
Category:MyCategory
jsonschema
{
"type": "object",
"properties": {
"text": { "type": "string" },
"number": { "type": "number" },
"array": { "type": "array" }
}
}
Item:MyInstance
jsondata
{
"@type": "MyDataTemplate",
"text": "some text",
"number": 123,
"array": [1,"two",3.0]
}
If we have a jsonschema, we get the editor & validator for free
https://github.com/json-editor/json-editor
Category:MyCategory
jsonschema
{
"type": "object",
"title": "My Form",
"title*": {"de": "Mein Formular"} ,
"properties": {
"color": {
"type": "string",
"format": "color"
},
"number": {
"type": "number",
"description": "not a string!"
}
}
}
Item:MyInstance
jsondata
{
"color": "#ff0000",
"number": "123"
}
Classes, Instances, Inheritance?
Lets add a jsonschema
slot for Category pages
Slot | Content Model |
---|---|
main | wikitext |
jsondata | json |
jsonschema | json |
Category:MyCategory
jsonschema
{
"type": "object",
"properties": {
"text": { "type": "string" },
"number": { "type": "number" },
"array": { "type": "array" }
}
}
Category:MySubCategory
jsonschema
{
"type": "object",
"allOf": "/wiki/Category:MyCategory?action=raw&slot=jsonschema",
"properties": {
"additional_property": { "type": "string" }
}
}
Context and Semantic MediaWiki
Lets add a json-ld context within the jsonschema
slot for Category pages
Slot | Content Model |
---|---|
main | wikitext |
jsondata | json |
jsonschema | json |
Category:MySubCategory
jsonschema
{
"@context": [
"/wiki/Category:MyCategory?action=raw&slot=jsonschema",
{
"schema": "https://schema.org/",
"Property": "<my.domain>/id/",
"image": "schema:image",
"image*": "Property:HasProperty"
}
],
"allOf": "/wiki/Category:MyCategory?action=raw&slot=jsonschema",
"properties": {
"additional_property": { "type": "string" }
}
}
Item:MyInstance jsondata
=> [[HasProperty:{{{additional_property|}}}]]
Interconnection with the wikiparser
Additional slots rendered by the wiki parser
Slot | Content Model | Description |
---|---|---|
main | wikitext | default content slot, rendered between the page header and footer |
jsondata | json | structured data |
jsonschema | json | stored within a category (=class) page, defining the schema for the jsondata slot of any category member (instance) |
header_template | wikitext | stored within a category (=class) page, renders the page header of any category member (instance) |
footer_template | wikitext | stored within a category (=class) page, renders the page footer of any category member (instance) |
header | wikitext | renders the page header via {{#invoke: Entity|header}}* |
footer | wikitext | renders the page footer via {{#invoke: Entity|footer}}* |
Footer / Header templateProperty-specific templates within the schema
Entries of my_list:
{{{my_list|}}}
{
"type": "object",
"properties": {
"my_list": {
"type": "array",
"eval_template": {
"type": "mustache-wikitext",
"value": "{{#my_list}} * [[{{{.}}}]] <br> {{/my_list}}"
}
}
}
}
- *Wiki-side feature are implemented in Lua => To be rewritten in PHP
- Why are parser calls needed at all? Currently there seems no options to provide a hook from the core that allows injecting slot-specific content
Further links
jsondata
recommended_successor |
| |||||||
---|---|---|---|---|---|---|---|---|
type |
| |||||||
uuid | "7113f5cf-921a-4c82-ad18-72afeff9d01d" | |||||||
name | "TranscendWikitextToStoreAndEditStructuredLinkedData" | |||||||
label |
| |||||||
statements |
|