Online Demonstrator

open
Information to be returned open
Advanced options open

3P is a PHP implementation of the POWDER processor described in Section 3 of the W3C Recommendation titled POWDER: Description Resources.

This tool is currently under development, and it has been posted online only for testing and demonstration purposes.

Overview

3P is a PHP implementation of the POWDER processor described in Section 3 of the W3C Recommendation titled POWDER: Description Resources. This tool is currently under development, and it has been posted online only for testing and demonstration purposes.

The features supported by 3P are described in the document titled POWDER Feature List. In addition, 3P is able to generate on the fly RDFa snippets for resources associated with POWDER documents.

3P has been originally developed by the Database & Web Security group at the University of Insubria in the framework of the QUATRO Plus project.

Following, you can find an overview of POWDER and 3P.

What is POWDER?

POWDER—which stands for Protocol for Web Description Resources—is a Semantic Web technology developed at W3C which defines a standard mechanism for describing sets of resources denoted by a given URI/IRI pattern. For instance, POWDER allows you to state that all the resources hosted by imdb.com concern movies, that those having a URI/IRI starting with http://www.imdb.com/cannes/ concern movies presented at the Cannes Festival, etc. In other words, POWDER allows you to concisely create a machine-understandable description of the resources hosted by even a large website, without the need of creating semantic annotations for each of them.

Another key feature of POWDER is the support to metadata provenance. In fact, any description of a set of resources is associated with information which can be used to identify who created such descriptions. Thanks to this, user agents might be able to decide whether, and possibly how much, any of these descriptions is trustworthy based on their author and on the policies/preferences of an end user.

The POWDER technology, which is illustrated in three W3C Recommendations, can be summarized as follows:

  • A Description Resource (DR) is a machine-understandable description of a set of resources consisting of two main components, namely, the DR scope, which denotes the (set of) resource(s) the DR applies to by means of URI/IRI patterns, and a descriptor set, describing the properties of the resources denoted by the DR scope.
  • DRs are stored into standalone files, called POWDER documents, which include also information about who created such DRs, and when, which is their validity period, etc.
  • Once posted online, POWDER documents can be associated with the resources they apply to through HTTP Link headers and/or (X)HTML link tags.

Which is the Format of POWDER Documents?

The basic syntax of POWDER documents is an XML dialect defined by the POWDER XML Schema. It is however possible to convert any POWDER document into RDF/OWL by applying a defined set of transformation rules (technically, this is enforced through a GRDDL transform associated with the POWDER namespace).

POWDER documents converted into RDF/OWL are known as POWDER-S documents, and their structure and semantics are described in the W3C Recommendation titled POWDER: Formal Semantics.

Now, we have POWDER documents (XML) and POWDER-S documents (RDF/OWL). Since they are semantically equivalent, which is the reason of using two formats instead of a single one? Why don't directly use RDF/OWL?

The reason is that RDF/OWL allow you to associate a description with a given URI/IRI, but not with a given URI/IRI pattern. For instance, you can describe http://www.imdb.com/, but not, say, the URIs/IRIs starting with http://www.imdb.com/. In order to make this possible, it is necessary to enforce a semantic extension which is not part of RDF/OWL standard semantics.

Such semantic extension is illustrated in Section 4.3 of the W3C Recommendation titled POWDER: Formal Semantics. POWDER-S documents make use of that semantic extension, and thus they are not actually standard RDF/OWL.

What is a POWDER Processor?

Basically, a POWDER processor is a software agent which is able to verify whether a given (set of) POWDER document(s) applies or not to a given URI/IRI, and to generate an RDF/XML description of that URI/IRI by processing the relevant POWDER document(s).

In addition to this, a POWDER processor may be able to discover POWDER documents, to validate them, etc.

The full list of features to be supported by a conformant POWDER processor is illustrated in Section 3 of the W3C Recommendation titled POWDER: Description Resources.

But why should I need a specific piece of software to process POWDER documents, instead of using existing Semantic Web tools supporting standard technologies like RDF/OWL?

The reason has been already introduced in the previous section. RDF/OWL POWDER documents are not standard RDF/OWL and, consequently, RDF/OWL tools cannot be used to process POWDER documents, unless they enforce the above-mentioned semantic extension.

Existing POWDER processors are listed in the POWDER Working Group official page, along with POWDER validators and transformation tools.

What is 3P?

