GoodRelationsSimple

GoodRelations Simple Recipe

Overview

On this page, we explain how a typical business would use the GoodRelations vocabulary for e-commerce to add rich meta-data to their Web pages so that state-of-the art search engines, matchmaking services, and recommender systems will find your company.

Scenario Description

In the example, we use the following content:

  • The URI of the company's main page is
    http://www.example.com/xyz
  • The legal name of the business is
    Hepp Industries Ltd.
  • The address of the shop and the main office are the same.
  • The opening hours given in CET (GMT+1:00) are
    8:00 - 18:00 Mon-Fri and
    8:30-14:00 on Saturdays.
  • The company offers
    to sell and
    to repair
    "computers and motorbikes". This is represented by the two strings "We sell and repair computers and motorbikes" and "computers and motorbikes".
  • The offer is valid from 2009-04-24T00:00:00+01:00 through 2010-04-24T00:00:00+01:00.

The language of the short text "computers and motorbikes" is English (@en).

Publishing the Rich Meta-Data

There are at least three ways of adding such rich meta-data to your page:

  1. You can simply insert additional, invisible RDFa markup into your HTML page, most likely directly before the closing "body" element. This is the easiest way.
  2. You can create a dedicated file "goodrelations.rdf" in the RDF/XML format, upload it to your Web server, and link to that file from your Web page. The necessary steps are described here.
  3. You can create a dedicated textfile "goodrelations.n3" in the N3/Turtle format and proceed as in alternative 2. N3/Turtle is just more readable for humans.

UML Diagram

The following shows the relevant subset from the full UML diagram of GoodRelations:

700px|alt UML diagram of the GoodRelations subset for the simple example

Example in RDFa

Insert the following additional mark-up directly before the closing

in your Web page, i.e.

...

We sell and repair computers and motorbikes

<div ns="http://www.w3.org/1999/xhtml"

 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"

... SNIPPET FROM BELOW ...

Here is the complete snippet to be used for our example:

   ``
   ``
   ``
   ``
     

     ``
     ``
        

         ``
         ``
          

           ``
           ``
           ``
          

         ``
         ``
          

           ``
           ``
           ``
           ``
           ``
           ``
           ``
          

         ``
        

     ``
     ``
     ``
     ``
     ``
        

        ``
        ``
        

     ``
     ``
     ``
    

   ``
  

Ideally, you should also change the DOCTYPE in the header to "XHTML+RDFa":

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

Also, make sure that the "head" element includes the proper content type and encoding for XHTML:

<p>Hepp Industries Ltd. Main Page</p>

So the complete header should look like

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

<p>Hepp Industries Ltd. Main Page</p>

...

Example in N/Turtle

Create a new text file "goodrelations.n3" with the following content, upload it to your Web server, and link to that file from your Web page. The necessary steps are described here.

@prefix foo: <http://www.example.com/xyz#> .
@prefix gr: <http://purl.org/goodrelations/v1#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <xmlns:foaf="http://xmlns.com/foaf/0.1/> .

# Simple Example: Business Entity, Shop, and High-Level Descrition of Offers
foo:myCompany
    a gr:BusinessEntity ;
    foaf:page <http://www.example.com/xyz>;
    gr:legalName "Hepp Industries Ltd."^^xsd:string ;
    gr:hasPOS foo:myShop ;
    gr:offers foo:myOffering .
# The following three elements are the same as in the minimal example
foo:myShop
    a gr:LocationOfSalesOrServiceProvisioning ;
    foaf:page <http://www.example.com/xyz>;
    gr:hasOpeningHoursSpecification
        foo:Workdays,
        foo:Saturdays .
foo:Workdays
    a gr:OpeningHoursSpecification ;
    gr:opens "08:00:00"^^xsd:time ;
    gr:closes "18:00:00"^^xsd:time ;
    gr:hasOpeningHoursDayOfWeek
        gr:Monday, gr:Tuesday, gr:Wednesday, gr:Thursday, gr:Friday .
