Extension:RDFa

=What does this extension do?= This extension provides the functionality of outputting semantic data of Mediawiki pages in the RDFa format. The RDFa formatted data generated from a page will have the page itself as the subject. The properties and objects are retrieved from the semantic data of this page.

Besides the user defined properties, this extension is also able to recognize the following special properties:
 * Category
 * Has Type
 * Modification date
 * "Sub-Category" relation
 * Subproperty of

The corresponding properties in the RDFa format are as follows:


 * typeof
 * Property:Has_type
 * Property:Modification date
 * http://www.w3.org/2000/01/rdf-schema#subClassOf
 * http://www.w3.org/2000/01/rdf-schema#subPropertyOf

This extension does not generate any visible content for usual reading. You should use an RDFa-aware browser or tool to use the RDFa metadata.

The extension also provides the functionality that allows user to map the property of MediaWiki to other property. For example, instead of output property "has end date" from MediaWiki, user can ask the extension output property "vcal:dtend", where "vcal" is a prefix for "http://www.w3.org/2002/12/cal/icaltzd#".

RDFa -> Semantic MediaWiki Data

Another part of this extension provides the functionality to transform RDFa data to Semantic data in SMW. The extension first extracts the RDFa data of the source web page(Note: this extraction process requires ARC). Once we have all the triples from RDFa, the transformation process begins with creating a new helper wiki page(with hashed title) to hold each triple. Then the user can apply wiki template to generate Semantic data.

=Download and installation=

You can download the code at:


 * RDFa Extension (Version 1)
 * RDFa Extension (Version 2)
 * RDFa Extension (Version 3, with the extension transform RDFa -> Semantic Mediawiki Data)

After you downloaded the code, place the code to the 'RDFa' directory within your MediaWiki 'extensions' directory. Then, add the following code to your LocalSetting.php after the line that installs Semantic MediaWiki.

Note: if you wants to use RDFa extraction part of the extension, you need download ARC2 lib, and put the code in RDFa_extractor directory.

require_once ("$IP/extensions/RDFa/rdfa.php"); require_once("$IP/extensions/RDFa_extractor/extract_rdfa.php");

You can browse the code at:


 * Browse RDFa Extension

=Dependencies=

This extension requires Semantic MediaWiki. RDFa extraction part of the extension will be rely on ARC2 library

= Functionalities and Usage (Semantic Data -> RDFa)=

Basic Usage
capital of::Germany locate in::Europe has LatLong::52.5166667,13.4

Suppose there is a wiki page contains above structured data in wiki format. Further, lets assume the host address of the wiki is http://localhost/mediawiki. Then this extension will generate triples in the RDFa format as follows：

    

Notice that the extension use different html markup,  and &lt;div&gt;, to present the data. This is because the extension is able to regconize the type of the values of properties: the extension uses  to markup data if the value of property is another wiki page. Otherwise, the extension uses &lt;div&gt; markup. Also, the "typeof" property in the RDFa data is generated by the "Category" markup of wiki page.

These RDFa formatted data can be displayed as RDF triples:   .

  .

 <http://localhost/mediawiki/index.php/Property:Has_LatLong> "52.5166667,13.4".

<http://localhost/mediawiki/index.php/Berlin> <http://localhost/mediawiki/index.php/Property:Locate_in> <http://localhost/mediawiki/index.php/Europe>.

<http://localhost/mediawiki/index.php/Berlin> <http://localhost/mediawiki/index.php/Property:Modification_date> "3 September 2009 02:19:03".

Mapping Properties
In some cases, the user may want to translate the property of MediaWiki to another property for certain purpose(so SearchMonkey of Yahoo! can display the enhanced search result). Parser function "rdfa_map" provides the functionality that maps one property of MediaWiki to other property.

We provides two ways for user to map between properties: 1. user can provide the title of a page which contains the mapping of properties(check Mapping Page Format for detail) at LocalSettings.php, 2. use parser function "rdfa_map"; Note: if bother ways are presented, extension will use the second one(parser function) to translate.

Provide page title
All you need to do is set variable $rdfa_map_page = "...page title..." in LocalSettings.php, and create the mapping at that page(check Mapping Page Format for detail). Exmaple: $rdfa_map_page="property_map";

