2012-10-22

chg

← Older revision

Revision as of 00:11, 23 October 2012

(One intermediate revision by one user not shown)

Line 17:

Line 17:

[[Is capital of::Germany]]

[[Is capital of::Germany]]



In the article, this text still is displayed as a simple hyperlink to «Germany». The additional text capital of is the name of the '''property''' that classifies the link to Germany. As in the case of categories, the name of the property is arbitrary, but users should try to re-use properties that already appear elsewhere.

+

In the article, this text still is displayed as a simple hyperlink to «Germany». The additional text
Is
capital of is the name of the '''property''' that classifies the link to Germany. As in the case of categories, the name of the property is arbitrary, but users should try to re-use properties that already appear elsewhere.

To simplify this re-use, every property has its own article in the wiki, just as every category has an article.  You can see all the properties in use in the wiki with the [[Special:Properties]] page. Just as category articles are prefixed with Category:, all property articles are prefixed with Property: to distinguish them from other articles. So you can also also use MediaWiki's [[Special:Search]] page to find existing properties. As with categories, a property's article can be empty, but it is strongly recommended to add a description that explains the intent of the property and its proper usage.

To simplify this re-use, every property has its own article in the wiki, just as every category has an article.  You can see all the properties in use in the wiki with the [[Special:Properties]] page. Just as category articles are prefixed with Category:, all property articles are prefixed with Property: to distinguish them from other articles. So you can also also use MediaWiki's [[Special:Search]] page to find existing properties. As with categories, a property's article can be empty, but it is strongly recommended to add a description that explains the intent of the property and its proper usage.

Line 51:

Line 51:

3,396,990

3,396,990



in the article, identifying it as a value for the "population
property
". With Semantic MediaWiki, this is done by putting the property name and '''::''' in front of the text and surrounding it with
[[ ]]
brackets, thus:

+

in the article, identifying it as a value for the "
Has
population"
property
. With Semantic MediaWiki, this is done by putting the property name and '''::''' in front of the text and surrounding it with
[[ ]]
brackets, thus:

[[Has population::3,396,990]].

[[Has population::3,396,990]].



This works fine. However, it creates a link to a ''3,396,990'' page, and having an article for every population value probably does not make sense. Furthermore, if you wanted to create a list of all German cities ordered by population, numeric order is different from the alphabetical order that you would expect for article names. For example, in alphabetical order, "1,000,000" comes before "345". We want to be able to tell Semantic MediaWiki that "population" is a number, not a link to a page in the wiki. The way to do this is to specify a '''type''' for the "population" property; see the section on [[#Datatypes for properties|datatypes]] for more information.

+

This works fine. However, it creates a link to a ''3,396,990'' page, and having an article for every population value probably does not make sense. Furthermore, if you wanted to create a list of all German cities ordered by population, numeric order is different from the alphabetical order that you would expect for article names. For example, in alphabetical order, "1,000,000" comes before "345". We want to be able to tell Semantic MediaWiki that "
Has
population" is a number, not a link to a page in the wiki. The way to do this is to specify a '''type''' for the "
Has
population" property; see the section on [[#Datatypes for properties|datatypes]] for more information.

=== Naming of properties ===

=== Naming of properties ===

Line 71:

Line 71:



Semantic MediaWiki has several built-in ''datatypes'' from which we can choose for properties. For our previous population example, the appropriate datatype is [[Help:Type Number|Number]]. We want to
give
property "population" a special property that specifies it has the datatype "number". To support this, Semantic MediaWiki has a built-in special property called [[Property:Has type|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:

+

Semantic MediaWiki has several built-in ''datatypes'' from which we can choose for properties. For our previous population example, the appropriate datatype is [[Help:Type Number|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 [[Property:Has type|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]]

[[Has type::number]]

Line 79:

Line 79:

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.

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 "capital of" property above is that the default data type is [[Help:Type Page|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 SMW website to [[Help:Configuration#smwgPDefaultType|change the default datatype]].

+

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 [[Help:Type Page|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 SMW website to [[Help:Configuration#smwgPDefaultType|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:

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

Show more