3P is a conformant POWDER processor including a set of additional features, such as POWDER documents discovery and validation. 3P allows you also to control how POWDER documents discovery is carried out, and to decide which information is to be returned (e.g., the description of the relevant resource, information about the discovered POWDER documents, information about the processor).

How Can I Use 3P?

3P will be available for download as soon as its stable version will be ready. In the meanwhile you can use the online demonstrator available here.

3P natively supports a RESTful API, which can be queried by submitting either a GET or POST HTTP request including a given set of parameters. Parameter u is the only one which is mandatory, and it denotes the URI/IRI of the resource to be described.

For more information on how to use 3P and the set of supported parameters, read the 3P RESTful API documentation.

References

URIs and IRIs

T. Berners-Lee, R. Fielding, L. Masinter. Uniform Resource Identifier (URI): Generic Syntax. RFC 3986, IETF, January 2005.
M. Dürst, M. Suignard. Internationalized Resource Identifiers (IRIs). RFC 3987, IETF, January 2005.

POWDER Specifications

K. Scheppe (ed.). Protocol for Web Description Resources (POWDER): Primer. W3C Working Group Note, W3C, 1 September 2009.
P. Archer, K. Smith, A. Perego (eds.). Protocol for Web Description Resources (POWDER): Description Resources. W3C Recommendation, W3C, 1 September 2009.
P. Archer, A. Perego, K. Smith (eds.). Protocol for Web Description Resources (POWDER): Grouping of Resources. W3C Recommendation, W3C, 1 September 2009.
S. Konstantopoulos, P. Archer (eds.). Protocol for Web Description Resources (POWDER): Formal Semantics. W3C Recommendation, W3C, 1 September 2009.
M. Nottingham. Web Linking. Version 10. Internet Draft, IETF, 5 May 2010.
D. Raggett, A. Le Hors, I. Jacobs (eds.). HTML 4.01 Specification. W3C Recommendation, W3C, 24 December 1999 (Section 12.3: Document relationships: the LINK element).

POWDER Processors and Tools

See the POWDER Working Group official page.

The 3P's RESTful API

The 3P's RESTful API is implemented by the httpDescribe() method of class PowderProcessor—the PHP class implementing 3P's core functionalities.

Setting up the 3P's RESTful API requires just three lines of code:

<?php

  require_once("PowderProcessor.php");
  $proc = new PowderProcessor;
  echo $proc->httpDescribe();  

?>

Once invoked, the httpDescribe() method fetches the parameters included in the GET or POST HTTP request submitted by the client, it uses them to set the relevant properties of class PowderProcessor, and then it invokes the describe() method, which is in charge of returning the RDF description of the relevant resource after having processed the set of specified/discovered POWDER documents.

The set of parameters accepted by the API is described in the table below.

Parameter Values Default Required Description
uan absolute URI/IRI, referernoneyes

It denotes the URI/IRI of the resource to be described (i.e., the candidate resource). If set to referer, the URI/IRI specified in the HTTP Referer header of the request submitted to the API. If the u parameter is missing or set to the empty string, the API returns an empty RDF graph—an RDF/XML document consisting only of the root node rdf:RDF.

dan absolute URI/IRInoneno

It denotes the URI/IRI of a POWDER document to be processed against the resource denoted by parameter u. Setting this parameter disables POWDER documents' discovery. If set to the empty string, parameter d is treated as missing—thus enabling POWDER documents' discovery.

formatrdf, rdfardfno

This parameter controls the format of the description returned by 3P. Currently, the only possible values are rdf (default) and rdfa.

pdlisttrue, falsefalseno

Set this to true if you want the result to include only information about the discovered/specified POWDER document(s).

ppinfostrue, falsefalseno

Set this to true if you want the result to include information about the processor.

attrtrue, falsefalseno

Set this to true if you want the result to include information about the author(s), issue date, validity period, etc. of the discovered/specified POWDER document(s).

httplinkstrue, falsetrueno

Set this to false if you do not want 3P to check HTTP Link headers pointing to a POWDER document. This parameter is ignored when parameter d is set.

htmllinkstrue, falsetrueno

Set this to false if you do not want 3P to check (X)HTML link tags pointing to a POWDER document. This parameter is ignored when parameter d is set.

frefstrue, falsetrueno

Set this to false if you do not want 3P to process POWDER documents linked from the POWDER documents already discovered.