Parser usage
The parser provided by the extension is associated with magic word "rdfa_map", and takes only one argument: title of the article which contains the mapping of two properties. For instance, in above example, the page contains the mapping of properties has title "property_map".

Mapping Page Format
Example: property_map @prefix xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"

@prefix xmlns:vcal="http://www.w3.org/2002/12/cal/icaltzd#"

@prefix xmlns:dc="http://purl.org/dc/terms/"

@prefix xmlns:vcard="http://www.w3.org/2006/vcard/ns#"

@prefix xmlns:review="http://purl.org/stuff/rev#"

@prefix xmlns:xsd="http://www.w3.org/2001/XMLSchema#"

@prefix xmlns:commerce="http://search.yahoo.com/searchmonkey/commerce/"

End_date      = vcal:dtend

Location      = vcal:location

Start_date    = vcal:dtstart

Name          = dc:title

Has_start_date = vcal:dtstart

Has_end_date  = vcal:dtend

Has_location  = vcal:location

Has_label     = vcard:fn rdfs:label

Comment       = rdfs:comment

Latitude      = vcard:latitude

Longitude     = vcard:longitude

The parser function recognizes the namespace declaration if "@prefix" provided. The format for namespace declaration is illustrated as above. Please note that there is a space between "@prefix" and the namespace, and a " " after each declaration.

To map a property to a different property defined externally, we use "=" declare the mapping. In above example, property "End_date" in MediaWiki will be map to "vcal:dtend". Note: "vcal" is a namespace declared in the namespace declaration. Again, a " " is needed after each mapping.

= Functionalities and Usage (RDFa -> Semantic Data)=

Parser Function
The extract part of the extension provides following parser:

argument 1: (a html table or wiki ask query) This argument should be a list of urls of web pages that contains rdfa data. argument 2: a template that will be used to generate semantic annotation for the newly created wiki pages.

Example
Take the RDFa data in above section as an example, suppose we have RDFa data in a web page as below: <div id='RDFa' about='http://localhost/mediawiki/index.php/Berlin' xmlns:wiki_1='http://localhost/mediawiki/index.php/' xmlns:wiki_1_property='http://localhost/mediawiki/index.php/Property:' xmlns:wiki_1_category='http://localhost/mediawiki/index.php/Category:' typeof='wiki_1_category:Location'> </a> <div property='wiki_1_property:Has_LatLong' content='52.5166667,13.4'> </a> <div property='wiki_1_property:Modification_date' content='3 September 2009 02:19:03'>

We can create a extract the rdfa data using the parser:

The RDFa extraction part of the extension will extract RDFa data at http://localhost/mediawiki/index.php/Berlin, and create 4 new wiki pages, each of these wiki page will hold one of these rdfa triples:

Example of newly created wiki page:

Then you can create a location_template to render this triple: Subject:: Property:: Object::

Done !!!!

Now you can use any of the parsing, rendering functionalities provided by Semantic MediaWiki to play with these triples.

=Bugs, new feature request and contact information=

Please reports bug, feature requests, or any feedback to zhengj3-at-rpi.edu

=RDFa viewers=

Please look at http://rdfa.info/wiki/Tools

=Todo=


 * an "action=rdfa" option to a page to render only rdfa data

=Release Log=


 * Date: 2009-10-20, version number:0.0.2.
 * This version provides the functionality that allows user to map the property of MediaWiki to other property. For example, instead of output property "has name" from MediaWiki, user can ask the extension output property "vcal:dtend", where "vcal" is a prefix for "http://www.w3.org/2002/12/cal/icaltzd#". More details can be found at Mapping Properties
 * Instead of producing URIs(eg, instead of property="http://localhost/wiki/Property:has_name"), we use prefix to declare the namespace, and producing the "CURIEs" (CURIEs)
 * Download link: RDFa Extension (Version 2)


 * Date: 2009-09-11, version number:0.0.1, Version Description: initial version.
 * This version provides basic functionality of allowing people to output semantic data in RDFa format.
 * Download link: RDFa Extension (Version 1)