Help:Property declaration

Help:Property declarationOutdated properties
Table of Contents

This help page informs about how to declare properties. Semantic MediaWiki has several built-in datatypes from which we can choose for properties. For our previous population example, the appropriate datatype is Number. We want to assign to property "Has population" a special property that specifies it has the datatype "number". To support this, Semantic MediaWiki has a built-in special property called Has type. We use the same syntax for this special property as for any other property, so on the Property:Population page, we write the following which specifies the datatype of the property:

[[Has type::number]]

Semantic MediaWiki knows a number of special properties like Has type. Regardless of whether these properties have their own articles in the wiki, they have a special built-in meaning and are not evaluated like other properties.

Datatypes are very important for evaluating properties. Firstly, the data type determines how tools should handle the given values, e.g. for displaying values and sorting values in search results. Secondly, the data type is required to understand which values have the same meaning, e.g. the values "1532", "1,532", and "1.532e3" all encode the same number. Finally, some data types have special behavior, as will be described below. For these reasons, every property used should be defined with a data type.

The reason we didn't have to specify a data type for the "Is capital of" property above is that the default data type is Page, which displays as a link. Even though the datatype Page is the default, you should explicitly specify a datatype for every property, just to prevent confusion or later redefinition with an unintended type. It is also possible for the administrator of an website using Semantic MediaWiki to change the default datatype.

The same mark-up for properties that are links to pages also works for properties of other datatypes. Here are some more examples:

What it does What you type
Assign the value 1,234,567 to the property "Has population".
This country has a population of [[Has population::1,234,567]]."
Assign a numeric value, but showing different text in the article.
This country has a population of [[Has population::999,331|about a million]].
Specifying the type in a property's article, e.g.
This property is a number.
This property is a [[Has type::number]].
Display a web link by using a property of type "URL".
Find us online at [[Has website::]].
Display a "mailto" link by using a property of type "Email"
You can reach John at [[Has email]].

NoteNote:  One cannot include a full stop "." like in [[Foo.Bar::Baz]] in a property name since this conflicts with the syntax for creating property chains.

List of datatypes[edit]

Table of Contents

Using different datatypes, properties can be used to describe very different kinds of values. A complete list of all 17 datatypes provided by Semantic MediaWiki and 1 provided by other semantic extensions is available from special page "Types". The available 18 datatypes are:

DatatypeDescriptionIDHelp pagein this wikiProvided by
Annotation URIHolds URIs, but has some technical differences during export compared to the "URL" type
Help:Datatype "Annotation URI"Types/Annotation URISemantic MediaWiki
BooleanHolds boolean (true/false) values
Help:Datatype "Boolean"Types/BooleanSemantic MediaWiki
CodeHolds technical, pre-formatted texts (similar to datatype Text)
Help:Datatype "Code"Types/CodeSemantic MediaWiki
DateHolds particular points in time
Help:Datatype "Date"Types/DateSemantic MediaWiki
EmailHolds e-mail addresses
Help:Datatype "Email"Types/EmailSemantic MediaWiki
External identifierHolds a value that associates it with with a external URI for formatting
Help:Datatype "External identifier"Types/External identifierSemantic MediaWiki
Geographic coordinatesHolds coordinates describing geographic locations
Help:Datatype "Geographic coordinates"Types/Geographic coordinatesMaps (Semantic Maps)
KeywordHolds text of restricted length that is being normalised (similar to datatype Text)
Help:Datatype "Keyword"Types/KeywordSemantic MediaWiki
Monolingual textHolds a text value that associates the annotation with a specific language code
Help:Datatype "Monolingual text"Types/Monolingual textSemantic MediaWiki
NumberHolds integer and decimal numbers, with an optional exponent
Help:Datatype "Number"Types/NumberSemantic MediaWiki
PageHolds names of wiki pages, and displays them as a link
Help:Datatype "Page"Types/PageSemantic MediaWiki
QuantityHolds values that describe quantities, containing both a number and a unit
Help:Datatype "Quantity"Types/QuantitySemantic MediaWiki
RecordHolds compound property values that consist of a short list of values with fixed type and order
Help:Datatype "Record"Types/RecordSemantic MediaWiki
Telephone numberHolds international telephone numbers based on the RFC 3966 standard
Help:Datatype "Telephone number"Types/Telephone numberSemantic MediaWiki
TemperatureHolds temperature values (similar to type Quantity)
Help:Datatype "Temperature"Types/TemperatureSemantic MediaWiki
TextHolds text of arbitrary length
Help:Datatype "Text"Types/TextSemantic MediaWiki
ReferenceHolds a value that associates it to individual defined provenance metadata record
Help:Datatype "Reference"Types/ReferenceSemantic MediaWiki
URLHolds URIs, URNs and URLs
Help:Datatype "URL"Types/URLSemantic MediaWiki

