This page describes a quick demo of how the Web of Data can be queried for product features for Camcorders.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX gr: <http://purl.org/goodrelations/v1#>
# show properties an property values for EAN "8714574993836"
SELECT ?p ?v ?uom WHERE
{
?uri rdf:type gr:ProductOrServiceModel.
?uri gr:hasEAN_UCC-13 "8714574993836"^^xsd:string.
?uri ?p ?qv.
?qv gr:hasValueFloat ?v.
?qv gr:hasUnitOfMeasurement ?uom.
}
Note: Instead of hasValueFloat, hasMaxValueFloat or hasMaxValue should be used, but this requires inferencing which may not be available on all endpoints.
Example:Query the Virtuoso LOD instance for the EAN code: [http://lod.openlinksw.com/sparql?default-graph-uri=&should-sponge=&query=PREFIX+xsd%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%3E%0D%0APREFIX+gr%3A+%3Chttp%3A%2F%2Fpurl.org%2Fgoodrelations%2Fv1%23%3E%0D%0A%0D%0A%23+show+properties+an+property+values+for+EAN+%228714574993836%22%0D%0A%0D%0ASELECT+%3Fp+%3Fv+%3Fuom+WHERE%0D%0A%7B%0D%0A%3Furi+rdf%3Atype+gr%3AProductOrServiceModel.%0D%0A%3Furi+gr%3AhasEAN_UCC-13++%228714574993836%22^^xsd%3Astring.%0D%0A%3Furi+%3Fp+%3Fqv.%0D%0A%3Fqv+gr%3AhasValueFloat+%3Fv.%0D%0A%3Fqv+gr%3AhasUnitOfMeasurement+%3Fuom.%0D%0A}&format=text%2Fhtml&debug=on&timeout= Click here]
#!/usr/bin/env python
# encoding: utf-8
"""
SemanticProductDB.py
Created by Martin Hepp on 2009-06-15.
Copyright (c) 2009 Universität der Bundeswehr. All rights reserved.
"""
import webbrowser
import urllib
def fetchProperties(ean):
'''Fetch product properties from the Semantic Web'''
= """
query PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX gr: <http://purl.org/goodrelations/v1#>
SELECT ?p ?v ?uom WHERE
{
?uri rdf:type gr:ProductOrServiceModel.
?uri gr:hasEAN_UCC-13 \""""+ean+"""\"^^xsd:string.
?uri ?p ?qv.
?qv gr:hasValueFloat ?v.
?qv gr:hasUnitOfMeasurement ?uom.
}
"""
= urllib.urlencode({'default-graph-uri': '', 'query': query,
params 'format': 'text/html', 'debug' : 'on', 'timeout' : ''})
open("http://lod2.openlinksw.com/sparql?%s" % params)
webbrowser.
while True:
= raw_input('Enter EAN or scan item') # fetch EAN from keyboard
ean if (ean==''): break # stop when input is empty
= "0"+ean
ean print ean # print EAN
fetchProperties(ean)print 'Program completed.'
Click on the following link to download a PDF document with barcodes that should work:
BarcodeFeatureDemo.pdf (file size: 103 KB, MIME type: application/pdf)