Extension:RDFa
From MediaWiki.org
|
Release status: beta |
|
|---|---|
| Description | Outputs semantic data of Mediawiki in the RDFa format. |
| Author(s) | Jin Guang Zheng and Jie Bao |
| Last Version | 0.0.2 (2009-10-21) |
| MediaWiki | 1.9.* or greater |
| License | Th MIT License |
| Download | See here |
|
check usage (experimental) |
|
Contents |
[edit] 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#".
[edit] Download and installation
You can download the code at:
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.
require_once ("$IP/extensions/RDFa/rdfa.php");
You can browse the code at:
[edit] Dependencies
This extension requires Semantic MediaWiki.
[edit] Functionalities and Usage
[edit] Basic Usage
[[capital of::Germany]] [[locate in::Europe]] [[has LatLong::52.5166667,13.4]] [[Category:Location]]
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:
<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 href='wiki_1:Germany' rel='wiki_1_property:Capital_of'></a> <div property='wiki_1_property:Has_LatLong' content='52.5166667,13.4'></div> <a href='wiki_1:Europe' rel='wiki_1_property:Locate_in'></a> <div property='wiki_1_property:Modification_date' content='3 September 2009 02:19:03'></div> </div>
Notice that the extension use different html markup, <a> and <div>, to present the data. This is because the extension is able to regconize the type of the values of properties: the extension uses <a> to markup data if the value of property is another wiki page. Otherwise, the extension uses <div> 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/Berlin> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://localhost/mediawiki/index.php/Category:Location> . <http://localhost/mediawiki/index.php/Berlin> <http://localhost/mediawiki/index.php/Property:Capital_of> <http://localhost/mediawiki/index.php/Germany> . <http://localhost/mediawiki/index.php/Berlin> <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" .
[edit] 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.
[edit] 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";
[edit] Parser function
[edit] Parser usage
{{#rdfa_map: property_map}}
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".
[edit] Mapping Page Format
Example: property_map
@prefix xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" <br> @prefix xmlns:vcal="http://www.w3.org/2002/12/cal/icaltzd#" <br> @prefix xmlns:dc="http://purl.org/dc/terms/" <br> @prefix xmlns:vcard="http://www.w3.org/2006/vcard/ns#" <br> @prefix xmlns:review="http://purl.org/stuff/rev#" <br> @prefix xmlns:xsd="http://www.w3.org/2001/XMLSchema#" <br/> @prefix xmlns:commerce="http://search.yahoo.com/searchmonkey/commerce/" <br/> End_date = vcal:dtend <br/> Location = vcal:location <br/> Start_date = vcal:dtstart <br/> Name = dc:title <br/> Has_start_date = vcal:dtstart <br/> Has_end_date = vcal:dtend <br/> Has_location = vcal:location <br/> Has_label = vcard:fn rdfs:label <br/> Comment = rdfs:comment <br/> Latitude = vcard:latitude <br/> Longitude = vcard:longitude <br/> Longitude = vcard:longitude <br/>
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.
[edit] Bugs, new feature request and contact information
Please reports bug, feature requests, or any feedback to zhengj3-at-rpi.edu
[edit] RDFa viewers
Please look at http://rdfa.info/wiki/Tools
[edit] Todo
- an "action=rdfa" option to a page to render only rdfa data
[edit] 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)
[edit] See also
However, there are issues with
it (I've put your example from [1] as a standalone doc at [2]) - this stems from the fact that you're producing URIs (eg, in @typeof, @rel, @property) where only CURIEs are allowed [3]. Hence an RDFa processor (as in [2]) tries to interpret your URI as CURIE, for example: