GoodRelations is a standardized vocabulary for product, price, and company data that can be embedded into existing static and dynamic Web pages. Project Main Page

Vocabulary

Documentation

Developer's Wiki

GoodRelations Cookbook

E-Commerce Content Syndication on the Web of Linked Data with GoodRelations and LESS

Author: Martin Hepp, mheppATcomputerDOTorg

Overview

GoodRelations (http://purl.org/goodrelations) is a standardized vocabulary for product, price, and company data that can (1) be embedded into existing static and dynamic Web pages and that (2) can be processed by other computers. This increases the visibility of your products and services in the latest generation of search engines, recommender systems, and other novel applications.

LESS (http://less.aksw.org/about) is a framework and service for the template-based syndication and presentation of Linked Data .





In this recipe, we show how LESS can be used to include current information about offers and products matching a certain keyword (or more sophisticated SPARQL query) into your Web pages.





The data is taken in real-time from an RDF store that collates structured data from a huge number of Web sites that expose GoodRelations data. For examples in the wild, see

Getting Started

First, go to

and register and account. Only registered users can create new templates.

When done, log in and click on "Create New" in the upper left corner.

The system will unfortunately show a nasty error message:

"This template belongs to another user. You can make a copy using the "Save As" button or clicking here."

Click on "here" and enter the name of your template into the opening dialog box

Next, click on "SPARQL query" to design a template that fetches data dynamically based on a SPARQL query (the standard query language for Linked Data) against a public SPARQL endpoint (a public access point to a Linked Data database system).

Query

The first challenge is to define a suitable query. Below, you find an example for a SPARQL query that lists offers for products that contain the words "Johnny Cash" in the description. The query also does a bit of cosmetics for polishing the results values (e.g. trimming the price to two digits after the comma etc.).

For querying GoodRelations data, see http://www.ebusiness-unibw.org/wiki/GoodRelationsQueries.





PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX gr: <http://purl.org/goodrelations/v1#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> select distinct ?o as ?uri, bif:sprintf("%.2f",?p2) as ?price, ?currency, ?text, ?label, ?thumb, ?ean, ?order_link where { # Find products that contain "Johnny Cash" ?s1 rdfs:comment ?text . ?text bif:contains '"Johnny Cash"' . ?s1 a gr:ProductOrServicesSomeInstancesPlaceholder . OPTIONAL {?s1 foaf:thumbnail ?thumb .} OPTIONAL {?s1 gr:hasEAN_UCC-13 ?ean.} ?s1 gr:hasMakeAndModel ?model . ?model rdfs:label ?label . # Find offers that include those products ?o a gr:Offering. { # The following UNION is because we cannot assume that the expansion of gr:includes is on {?o gr:includes ?s1.} UNION {?o gr:includesObject ?t. ?t a gr:TypeAndQuantityNode. ?t gr:typeOfGood ?s1.} } ?o gr:hasPriceSpecification ?p. ?o rdfs:seeAlso ?order_link. ?o foaf:page ?order_link. ?p a gr:UnitPriceSpecification. ?p gr:hasCurrency ?currency. ?p gr:hasCurrencyValue ?p2. } order by desc (?p2) limit 5 offset 0

Paste this query into the respective form:

SPARQL Endpoint

Then, select a public endpoint to access with this query. The following one holds a lot of GoodRelations data:

Alternatively, you can also try

Note that the query above uses Virtuoso built-in functions, so it won't work with RDF stores other than Virtuoso.

Click on "Update Properties"; this will test the query and create handy shortcuts to the variables in your results.





HTML Template

Next, create an HTML template that defines the rendering of your results. Simply create a list or table and use the placeholder syntax from the LESS documentation. You can also simply point the cursor to the location to which the data should be inserted and click on the name of the proper variable on the right-hand side.





The complete HTML code for our example is given here. Note that the markup itself may be a bit sloppy ;-)

<xml>





</xml>

Then, click on preview. You will see how the results will look like immediately.





Save and Publish

The last step is to make your template available to others. Choose a name and a few tags and click on "Save", then "Publish".





You can then request permalinks that can be easily embedded into arbitrary Web sites.











Demo

Resources

LESS Help: http://less.aksw.org/help