Semantic MediaWiki with Property Clusters 4 - Dpldemo

Semantic MediaWiki with Property Clusters 4

From Dpldemo

Jump to: navigation, search
This document is part of a larger document: Semantic MediaWiki with Property Clusters

Contents

Implementation

While the current implementation works and can be used to test and refine the concept of Semantic MediaWiki with Property Clustering, it is not very efficient and sometimes cumbersome. The majority of the templates could and should be replaced by equivalent parser functions in a future release.

Using SMWpc on small and medium size wikis should be possible with the current implementation.

Properties are always assigned by using a template. This may look "overdesigned" in some simple cases. But it proves to be very useful because it allows to have an abstraction layer between SMW and the user interface for property assignment. The implementation of polymorph properties and checks against the class model rely on this design principle.

General Purpose Templates

For syntactic reasons it is sometimes necessary to escape the pipe character within templates. The usual way to do this is by using a template which expands to a pipe character. SMWpc for this reason uses the following templates:


SMWpc Documentation API Object

SMWpc: API on Object level

The following functions operate on object level (instance level). This means that they are applied to a a MediaWiki page which is an Instance of a SMWpc Class. See also the complete list of SMWpc interfaces.

Template:.obj is a

Declares a MediaWiki article page to be an instance of a SMWpc Class.

Syntax: {{.obj is a|<class>}}

  • expects as first parameter the name of the class without the 'Class' prefix.
  • generates a statment like 'Obj is a Class'
  • generates a link to a page which shows inverted links, i.e. other article which have a property that points to the current object

Implementation notes

  • This template sets internal variables to allow other templates faster access to the class name
  • proposed syntax for a parser function: {{#object:class|<class>}}.
  • This template assigns the meta property .obj is a to the object.


Template:.obj get , Template:.obj getText , Template:.obj getMy , Template:.obj getMyText

Return the value of a property.

Syntax: {{.obj get|<instance>|<property>|[<default value>]}}
or {{.obj getMy|<property>|[<default value>]}}

  • The standard variant expects as first parameter the name of an instance of a class.
  • The getMy-variants take the instance name from a variable named 'this' which is for example filled by a preceding call of {{.obj is a|<class>}}.
  • expects as second parameter the name of a property (without "Property:")
  • takes a default value as an optional third parameter. This will be delivered if the requested property is not set for the object.
  • if there is no default value given and the property is not set an empty string will be returned.
  • .obj get and .obj getMy return the value of the property; if its type is a page you will get a hyperlink to the page
  • the Text-variants always return plain text, even if the value is of Type 'page'.

Examples

  • {{.obj get|Peter|Born at}} returns 'Berlin'.
  • {{.obj getText|Peter|Born at}} returns 'Berlin'.
  • {{.obj get|Tony|Born at}} returns ''.
  • {{.obj get|Tony|Born at|''unknown''}} returns 'unknown'.
Now we set 'this' to 'Lucie' : {{#vardefine:this|Lucie}}
  • {{.obj getMy|Born at}} returns 'Paris'.

Implementation notes

  • This template uses an internal variable which holds the class name
  • proposed syntax for a parser function: {{#object:get|<instance>|<property>|[<default value>]}}.


Template:.obj set

Assign a value to a property of the current object.

Syntax: {{.obj set|<property>|<value>|[<prefix>]}}

  • assigns the value if the property is valid for the object's Type or on of its ancestors' Types.
  • If the property is invalid, a wrning will be issued and no assignment is made
  • If 'prefix' is a '-' the assignment will be silently made; otherwise the the assignment will be 'verbose', i.e. the value of the property will be printed; in addition the prefix will be printed before the property value. Skipping the third parameter completely will make a verbose assignment with no prefix being displayed.


Template:-

Print the argument and store its value as the 'current property'.

Syntax: {{-|<property>}}

  • display the property name
  • store its name as 'the current property'; successive calls of Template:+ can be used to assign a value to this property.

Implementation notes

  • An internal variable called 'prop' is used to store the property. There is no such thing like a property stack.


Template:+

Assign a value to the 'current property'.

Syntax: {{+|<value>|[<prefix>]}}

  • assign the value using Template:.obj set
  • The second parameter is passed to 'Template:.obj set'.



Template:.obj is referenced by

Display a list of objects which have a property that points to the object. This is kind of a 'semantic what links here'.

Syntax: {{.obj is referenced by|<instance>|<class>}}

  • expects an instance name
  • expects a class name (without 'Class ' prefix)

Examples

{{.obj is referenced by|Bassoon|Musical Instrument}} returns Bassoon is played by : Peter


Implementation notes

  • This template uses an internal variable which holds the class name
  • This template uses the subtemplate Template:.obj is referenced by.ask
  • proposed syntax for a parser function: {{#object:get|<class>|<property>|[<default value>]}}.

SMWpc Documentation API Class

SMWpc: API on Class level

The following functions operate on class level. This means that they are applied to MediaWiki pages which describe an SMWpc Class. See also the complete list of SMWpc interfaces.


Template:.class definition

Defines a class and sets its basic attributes.

Syntax: {{.class definition|<class>|color=<color>|icon=<icon>|extends=<base class>|doc=<doc>}}

  • expects as first parameter the name of the class without the 'Class' prefix.
  • color = an optional color (in rrggbb Notation without a leading '#'), defaults to #f7f7f7
  • icon = an optional icon file name (without the Image: prefix)
  • extends = an optional name of a base class (without 'Class ') from which the current class is derived
  • doc = an optional text describing the semantic concept of the class

This template should only be used within a class definition article (like 'Class Foo').

Implementation notes

  • It could be useful to have a 'Special:Classes' page.
  • This template assigns the meta properties .class color, .class icon, .class extends and .class doc to the class.


Template:.class description

Displays a list of properties of the class. Inherited properties are 'not' included.

Syntax: {{.class description|<class>}}

  • expects the name of a class without the 'Class' prefix.

Example

Personal tools
Toolbox