Wikidata/Notes/Inclusion syntax v0.3
|
This page is currently a draft. More information pertaining to this may be available on the talk page.
Translation admins: Normally, drafts should not be marked for translation. |
This page describes the data inclusion syntax for the Wikibase client, by which the properties of data items can be included and rendered on a wiki page using templates. In short: This is how we want Wikipedia articles to include data from Wikidata.
Preliminary
The inclusion syntax presented here is meant to work for simple cases, and only for them.
Complicated cases are currently planned to be realized using Lua. We do not know yet how the binding to Lua will look like, but we are confident that it will be far easier to use than any binding to Wikitext could ever look like. (Lua would be able to access Wikidata items and then programmatically work on them).
Accessing Item Data
Properties of a Wikidata Item can be used via the #property parser function:
{{#property:population}}
This will provide a representation of the value of the population property of the page's default item. The default item is the Wikidata item that is associated with this page via language links.
To access properties of a different item, it has to be specified explicitly, either by id
{{#property:population|id=q12345}}
or the associated Wiki page
{{#property:population|of=Germany}}
Formatting of qualified and sourced values
All values that are preferred are returned. The values also include qualifiers and references.
There are a number of further parameters that can be used to finetune the formatting:
separator: if there are several values, this is used to separate the valuesvalue template: a template to call on each value, with the parametersvalue,qualifiersandreferencesqualifier template: a template to call on each qualifier, using the qualifier property label as the first and the qualifier values as the second parameter. Ignored if there is aqualifiers template.qualifier separator: if there are several qualifiers, this is used to separate them. Ignored if there is aqualifiers template.qualifiers wrapper: a template to call on the qualifiers, using the qualifiers as the parameter. Ignored if there is aqualifiers template. Ignored if there are no qualifiers.qualifiers template: a template to call for all qualifiers, using the qualifier property labels as the argument names and the values as the respective value.qualifiers value separator: if a single qualifier has several values, this is used to separate these valuesreference keyvalue template: a template to call on each key-value pair of a reference, using the key label as the first and the values as the second parameter. Ignored if there is areference template.reference wrapper: a template to call on each reference, using the reference as the parameter. Ignored if there is areference template.references wrapper: a template to call on all references, using the references as the parameter. Ignored if there is areference template. Ignored if there are nor references.reference keyvalue separator: if there are several key-value pairs in one reference, this is used to separate them. Ignored if there is areference template.reference template: a template to call on each references of a value, using the key labels as the argument names and the values as the respective value.reference value separator: if within a reference one key has several values, this is used to separate these valuesreference separator: a separator to use between each reference
There is a (sensible) default value for each of these which can be changed per wiki using the messaging system.
Once you have seen this parameter list, you might understand why we want to use Lua for anything that is not "simple".
Formatting of single values
Items
item display template: a template that is called for items, with the named parameterslabel,link,id,descriptionandproperty
Number
number display template: a template that is called for numbers, with the named parametersformatted value,value,unit, ... (to be defined once the data model is fixed)
Time
time display template: a template that is called for times, with the named parametersiso8601,year,month, ... (to be defined once the data model is fixed)
Coordinate
coordinate display template: a coordinate that is called for times, with the named parameterslatitude,longitude,latitude dms, ... (to be defined once the data model is fixed)
Other
To be defined
Examples
Assumptions
The example assume reasonable default values for the above arguments. The examples assume no references, for simplicity sake. We assume here:
separator:,value template:{{{value}}} {{{qualifiers}}}{{{references}}}qualifier template:{{{1}}} {{{2}}}qualifier separator:,qualifiers wrapper:({{{1}}})qualifiers template: emptyqualifiers value separator:,reference keyvalue template:{{{1}}} {{{2}}}reference wrapper:<ref>{{{1}}}</ref>references wrapper:{{{1}}}reference keyvalue separator:,reference template: emptyreference value separator:,reference separator: a separator to use between each reference
Example 1
Given the following statement:
Berlin
| Population | 3,500,000 | [no sources] |
| as of 2012 |
{{#property:population}} will display as "3,500,000 (as of 2012)"
Example 2
Given the following statement:
and assuming that Template:Nothing is defined as empty, and there are articles for Angela Merkel and the CDU in the client wiki and these articles are linked to Wikidata:
{{#property:Chancellor}}will display as "Angela Merkel (since 2005, Party CDU)[1][2]"{{#property:Chancellor|qualifiers template=Nothing}}will display as "Angela Merkel[3][4]"
Example 3
Given the following statement:
and assuming that Template:Nothing is defined as empty, and there are articles for Estimate but not for Census in the client wiki and Estimate is linked to Wikidata and the Census item has a label:
{{#property:Population}}will display as "12,479,608 (as of 2011, Method Census)[5], 21,000,000 (Method Estimate)[6][7]"{{#property:Population|qualifiers template=Nothing|separator= or }}will display as "12,479,608[8] or 21,000,000[9][10]"{{#property:Population|qualifiers template=Nothing|reference template=Nothing|separator= or }}will display as "12,479,608 or 21,000,000"