Help:Semantic Wiki

From BeatlesWiki

Jump to: navigation, search

Contents

Let's work on a simple example. See the article about the events of 1957.

The code to produce such a page is

{{EventYear}}

<ask format="template" template="Event On Year" sort="RevDate">
[[RevDate:=+]]
[[Year:=1957]]
[[ShortDescr:=*]]
[[Month:=*]]
[[Day:=*]]
</ask>

{{Refresh}}

The lines 2-8 are enclosed between <ask> </ask>. These lines will interrogate (ask) the Semantic Wiki Engine so it displays information stored in the Semantic Wiki database.

Here's an example of results:

Semantic Wiki basics

This section is in construction, in the meantime please read http://ontoworld.org/wiki/Help:Annotation

The first thing to know is that Semantic Data is always linked to a specific article.

Categories

Relations

Attributes

Inline queries

Using the <ask> </ask> syntax is called an inline query. That is, all the results will be directly printed within the article.

<ask format="template" template="Event On Year" sort="RevDate">
[[RevDate:=+]]
[[Year:=1957]]
[[ShortDescr:=*]]
[[Month:=*]]
[[Day:=*]]
</ask>

On the first line:

  • format="template" means we want to use a template to display the results
  • template="Event On Year" means we want to use Template:Event On Year to display the results
  • sort="RevDate" means we want to sort the results according to the RevDate attribute

Every [[ ]] between <ask> </ask> indicates:

  • columns in the form of categories, attributes or relations
  • columns we want to display
  • columns we want to filter

Columns

It is important to respect the type of column !

  • Categories: [[Category:CategoryName]]
  • Relations: [[RelationName::*]]
  • Attributes: [[AttributeName:=*]]


Displaying columns

Filtered columns (being attributes, relations or categories) is done by specifying the name of the column, followed by an asterisk (*).

In the above example, the only columns we want to display are ShortDescr, Month and Day. The order of the columns is important, particularly when using a template to display the results.


Filtering columns

  • Use a + sign for the column you want to sort. Note that you'll have to re-specify if you want to display that column. In the above example, we sort the results by the attribute RevDate but we don't display this attribute because we have not specified [[RevDate:=*]]
  • Type any text after the category, attribute or relation to filter. You may even use '>' and '<' signs.
    • [[Year:=1957]] will only display results for articles having the Year attribute to 1957
    • [[Year:=>1957]] will display results for articles having the Year attribute greather than 1957

Using a template to display results

See Help:Templates if you don't know what a temmplate is.
The template must use unnamed arguments.

The order of the columns to display, specified between the <ask> </ask>, is then passed to the template. However, {{{1}}} is always the page name where the result was found.

In the above example, the following data is passed to the template Template:Event On Year:

  • {{{1}}}: page link
  • {{{2}}}: ShortDescr attribute
  • {{{3}}}: Month attribute
  • {{{4}}}: Day attribute


Adding info into the Semantic Wiki database

Let's say we're writing an article about John Lennon and that we want to add Semantic Data (note: you'll find the completed article of this example on Example:John Lennon) ...

Here's the code

John Lennon was born on [[BirthDate:=October 9, 1940]].

His father was [[isChildOf::Freddie Lennon]]

His mother was [[isChildOf::Julia Lennon]]

He wrote [[SongsWritten:=432]] songs.

[[Category:Artist]]

Categories

Categories are used in a wiki to classify pages.

Relations

Attributes

The code [[BirthDate:=October 9, 1940]] defines an attribute named BirthDate with a value of October 9, 1940.
An attribute defines some kind of property attached to John Lennon.
The attribute SongsWritten has the value 432.

Personal tools