Item:OSW7113f5cf921a4c82ad1872afeff9d01d
mNo edit summary |
(Update package: OSW Docs - Core) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 174: | Line 174: | ||
</div> | </div> | ||
<div style="break-inside: avoid;"> | <div style="break-inside: avoid;"> | ||
<div class="JsonEditor json-editor-compact" data-config='{"schema": { | <div class="JsonEditor json-editor-compact" style="font-size:medium" data-config='{"schema": { | ||
"type": "object", | "type": "object", | ||
"title": "My Form", | "title": "My Form", | ||
Line 337: | Line 337: | ||
== Further links == | == Further links == | ||
* https://github.com/OpenSemanticLab (The software stack behind | * https://github.com/OpenSemanticLab (The software stack behind) | ||
* Google structured data validator: https://search.google.com/test/rich-results/result?id=hbvnEP-_VO0pG-KPPLLkDQ | * Google structured data validator: https://search.google.com/test/rich-results/result?id=hbvnEP-_VO0pG-KPPLLkDQ | ||
* Schema PagePackages: https://github.com/orgs/OpenSemanticWorld-Packages/repositories | * Schema PagePackages: https://github.com/orgs/OpenSemanticWorld-Packages/repositories | ||
jsondata | |||
---|---|---|---|
Line 1: | Line 1: | ||
{ | { | ||
"recommended_successor": [ | |||
"Item:OSWf1df064239044b8fa3c968339fb93344" | |||
], | |||
"type": [ | "type": [ | ||
"Category:OSW494f660e6a714a1a9681c517bbb975da" | "Category:OSW494f660e6a714a1a9681c517bbb975da" | ||
Line 11: | Line 14: | ||
} | } | ||
], | ], | ||
" | "statements": [ | ||
"Item: | { | ||
"uuid": "65cb09b2-cbab-4bf0-8e0b-0aa21ec68c2f", | |||
"predicate": "Property:IsRelatedTo", | |||
"object": "Item:OSWab674d663a5b472f838d8e1eb43e6784" | |||
} | |||
] | ] | ||
} | } |
Latest revision as of 07:03, 13 November 2024
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 |
|