foo:Saturdays
    a gr:OpeningHoursSpecification ;
    gr:opens "08:30:00"^^xsd:time ;
    gr:closes "14:00:00"^^xsd:time ;
    gr:hasOpeningHoursDayOfWeek gr:Saturday .
# The following elements are in addition to those from the minimal example
foo:myOffering
    a gr:Offering;
    foaf:page <http://www.example.com/xyz>;
    rdfs:comment "We sell and repair computers and motorbikes"@en ;
    gr:includes foo:myProducts ;
    gr:hasBusinessFunction gr:Sell, gr:Repair ;
    gr:validFrom "2009-04-24T00:00:00+01:00"^^xsd:dateTime ;
    gr:validThrough "2010-04-24T00:00:00+01:00"^^xsd:dateTime ;
    gr:availableAtOrFrom foo:myShop .

foo:myProducts
    a gr:ProductOrServicesSomeInstancesPlaceholder;
    foaf:page <http://www.example.com/xyz>;
    rdfs:comment "computers and motorbikes"@en.
# one can attach more details on the products, see later


Example in RDF/XML

Create a new file "goodrelations.rdf" in the RDF/XML format with the following content, upload it to your Web server, and link to that file from your Web page. The necessary steps are described here.

 ``
   ``Hepp Industries Ltd.``
   ``
     ``
       ``
         ``
           ``08:00:00``
           ``18:00:00``
           ``
           ``
           ``
           ``
           ``
         ``

       ``

       ``
         ``
           ``08:30:00``
           ``14:00:00``
           ``
         ``

       ``

     ``

   ``

   ``
     ``
       ``We sell and repair computers and motorbikes``
       ``
         ``
           ``computers and motorbikes``
         ``

       ``

       ``
       ``
       ``2009-04-24T00:00:00+01:00``
       ``2010-04-24T00:00:00+01:00``
       ``
     ``

   ``

 ``

Extensions and Improvements

You can improve the rich meta-data in many ways.

Translations of Text Elements

You can provide translations of the strings "computer and motorbikes" and "We sell and repair computers and motorbikes", indicate the respective language tag, and attach the translations to both the gr:Offering and gr:ProductOrServiceSomeInstancesPlaceholder nodes.

Example:

   ``
   ``
   ``
  

Payment Methods

You can indicate which payment methods you accept by attaching those to the gr:Offering node:

...

Available payment methods are

  • AmericanExpress
  • DinersClub
  • Discover
  • MasterCard
  • VISAByBankTransferInAdvance
  • ByInvoice
  • COD
  • Cash
  • CheckInAdvance
  • DirectDebit and
  • PayPal.

For understanding the full range of options, please see the GoodRelations Primer.

Contact Details

You can attach the address and geo position of your main office and of your shop or shops to the respective elements. If you don't know the latitude and longitude of your addresses, you can easily use online services to determine them, e.g. the excellent one by Stephen P. Morse at http://stevemorse.org/jcal/latlon.php.

Important: Note that this also requires to define the namespace prefiyx "vcard:" as "http://www.w3.org/2006/vcard/ns".

Office

   ``

   ``
     ``
     ``
     ``
     ``
     ``
     ``
   ``

   ``
   ``
     ``
     ``
   ``

   ``

Shop

   ``
     ``
     ``
     ``
     ``
     ``
     ``
   ``

   ``
   ``
     ``
     ``
   ``

    ``

owl:imports

You can improve the ability of intelligent Web applications to reason about your data if your properly import the GoodRelations and vCard ontologies.

RDFa

     ``
     ``

N3

<>
    a    owl:Ontology;
    owl:imports
       <http://purl.org/goodrelations/v1>, <http://www.w3.org/2006/vcard/ns>.

RDF/XML

 ``
       ``
       ``
       ``
   ``

Query Example

Query Examples