frefsdeptha non negative integer1no

Sets the maximum search depth in a graph consisting of linked POWDER documents. The root of the search tree is the specified or first discovered POWDER document.

validatetrue, falsefalseno

Set this to true if you want to validate specified/discovered POWDER documents against the POWDER's XML Schema.

POWDER and RDFa

RDFa (RDF in attributes) is a technology, developed at W3C, thanks to which it is possible to enrich Web pages with semantic annotations. More precisely, RDFa specifies how RDF triples can be embedded into an (X)HTML document, in order to describe its content at any granularity level, from a single text node to the whole document.

RDFa is currently widely deployed, and it is supported by some of the most used online services, like Google (Rich Snippets), Facebook (Open Graph Protocol), and Twitter (Twitter Annotations).

What POWDER has to do with all this?

Suppose that you manage a website, and you would like to use RDFa to describe the content of each Web page—as you would do when using OGP. Typically, this can be achieved by embedding RDF triples into the head of the corresponding (X)HTML document, by including a set of meta and link tags. You can do this manually, but if you have a large number of Web pages, this would become a cumbersome, time-consuming, and error-prone task.

Now, POWDER allows you to concisely describe the resources of a website, and to store such description in a few (possibly, one) XML files, referred to as POWDER documents. Then, a POWDER processor is able to process such POWDER documents and return an RDF description of each of the resources of the website. So, if you have a tool able to convert such RDF description into an RDFa snippet, you can use such tool to include on the fly a given RDFa snippet into the (X)HTML code of the relevant Web page.

The result is that, with a little effort, you are able to automatically and consistently generate RDFa snippets for all the Web pages of your website.

Based on these considerations, starting from version 0.1.0 β, 3P supports this feature. More precisely, you can fetch the RDFa snippet of a Web page described by a POWDER document by submitting a GET or POST HTTP request to the 3P's RESTful API.

This feature is supported also by the 3P's online demonstrator—which is nothing else than an Ajax interface to the 3P's RESTful API. Type the URL of a Web page in the relevant field, and then press “Describe URI/IRI”. Once the result is returned, click on the textual link “Retrieve as an RDFa snippet” located over the box displaying the result.

Details about RDFa support in 3P and how to use it are given in the following sections.

How 3P Creates an RDFa Snippet

RDFa support is built on top of 3P's core functionalities—i.e., the discovery and processing of POWDER documents. Consequently, when an RDFa snippet is requested, 3P first generates the RDF description of the relevant resource, based on the discovered POWDER documents, and then it converts it into RDFa.

The RDFa snippet returned by 3P consists of a set of (X)HTML meta and link tags, which can be included into the head of the relevant (X)HTML document(s).

For instance, the following RDF triples

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:wdrs="http://www.w3.org/2007/05/powder-s#">
  <rdf:Description rdf:about="http://www.andrea-perego.name/?sec=news">
    <foaf:maker rdf:resource="http://andrea-perego.name/foaf/#me"/>
    <og:type rdf:resource="http://ogp.me/ns#Website"/>
    <og:image rdf:resource="http://andrea-perego.name/img/andrea.png"/>
    <og:site_name xml:lang="en">Andrea Perego's website</og:site_name>
    <og:title xml:lang="en">Andrea Perego :: News</og:title>
    <og:url rdf:resource="http://andrea-perego.name/?sec=news"/>
    <wdrs:describedby rdf:resource="http://www.andrea-perego.name/powder.xml"/>
  </rdf:Description>
</rdf:RDF>

are converted into:

<link xmlns:foaf="http://xmlns.com/foaf/0.1/" about="http://www.andrea-perego.name/?sec=news" rel="foaf:maker" href="http://andrea-perego.name/foaf/#me"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:type" content="website"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:image" content="http://andrea-perego.name/img/andrea.png"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:site_name" xml:lang="en" content="Andrea Perego's website"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:title" xml:lang="en" content="Andrea Perego :: News"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:url" content="http://andrea-perego.name/?sec=news"/>
<link xmlns:wdrs="http://www.w3.org/2007/05/powder-s#" about="http://www.andrea-perego.name/?sec=news" rel="wdrs:describedby" href="http://www.andrea-perego.name/powder.xml"/>
<link rel="describedby" type="application/powder+xml" href="http://www.andrea-perego.name/powder.xml"/>
<link rel="meta" type="application/rdf+xml" href="http://dawsec.dicom.uninsubria.it/andrea/ppp/http/?u=referer&amp;d=http%3A%2F%2Fwww.andrea-perego.name%2Fpowder.xml"/>