Example values and formatting[edit]

Datatype Property Example value Query display Query display using #- (plain)
Annotation URI Property:Has annotation uri
Boolean Property:Has boolean true true true
Code Property:Has code
is preserved but variables are expanded, e.g:
Help:Property declaration
is displayed as the name of this page instead of FULLPAGENAME
is preserved but variables are expanded, e.g:
Help:Property declaration
is displayed as the name of this page instead of FULLPAGENAME
is preserved but variables are expanded, e.g:
Help:Property declaration
is displayed as the name of this page instead of FULLPAGENAME
Date Property:Has date 2015-05-22T17:32 22 May 2015 17:32:00 2015-05-22T17:32:00
External_identifier Property:Has SMW issue ID 1218 1218 1218
EMail Property:Has email address
Geographic coordinate Property:Has coordinates 32° 42' 54.00" N, 117° 9' 45.00" W 32° 42' 54.00" N, 117° 9' 45.00" W 32° 42' 54.00" N, 117° 9' 45.00" W
Keyword Property:Has keyword TestKeyword TestKeyword TestKeyword
Number Property:Has number 47000.11 47,000.11 47000.11
Monolingual text Property:Has mlt Monoglingual text in english (en)Einsprachiger Text auf Deutsch (de)Texte monoglinguel en français (fr) Monoglingual text in english (en), Texte monoglinguel en français (fr), Einsprachiger Text auf Deutsch (de) Monoglingual text in english (en), Texte monoglinguel en français (fr), Einsprachiger Text auf Deutsch (de)
Page Property:Has example Semantic MediaWiki Semantic MediaWiki Semantic MediaWiki
Quantity Property:Has area 1052km²406.18 sqmi <br /> 1,052.00 km²406.18 sqmi <br /> 1052.00 km²
Reference Property:Has Wikidata reference Q190087 <a href="" target="_blank">Q190087</a> <a href="" target="_blank">Q190087</a>
Record Property:Has conservation status Dodo (Extinct, 2012) Dodo (Extinct, 2012) Dodo (Extinct, 2012)
Telephone number Property:Telephone number +1-800-225-5288 +1-800-225-5288
Temperature Property:Has temperatureExample 23°C296.15 K <br />73.4 °F <br />533.07 °R <br /> 296.15 K23 °C <br />73.4 °F <br />533.07 °R <br /> 296.15 K
Text Property:SomeProperty Did you create the page for Tokyo 東京 ? Yes ✓ Did you create the page for Tokyo 東京 ? Yes ✓ Did you create the page for Tokyo 東京 ? Yes ✓
URL Property:Has_URL

Enumerations and "Allows value"[edit]

In addition to assigning a datatype to a property, you can also restrict the allowed values to a given set (like a whitelist for property inputs). This is done by using the special property Property:Allows value to enumerate its permitted values. This works for every datatype.


The datatype Quantity allows a unit after the numeric value to distinguish values (e.g. "30 miles" versus "42 km"). To support automatic conversion and multiple unit formats, one needs to declare each supported unit as described in the documentation on custom units. Property values are then automatically converted between different units, so that users are free to use their preferred unit in each article yet still query and compare with property values in other articles.

Handling in earlier versions[edit]

Up to Semantic MediaWiki 1.5.6, datatypes had individual wiki pages in their own namespace called "Type". This was abolished to reduce the number of extra namespaces. You may still find expressions like "Type:Number" in places in this wiki. Both writings are accepted for assigning a datatype to a property.

In very early versions of SMW, properties with datatype Page were known as relations and only those used double colons (::) as the separator between property name and link text. All other properties (numbers, text, etc.) were known as attributes and had to use colon equals (:=) as the separator.

See Upgrading from SMW 0.7 to SMW 1.0 for other changes in SMW 1.0; if you're still using the older version of SMW, see semweb:Help:Annotation (SMW0.7) for documentation of Annotations in version 0.7.

Special properties[edit]

We mentioned the special property Property:Has type that you use to define the data type of a property. Semantic MediaWiki has other predefined special properties that have special meaning (even if you do not create property pages for them in your wiki). You cannot use these names for your own properties, but since Semantic MediaWiki 1.4.0 you can use them in browsing and querying interfaces just like all other properties. For more information, see special properties help and the individual property pages.

See also[edit]