Help:Property declaration

From semantic-mediawiki.org
Help:Property declarationOutdated properties

This help page informs about how to declare properties. Semantic MediaWiki has several built-in datatypes from which we can choose for properties.

If one wants for example create a property called "Population", the appropriate datatype is datatype "Number"Holds integer and decimal numbers, with an optional exponent. To do this a special property that specifies that it has the datatype "Number" has to be assigned to the property's page. To support this, Semantic MediaWiki has a built-in special property called "Has type". The same syntax for this special property as for any other property is used, so on the property "Population" page, the following mark-up is added which specifies the datatype of the property:

[[Has type::Number]] or {{#set: Has type=Number }}

Semantic MediaWiki provides a number of special properties like special property "Has type"Assigns a datatype to a property. 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 datatype determines how tools should handle the given values, e.g. for displaying values and sorting values in search results. Secondly, the datatype 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 datatypes have special behavior. For these reasons, every property used should be defined with a datatype.

If one wants to create a property like e.g. "Is captial of" a datatype does not necessarily has to be specified since the default datatype for all properties with no explicit datatype declaration is datatype "Page"Holds names of wiki pages, and displays them as a link, which displays assigned values as a link. However, 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 datatype. It is also possible for the administrator of a wiki 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::http://example.com]].
Display a "mailto" link by using a property of type "Email" You can reach John at [[Has email address::john@example.com]].
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.

Datatypes[edit]

There are many datatypes available to declare the basic characteristics of a property. See here for a list of datatypes.

Special properties[edit]

We mentioned special property "Has type"Assigns a datatype to a property that you use to define the datatype 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.0Released on 21 November 2008 and compatible with MW 1.13.x - 1.16.x. you can use them in browsing and querying interfaces just like all other properties. For more information, see the help page on special properties and the individual property pages.

Note[edit]

If for some reason, e.g. a misconfiguration of the wiki via the "LocalSettings.php" file or due to a conflicting extension, the "Property" namespace does not allow for annotations as it should and error message is displayed to inform users about it.1 In this case the system administrator of the wiki needs to be contacted to investigate and rectify the issue.

See also[edit]


References

  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:4686