„Wikipedia:Lua/Modul/WikidataScheme/Specification“ – Versionsunterschied
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
Setup |
+ |
||
Zeile 22: | Zeile 22: | ||
* An entity used in several places may change pointer at once. |
* An entity used in several places may change pointer at once. |
||
* The assignment may differ in development. Just apply another resolving map. Actually there are three different Wikibase installations available: |
* The assignment may differ in development. Just apply another resolving map. Actually there are three different Wikibase installations available: |
||
*# Productive Wikidata https://www.wikidata.org/ |
*# Productive Wikidata – https://www.wikidata.org/ |
||
*# WMF test Wikidata |
*# WMF test Wikidata – https://test.wikidata.org/ |
||
*# BETA Wikidata (wmflabs) |
*# BETA Wikidata (wmflabs) – https://wikidata.beta.wmflabs.org/ |
||
Naturally, all expected symbolic names are to be resolved, otherwise an error is shown in displayed table. |
Naturally, all expected symbolic names are to be resolved, otherwise an error is shown in displayed table. |
||
Zeile 40: | Zeile 40: | ||
***; style |
***; style |
||
***: Mapping table or ''string'' with [[Cascading Style Sheets|CSS]] for this text element |
***: Mapping table or ''string'' with [[Cascading Style Sheets|CSS]] for this text element |
||
The resulting strings may contain basic markup: |
The resulting strings may contain balanced basic markup: |
||
* For italic and bold, <code><nowiki>''</nowiki></code> and <code><nowiki>'''</nowiki></code> wikisyntax |
* For italic and bold, <code><nowiki>''</nowiki></code> and <code><nowiki>'''</nowiki></code> wikisyntax |
||
* Internal links, with <code style="white-space:nowrap"><nowiki>[[double bracket]]</nowiki></code> syntax, beginning with global project prefix. |
* Internal links, with <code style="white-space:nowrap"><nowiki>[[w:de:double bracket]]</nowiki></code> syntax, beginning with global project prefix. |
||
* External links, with <code style="white-space:nowrap"><nowiki>[single bracket]</nowiki></code> syntax, beginning with protocol ''http https ftp''. |
* External links, with <code style="white-space:nowrap"><nowiki>[http://single bracket]</nowiki></code> syntax, beginning with protocol ''http https ftp''. |
||
* Whitelisted HTML elements, like ''span div bdi bdo code pre ul ol li dl dt dd em strong b i table caption tr th td''. |
* Whitelisted HTML elements, like ''span div bdi bdo code pre ul ol li dl dt dd em strong b i table caption tr th td''. |
||
=== Entry === |
=== Entry === |
||
This is used for both <code>claims</code> and <code>qualifiers</code>. |
This is used for both <code>claims</code> and rather similar for <code>qualifiers</code>. |
||
* |
* Sequence table, with each element as mapping table of the following (mostly optional) components: |
||
*; subject |
*; {{Anker|subject}} subject |
||
*: Property name, P-number or symbolic name resolved by [[#NameResolver|NameResolver]] as P-number. |
*: Property name, P-number or symbolic name resolved by [[#NameResolver|NameResolver]] as P-number. |
||
*: Mandatory. |
|||
⚫ | |||
*; {{Anker|intro}} intro |
|||
*: General description, introduction |
*: General description, introduction |
||
*: [[#TextVariant|TextVariant]] |
*: [[#TextVariant|TextVariant]] |
||
*; state |
*; {{Anker|state}} state |
||
*: One of: <code>"required"</code>, <code>"suggested"</code>, <code>"deprecated"</code>, otherwise <code>"optional"</code> |
*: One of: <code>"required"</code>, <code>"suggested"</code>, <code>"deprecated"</code>, otherwise <code>"optional"</code> |
||
*; values |
*; values |
||
*: Sequence table (array) of mapping tables. Each with the |
*: Sequence table (array) of mapping tables. |
||
*: Each element with the optional components in [[#Detail|Detail]]. |
|||
*; {{Anker|example}} example |
|||
*:; q |
|||
⚫ | |||
⚫ | |||
⚫ | |||
*:; qlist |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
*: Example value, text |
*: Example value, text |
||
*: [[#TextVariant|TextVariant]] |
*: [[#TextVariant|TextVariant]] |
||
*; terminate |
*; {{Anker|terminate}} terminate |
||
*: Final remarks |
*: Final remarks |
||
*: [[#TextVariant|TextVariant]] |
*: [[#TextVariant|TextVariant]] |
||
Zeile 80: | Zeile 70: | ||
*; style |
*; style |
||
*: Mapping table or ''string'' with [[Cascading Style Sheets|CSS]] for entire unit |
*: Mapping table or ''string'' with [[Cascading Style Sheets|CSS]] for entire unit |
||
=== Detail === |
|||
* One single value of statement. |
|||
* Sequence table, with each element as mapping table of the following optional components: |
|||
⚫ | |||
*; {{Anker|q}} q |
|||
⚫ | |||
⚫ | |||
⚫ | |||
*; {{Anker|qlist}} qlist |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
*: Sequence table, of [[#Qualifier|Qualifier]] |
|||
⚫ | |||
*; [[#terminate|terminate]] |
|||
=== Qualifier === |
|||
This is rather similar to <code>claims</code>. |
|||
* One single qualifier. |
|||
* Sequence table, with each element as mapping table of the following (mostly optional) components: |
|||
*; [[#subject|subject]] |
|||
*: Mandatory. |
|||
*; [[#state|state]] |
|||
*; [[#intro|intro]] |
|||
*; [[#q|q]] |
|||
*: if not <code>qlist</code> |
|||
*; [[#qlist|qlist]] |
|||
*: if not <code>q</code> |
|||
*; [[#example|example]] |
|||
*; [[#terminate|terminate]] |
|||
== {{Anker|root}} Root Element == |
== {{Anker|root}} Root Element == |
||
Using all definitions of [[# |
Using all definitions of [[#Building blocks|building blocks]], the specification is defined as follows: |
||
* Mapping table created from the following components: |
* Mapping table created from the following optional components: |
||
*; caption |
*; caption |
||
*: Table or gadget title |
*: Table or gadget title |
||
Zeile 98: | Zeile 122: | ||
*; claims |
*; claims |
||
*: Statements (actually mandatory) |
*: Statements (actually mandatory) |
||
⚫ | |||
*; footer |
*; footer |
||
*: Terminating hints, remarks, legend |
*: Terminating hints, remarks, legend |
||
Zeile 119: | Zeile 144: | ||
* A ''sequence table'' in Lua is an ''Array'' <code style="white-space:nowrap">[ ]</code> in JSON. |
* A ''sequence table'' in Lua is an ''Array'' <code style="white-space:nowrap">[ ]</code> in JSON. |
||
* Both textual JSON and Lua tables may be provided. |
* Both textual JSON and Lua tables may be provided. |
||
* Lua specifications may be |
* Lua specifications may be passed by general module call, or by providing a generating <code style="white-space:nowrap">mw.loadData()</code> page name. |
||
* A number of specifications may be created programmatically, e.g. fundamentals of a human being, then forking into opera singer, rock & pop |
* A number of specifications may be created programmatically, e.g. fundamentals of a human being, then forking into opera singer, rock & pop musicians, composer, painter, writer, … |
||
== Example == |
== Example == |
||
{{#tag:syntaxhighlight| |
|||
{{#rel2abs:../../GlobalSharing/Wikidata}} |
{{#invoke:WikidataScheme|format|1={{:{{#rel2abs:../../GlobalSharing/Wikidata}}}}}} |
||
| lang=json}} |
Version vom 11. Dezember 2019, 23:35 Uhr
Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
This page describes the data structure used for a WikidataScheme specification.
A root element is to be provided.
Building blocks
EntityName
This can be either:
- A Wikidata entity ID, beginning with P, Q, L and followed by digits:
Q1
- A symbolic name.
- This is required to be resolved by NameResolver.
NameResolver
This is a mapping table resolve
in root element which assigns:
- symbolic name
- mapping table as follows:
- assign a number to (at least) one of the components
P
,Q
,L
. - Basically more than one component may be present, but the first one found in that order will be used.
- assign a number to (at least) one of the components
The motivation to use a symbolic name is:
- The thematic description becomes more intuitive; described by self explaining words only.
- An entity used in several places may change pointer at once.
- The assignment may differ in development. Just apply another resolving map. Actually there are three different Wikibase installations available:
- Productive Wikidata – https://www.wikidata.org/
- WMF test Wikidata – https://test.wikidata.org/
- BETA Wikidata (wmflabs) – https://wikidata.beta.wmflabs.org/
Naturally, all expected symbolic names are to be resolved, otherwise an error is shown in displayed table.
The JSON function may be used to resolve all symbolic names and generates pretty formatted JSON with entity IDs only.
TextVariant
This can be either:
- A string, with Wikidata entity ID only, beginning with P, Q, L and followed by digits (label will be used)
- A string, with constant text otherwise
- A mapping table, which assigns an ISO 639 / BCP47 key to a text string.
- There should be always present at least:
{ "en": "Fallback text" }
- In addition to language codes, the following two components are processed:
- class
- Sequence table (array) or string with class names for this text element
- style
- Mapping table or string with CSS for this text element
- There should be always present at least:
The resulting strings may contain balanced basic markup:
- For italic and bold,
''
and'''
wikisyntax - Internal links, with
[[w:de:double bracket]]
syntax, beginning with global project prefix. - External links, with
[http://single bracket]
syntax, beginning with protocol http https ftp. - Whitelisted HTML elements, like span div bdi bdo code pre ul ol li dl dt dd em strong b i table caption tr th td.
Entry
This is used for both claims
and rather similar for qualifiers
.
- Sequence table, with each element as mapping table of the following (mostly optional) components:
- subject
- Property name, P-number or symbolic name resolved by NameResolver as P-number.
- Mandatory.
- intro
- General description, introduction
- TextVariant
- state
- One of:
"required"
,"suggested"
,"deprecated"
, otherwise"optional"
- values
- Sequence table (array) of mapping tables.
- Each element with the optional components in Detail.
- example
- Example value, text
- TextVariant
- terminate
- Final remarks
- TextVariant
- class
- Sequence table (array) or string with class names for entire unit
- style
- Mapping table or string with CSS for entire unit
Detail
- One single value of statement.
- Sequence table, with each element as mapping table of the following optional components:
- intro
- q
- The one and only permitted value as item
- EntityName as Q-number.
- Must not be used together with
qlist
. - qlist
- Sequence table (array) of items, each of them:
- Item, as EntityName as Q-number.
- Last element may be
true
which indicates that other items than explicitly mentioned are permitted as well.
- Must not be used together with
q
. - qualifiers
- Permitted within
claims.values
only. - Sequence table, of Qualifier
- example
- terminate
Qualifier
This is rather similar to claims
.
- One single qualifier.
- Sequence table, with each element as mapping table of the following (mostly optional) components:
Root Element
Using all definitions of building blocks, the specification is defined as follows:
- Mapping table created from the following optional components:
- caption
- Table or gadget title
- TextVariant
- onLabel
- Naming convention and expectations on label text
- TextVariant
- onDesc
- Formatting and expectations on description text
- TextVariant
- onAlias
- Formatting and expectations on aliases texts
- TextVariant
- claims
- Statements (actually mandatory)
- Sequence table of Entry
- footer
- Terminating hints, remarks, legend
- TextVariant
- id
- string, selector for entire table
- class
- Sequence table (array) or string with class names for entire table
- style
- Mapping table or string with CSS for entire table
- options
- Mapping table, override local /config
- resolve
- Mandatory if symbolic names occurring.
- NameResolver
- While all components are optional a specification without
claims
is pointless. - More components are permitted but not evaluated.
JSON and Lua
- A mapping table in Lua is an object
{ }
in JSON. - A sequence table in Lua is an Array
[ ]
in JSON. - Both textual JSON and Lua tables may be provided.
- Lua specifications may be passed by general module call, or by providing a generating
mw.loadData()
page name. - A number of specifications may be created programmatically, e.g. fundamentals of a human being, then forking into opera singer, rock & pop musicians, composer, painter, writer, …
Example
{ "@generated": "2025-07-03T21:11:23+02:00",
"@format": "WikidataScheme 2019-12-16",
"claims": [
{ "subject": "instance",
"state": "required",
"values": [
{
"qlist": [ "template",
"module",
"gadget",
true ]
}
]
},
{ "subject": "proglang",
"state": "suggested",
"values": [
{
"qlist": [ "lua",
"javascript",
"json",
"css" ]
}
]
},
{ "subject": "source",
"state": "suggested",
"values": [
{
"intro": "Q42253",
"qualifiers": [
{ "subject": "protocol",
"state": "required",
"q": "https"
},
{ "subject": "host",
"state": "optional",
"qlist": [ "enwiki",
"dewiki",
"mediawikiwiki",
"git",
true ]
}
]
}
]
},
{ "subject": "version",
"state": "suggested",
"values": [
{
"intro": {
"de": "Versionsbezeichnung größer als die vorangehende",
"en": "Revision ID greater than previous",
"it": "ID versione maggiore della precedente",
"ru": "Идентификатор версии выше предыдущего"
}
}
]
},
{ "subject": "licence",
"state": "suggested",
"values": [
{
"qlist": [ "Q14946043",
"Q18199165" ]
}
]
},
{ "subject": "usedby",
"state": "optional",
"values": [
{
"intro": {
"de": "Bekannte Verwendungen, oder übergeordnete Einheit",
"en": "Known usages, and root software of a sub unit",
"it": "Applicazioni note o unità supoeriore",
"ru": "Известное использование или родительская программная единица"
}
}
]
},
{ "subject": "uses",
"state": "optional",
"values": [
{
"intro": {
"de": "Abhängigkeiten, benötigte Ressourcen, aus anderen Paketen oder Untereinheiten",
"en": "Dependencies, required resources, from other packages or sub units",
"it": "Dipendenze, risorse necessarie, da altri pacchetti o da unità inferiori",
"ru": "Зависимости, требуемые ресурсы, из других пакетов или подъединиц"
}
}
]
},
{ "subject": "doc",
"state": "suggested",
"values": [
{
"intro": "Q42253",
"qualifiers": [
{ "subject": "protocol",
"state": "required",
"q": "https"
},
{ "subject": "host",
"state": "optional",
"qlist": [ "enwiki",
"dewiki",
"mediawikiwiki",
true ]
},
{ "subject": "lang",
"state": "optional",
"qlist": [ "en",
"de",
true ]
}
]
}
]
},
{ "subject": "tags",
"state": "optional",
"values": [
{
"intro": {
"de": "Tagging, Themen, Schlagwörter",
"en": "Tagging, topics, keywords",
"it": "Tag, materie, parole chiave",
"ru": "Тегинг, темы, ключевые слова"
}
}
]
}
],
"resolve": { "css": { "Q": 46441 },
"de": { "Q": 188 },
"dewiki": { "Q": 48183 },
"doc": { "P": 973 },
"en": { "Q": 1860 },
"enwiki": { "Q": 328 },
"gadget": { "Q": 61866692 },
"git": { "Q": 186055 },
"host": { "P": 137 },
"https": { "Q": 44484 },
"instance": { "P": 31 },
"javascript": { "Q": 2005 },
"json": { "Q": 2063 },
"lang": { "P": 407 },
"licCC3": { "Q": 14946043 },
"licence": { "P": 275 },
"lua": { "Q": 207316 },
"mediawikiwiki": { "Q": 15633578 },
"module": { "Q": 15184295 },
"proglang": { "P": 277 },
"protocol": { "P": 2700 },
"source": { "P": 1324 },
"tags": { "P": 366 },
"template": { "Q": 11266439 },
"usedby": { "P": 1535 },
"uses": { "P": 2283 },
"version": { "P": 348 }
}
}