Transcend wikitext to store and edit structured & linked data

From OSL Demo
Item:OSW7113f5cf921a4c82ad1872afeff9d01d /
Revision as of 14:12, 19 April 2023 by Admin (talk | contribs) (Update package: OSW Docs - Core)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

View as slide show

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


📎 Select files (or drop them here)... 📷 Camera
    jsondata
    type
    "Category:OSW494f660e6a714a1a9681c517bbb975da"
    uuid"7113f5cf-921a-4c82-ad18-72afeff9d01d"
    name"TranscendWikitextToStoreAndEditStructuredLinkedData"
    label
    text"Transcend wikitext to store and edit structured & linked data"
    lang"en"
    recommended_successor
    "Item:OSWf1df064239044b8fa3c968339fb93344"
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.