Note that the last two link tags, namely:

<link rel="describedby" type="application/powder+xml" href="http://www.andrea-perego.name/powder.xml"/>
<link rel="meta" type="application/rdf+xml" href="http://dawsec.dicom.uninsubria.it/andrea/ppp/http/?u=referer&amp;d=http%3A%2F%2Fwww.andrea-perego.name%2Fpowder.xml"/>

are not mapped from the original RDF/XML document, but they correspond to the link tags which can be included into any Web page which is described by a POWDER document. More precisely, the first link tag states that the current Web page is described by a POWDER document located at URL http://www.andrea-perego.name/powder.xml, whereas the second link tag provides information in order to retrieve an RDF description of the current Web page, by submitting a query to a POWDER processor.

Why are they included here? The idea is that, this way, you are able to verify the original source of the claims corresponding to the RDF statements embedded in the (X)HTML code of a page.

By contrast, the following lines:

<link xmlns:foaf="http://xmlns.com/foaf/0.1/" about="http://www.andrea-perego.name/?sec=news" rel="foaf:maker" href="http://andrea-perego.name/foaf/#me"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:type" content="website"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:image" content="http://andrea-perego.name/img/andrea.png"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:site_name" xml:lang="en" content="Andrea Perego's website"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:title" xml:lang="en" content="Andrea Perego :: News"/>
<meta xmlns:og="http://ogp.me/ns#" property="og:url" content="http://andrea-perego.name/?sec=news"/>
<link xmlns:wdrs="http://www.w3.org/2007/05/powder-s#" about="http://www.andrea-perego.name/?sec=news" rel="wdrs:describedby" href="http://www.andrea-perego.name/powder.xml"/>

maps from the original RDF/XML document. Note that the RDFa mapping of the OGP properties og:type, og:image, og:url is compliant with the OGP specification, where only meta tags are used—according to the RDFa specification we should rather have link tags here, since the object of the corresponding RDF statement is a URI reference.

You can also note that each of the returned meta and link tags directly include the relevant namespace declaration(s). This is a consequence of the fact that 3P returns just the (X)HTML code embedding RDFa, and thus it is not possible to group namespace declarations in parent elements, like html or head.

The drawback is, of course, redundancy. A possible advantage is that, in case the POWDER document(s) describing a Web page are updated with terms from new vocabularies/ontologies, you do not need to include the corresponding namespace declarations in the (X)HTML source of your Web page.

Using the 3P's API to Get an RDFa Snippet

If you want to get an RDFa snippet for a given Web page from the 3P's RESTful API, you just have to submit either a GET or POST HTTP request to the API's URL including two mandatory parameters, namely:

  • u: the URL of the relevant page
  • format: the format of the returned description; set this to rdfa

Additionally, if you already know which is the POWDER document applying to the relevant page, you can specify its URL through the d parameter. This will improve performance, since 3P will not have to submit an HTTP request to discover the POWDER documents linked from that page.

You can see a working example by copying and pasting the following URL in the address bar of your browser:

http://dawsec.dicom.uninsubria.it/andrea/ppp/http/?u=http%3A%2F%2Fwww.andrea-perego.name%2F%3Fsec%3Dnews&format=rdfa

In order to include the returned RDFa snippet in a head of an (X)HTML document, you can use any scripting language able to submit an HTTP request. As an example, you can see below an example of (X)HTML code embedding a PHP script which sends an HTTP GET request to the 3P's API and includes the result in the head of the document:

...
<html ...>
  <head>
    ...
<?php

  $api_url = "http://dawsec.dicom.uninsubria.it/andrea/ppp/http/";
  $page_url = "http://www.andrea-perego.name/?sec=news";
  $request_url = $api_url . "?u=" . urlencode($page_url) . "&format=rdfa";

  $cURL = curl_init();
  
  curl_setopt($cURL, CURLOPT_URL, $url);
  curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
  
  echo curl_exec($cURL);

  curl_close($cURL);
  
?>
    ...
  </head>
  <body>
    ...
  </body>
</html>

Contacts

If you have any comments, questions, etc. about POWDER and 3P, please post an email to the public mailing list of the POWDER WG (public-powderwg@w3.org).