- From: Kurt J <kurtjx@gmail.com>
- Date: Tue, 25 Aug 2009 10:30:11 +0100
- To: Terry Brooks <tabrooks@u.washington.edu>
- Cc: "public-lod@w3.org" <public-lod@w3.org>
> ====== SNIP ============
>
> <title>Error 400 Parse error:
> prefix foaf: <http://xmlns.com/foaf/0.1/> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns
>
> Encountered "<" at line 1, column 57.
> Was expecting:
> <IRIref> ...
> </title>
> </head>
i believe your mistake is in the url encoding. you're using the
HTML-style encoding where < becomes <
actually, you can just leave '<' and '>' unencoded i think. i'm using
python to make the query -
In [1]: import urllib
In [2]: query = '''prefix foaf: <http://xmlns.com/foaf/0.1/> prefix
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?type
WHERE { ?name foaf:name 'Screwtape' . ?name rdf:type ?type }'''
In [3]: query_esc = urllib.quote(query)
In [4]: response =
urllib.urlopen('http://dbtune.org/musicbrainz/sparql?query='+query_esc)
In [5]: print response.read()
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="type"/>
</head>
<results>
<result>
<binding name="type">
<uri>http://purl.org/ontology/mo/MusicArtist</uri>
</binding>
</result>
</results>
</sparql>
notice i'm just using the handy urllib library to do the url escaping.
which ever language you're using, there is surely a similar library.
also for completeness, here's what the percent encoded query looks like:
In [6]: print query_esc
prefix%20foaf%3A%20%3Chttp%3A//xmlns.com/foaf/0.1/%3E%20%20prefix%20rdf%3A%20%20%3Chttp%3A//www.w3.org/1999/02/22-rdf-syntax-ns%23%3E%20%20SELECT%20%3Ftype%20WHERE%20%7B%20%3Fname%20foaf%3Aname%20%27Screwtape%27%20.%20%3Fname%20rdf%3Atype%20%3Ftype%20%20%7D
I also recommend SPARQLWrapper for python for querying endpoints.
http://sparql-wrapper.sourceforge.net/
Hope this helps!
-kurt
Received on Tuesday, 25 August 2009 09:30:51 UTC