php - Could not handle ?university dbpedia-owl:count in ARC2 -
i'm using simple sparql query list of universities selected country. , of sparql code
select ?name ?type { ?university <http://schema.org/collegeoruniversity> { ?university dbpedia-owl:country dbpedia:france } union { ?university dbpprop:country dbpedia:france } optional { ?university dbpprop:name ?name . filter (langmatches(lang(?name), 'fr')) } optional { ?university dbpedia-owl:type ?type }
to show result in php side, i'm using arc2 library use php query sparql endpoints , generate html pages. steps doc ok.
here full php code sparql query server side:
<html> <body> <?php include_once('semsol/arc2.php'); /* arc2 static class inclusion */ $dbpconfig = array( "remote_store_endpoint" => "http://dbpedia.org/sparql", ); $store = arc2::getremotestore($dbpconfig); if ($errs = $store->geterrors()) { echo "<h1>getremotesotre error<h1>" ; } $query = ' prefix foaf: <http://xmlns.com/foaf/0.1/> prefix dc: <http://purl.org/dc/elements/1.1> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix address: <http://www.w3.org/addressing/schemes.html> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> select ?name ?type { ?university <http://schema.org/collegeoruniversity> { ?university dbpedia-owl:country dbpedia:france } union { ?university dbpprop:country dbpedia:france } optional { ?university dbpprop:name ?name . filter (langmatches(lang(?name), 'fr')) } optional { ?university dbpedia-owl:type ?type } } order ?name '; $rows = $store->query($query, 'rows'); /* execute query */ if ($errs = $store->geterrors()) { echo "query errors" ; print_r($errs); } /* display results in html table */ echo "<table border='1'>" ; foreach( $rows $row ) { /* loop each returned row */ print "<tr><td>" .$row['l'] . "</td><td>" . $row['c']. "</td></tr>"; } echo "</table>" ?> </body> </html>
but when run code on server side that's error handling
query errorsarray ( [0] => incomplete or invalid group graph pattern. not handle " ?university dbpedia-owl:count" in arc2_sparqlplusparser [1] => incomplete or invalid group graph pattern. not handle " { ?univers" in arc2_sparqlplusparser )
so there solution? many thanks
your query doesn't include prefixes dbpedia-owl, dbpedia or dbpprop. when use web service interactively, these defined automatically, when connect remotely, still need include them. can see full list of prefixes defined in browser.
i'd guess that's what's happening when dbpedia-owl:count realizes it's seen count, legal sparql keyword, , realizes dbpedia-owl: didn't make sense. (i'm not familiar arc's parser, though; guess.)
i expect may run issues doing:
$query = '...'fr'...';
i'm not php user, i'm not how that's handled, looks single quotes need escaped, or need use double quotes.
Comments
Post a Comment