Help:Import vocabulary

From NYC Resistor Wiki
Jump to: navigation, search

SMW user manual


Browsing and searching

Browsing interfaces

Semantic search


Properties and types

Custom units

Semantic templates

Inline queries

Service links

Semantic Web

OWL/RDF export

External tools

Importing vocabulary

Ontology import

In Semantic MediaWiki it is possible to import and reuse vocabulary that belongs to existing Semantic Web documents or standards by associating the vocabulary's elements with wiki terms. An example of this functionality is the use of the FOAF vocabulary in the wiki. Although the associated terms work like any other annotation in the wiki, the RDF that is exported will directly use the elements of the FOAF specification, thus allowing users to edit FOAF files through the wiki.

Example: importing foaf:knows[edit]

Normally, all concepts that can be described (and be used for description) in the wiki are defined by the wiki and thus are local. So the URI that RDF export uses to denote a concept is usually from a specific namespace that should be used only by the wiki. Even if you create a property that seems to come from a well-known vocabulary because you name it foaf:knows, it would still be exported with the URI


which is the XML-compatible URI derived from the article URL (see Help:RDF export for details). Semantic MediaWiki's mechanism for importing vocabularies solves this problem by allowing the reuse of external vocabulary in a controlled way. After an administrator makes the external vocabulary available, any user can state that a term in the wiki matches an imported element by adding the following text to its article:

[[imported from::foaf:knows]]

The special property imported from tells SMW that the wiki's property really refers to the property from the FOAF vocabulary.

The wiki article doesn't have to be named "Property:foaf:knows", the user could choose any name to represent the property within the wiki. ( uses "foaf:knows" here since the community in this wiki is expected to have some technical background; In another wiki, one might prefer a less technical name.)

In order to interpret the above "imported from" statement, the wiki needs to understand the meaning of "foaf:knows" as a shorthand for "". This is the case for "foaf:knows" since the wiki administrator has made this property available for this purpose. The section on importing further vocabularies describes how you can find out which elements are available, how new elements can be added, and what the idea behind this "control mechanism" is.

Importing properties[edit]

Basically, all known elements can be imported as described above. When importing properties, there is a minor additional effect: the imported element will also define the datatype of the property. In this example, the property foaf:name is declared as a string merely through its import statement. If you import a property, remove its "has type" statement.

Importing further vocabularies[edit]

As explained above, not every element of some external vocabulary can be imported. The easiest way for finding out whether something is available for import is to try importing it with a statement as the above. If this does not work, a message in the factbox will inform you about the problem. Possible reasons are:

  1. The namespace (e.g. "foaf:") is not available at all. The wiki does not know what it refers to, and it does not support any elements from this range.
  2. The specific element (e.g. "foaf:knows") is not available in the (known) namespace "foaf:".
  3. The element is known, but it cannot be imported for the specific kind of page you are trying to use it on. For example, you cannot import foaf:knows on a page in the wiki-namespace "Category:" since it should always be a "Property:".

In the last case, you can fix the problem by using an appropriate article for import. In the other cases, you only users with administrator privileges can add the unknown vocabulary elements. This can be done very quickly by modifying the wiki (see below), but there are also cases in which some vocabulary is not made available on purpose. Possible reasons for this are:

  • The element you wish to use is not recommended for public use yet, or its correct use is still discussed in the community. An example of this is foaf:OnlineEcommerceAccount.
  • The specification of the chosen vocabulary is too ambiguous or preliminary for current use. It might become more precise later which would affect the usage in the wiki (or render its earlier usage incorrect).
  • The vocabulary is not widespread and standard, and the community of the wiki (represented by its admins) does not endorse its use at the moment. Not everyone's home-made ontology needs to be imported in a wiki.
  • The specification of the vocabulary is tailored towards another ontology language than that of the wiki (OWL DL), and it is not clear how to map it correctly. Since importing some vocabulary also entails a mapping to OWL DL it must be specified how the mapping should be done. It is also questionable whether exporting such elements to OWL/RDF would be of much use.
  • The imported element is part of the ontology vocabularies used for export.
    • In this case, using the element also directly could impair the sanity of the export. E.g. if owl:Nothing would be imported as a category into the wiki, one could easily make the whole output inconsistent by adding some article to this class, which is not desirable.
    • Alternatively, the element could already be sufficiently represented implicitly in the wiki. E.g. in order to state that something is an element of a class, one does not need to import the property rdf:type — it suffices to use the available category mechanism.

A quick way to find out what elements are available for some namespace abbreviation is to go to the article MediaWiki:smw_import_foaf, with foaf replaced by the namespace identifier you are interested in. The rationale behind this system is that the community can decide on a sane use of desired vocabularies, but each user still has the power to decide in which cases the available elements are used and by what name they should be represented within the wiki.

Making vocabularies available for import[edit]

Wiki-users with administrator status can make new elements available by simply editing a specific page for each vocabulary with a "magic" name. The page is in the Mediawiki namespace with the prefix smw_import_. For example, the page for the foaf vocabulary is named MediaWiki:smw_import_foaf. It contains something like|[ Friend Of A Friend]

The first line tells the wiki that

After this, there is a line that declares each vocabulary element that can be reused within the wiki. For instance, "name" (referring to "foaf:name") can only be a property of Type:String. The text after the "|" declares the (unique) context in which some element can be used. Elements that can be imported as properties are declared by specifying their type with Type:some datatype, elements that can be imported as categories are declared by specifying the "Category" namespace identifier. (Note that in SMW 1.0 the type and namespace depends on your language setting!). Moreover, one can also declare other elements by writing anything else than the above; however, we strongly recommend you use one meaningful string; we suggest "Main", although you can use such elements in namespace other than "Property" and "Category" as well.

Changing import statements[edit]

It can easily happen that some existing article of the wiki should be modified to represent (another) imported concept. For example, a wiki community that already uses a category "Person" might decide to map this category to "foaf:Person" in the future. Luckily, this is not a problem. Import statements in existing articles can be changed at any point in time without requiring additional updates in the wiki. The exported RDF will immediately be modified accordingly. Of course, in the case of properties, the datatype should usually not be changed without updating also the articles that use this property. This is mildly related to importing since an "imported from" declaration for properties will also define the datatype.