|
From: Visser, D. <dv...@id...> - 2013-08-20 14:20:54
|
Mariano: Carlos has a point. I know that with the triple stores I work with (based on OpenRDF Sesame), it is necessary to include prefix declarations for any prefixes you use in your SPARQL query. In your case, the query would need these declarations: PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> PREFIX dbpprop: <http://dbpedia.org/property/> However, I have tried the query below1, which lacks explicit prefix declarations, two different ways. First, entering it on the web page at http://dbpedia.org/sparql, and second, hitting the same URL as a SPARQL endpoint. It worked fine both ways. So, the prefixes given at http://dbpedia.org/sparql?nsdecl are defined for you even if you don't include them explicitly in your query. Best regards, Dale [1] SELECT * { <http://dbpedia.org/resource/Tim_Cook> dbpedia-owl:abstract ?abstract . FILTER (lang(?abstract) = "en") } From: Carlos Tejo [mailto:car...@fu...] Sent: Tuesday, August 20, 2013 6:54 AM To: spa...@li... Subject: Re: [sparql-wrapper-devel] Query bad formed Dear Mariano, Maybe the problem is the declaration of the prefixes (i can't find it in the sent snippet). And you should check the WHERE clause. It seems that something is broken. As a tip, you can check the SPARQL query in a web-based SPARQL endpoint (such as [1]), that maybe returns more information about the problem. Best regards, Carlos Tejo [1] http://dbpedia.org/sparql Carlos Tejo Alonso CTIC-Centro Tecnológico Parque Científico y Tecnológico de Gijón c/ Ada Byron, 39 Edificio Centros Tecnológicos 33203 Gijón - Asturias - Spain Tel.: +34 984 29 12 12 Fax: +34 984 39 06 12 E-mail: car...@fu...<mailto:car...@fu...> http://www.fundacionctic.org Privacy Policy: http://www.fundacionctic.org/privacidad On 16 August 2013 17:18, Mariano Alvarez <ro...@li...<mailto:ro...@li...>> wrote: Thanks for your response Dale, but I keep getting the error. This is the updated query: u"\n SELECT * WHERE { <http://dbpedia.org/resource/Tim_Cook>.\n ?x dbpedia-owl:abstract ?abstract.\n OPTIONAL { ?x dbpedia-owl:birthDate ?birthDate }\n OPTIONAL { ?x dbpedia-owl:birthPlace ?birthPlace }\n OPTIONAL { ?x dbpprop:name ?name }\n OPTIONAL { ?x dbpedia-owl:profession ?profession }\n OPTIONAL { ?x dbpprop:residence ?residence }\n OPTIONAL { ?x dbpprop:website ?website }\n \n FILTER (LANG(?abstract) = 'en')\n }\n " ________________________________ From: dv...@id...<mailto:dv...@id...> To: spa...@li...<mailto:spa...@li...> Date: Fri, 16 Aug 2013 11:08:03 -0400 Subject: Re: [sparql-wrapper-devel] Query bad formed Mariano: There is a period after the first URI in the graph pattern, which is only supposed to come after a complete triple pattern: u"\n SELECT * WHERE {\n <http://dbpedia.org/resource/Tim_Cook>.\n ?x dbpedia-owl:abstract ?abstract.\n OPTIONAL { ?x dbpedia-owl:birthDate ?birthDate. OPTIONAL { ?x dbpedia-owl:birthPlace ?birthPlace. OPTIONAL { ?x dbpprop:name ?name. OPTIONAL { ?x dbpedia-owl:profession ?profession. OPTIONAL { ?x dbpprop:residence ?residence. OPTIONAL { ?x dbpprop:website ?website.\n FILTER (LANG(?abstract) = 'en')\n }\n " Best regards, Dale Visser From: Mariano Alvarez [mailto:ro...@li...<mailto:ro...@li...>] Sent: Friday, August 16, 2013 10:20 AM To: spa...@li...<mailto:spa...@li...> Subject: [sparql-wrapper-devel] Query bad formed I'm trying to build a sparql query based on a list of properties but I get an error saying that the query is bad formed. The problem is I don't know what to do to fix it. This is the function: def create_query(dbpedia_uri, props): #props are something like this ('dbpedia-owl', 'birthdate') filters = '' for prop in QUERIES_DICT[ename]: filters += ' OPTIONAL { ?x %s:%s ?%s.' % (corresp_dict[prop[0]], prop[1], prop[1]) query = u""" SELECT * WHERE { . <%s>. ?x dbpedia-owl:abstract ?abstract. %s FILTER (LANG(?abstract) = 'en') } """ % (dbpedia_uri, filters) return query This is the query I get: u"\n SELECT * WHERE {\n <http://dbpedia.org/resource/Tim_Cook>.\n ?x dbpedia-owl:abstract ?abstract.\n OPTIONAL { ?x dbpedia-owl:birthDate ?birthDate. OPTIONAL { ?x dbpedia-owl:birthPlace ?birthPlace. OPTIONAL { ?x dbpprop:name ?name. OPTIONAL { ?x dbpedia-owl:profession ?profession. OPTIONAL { ?x dbpprop:residence ?residence. OPTIONAL { ?x dbpprop:website ?website.\n FILTER (LANG(?abstract) = 'en')\n }\n " ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with _______________________________________________ sparql-wrapper-devel mailing list spa...@li...<mailto:spa...@li...> https://lists.sourceforge.net/lists/listinfo/sparql-wrapper-devel ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ sparql-wrapper-devel mailing list spa...@li...<mailto:spa...@li...> https://lists.sourceforge.net/lists/listinfo/sparql-wrapper-devel |