Could not handle ?university dbpedia-owl:count in ARC2

I'm using simple SPARQL query to get a list of universities for selected country. and that some of SPARQL code

SELECT ?name ?type 
WHERE 
  {   ?university  a                    <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 a result in PHP side, I'm using ARC2 library to use PHP to query SPARQL endpoints and generate HTML pages. All steps from the doc is ok.

Here that full PHP code with 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 
             WHERE {
                       ?university  a                     <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 BY ?name
          ';


  $rows = $store->query($query, 'rows'); /* execute the query */

  if ($errs = $store->getErrors()) {
     echo "Query errors" ;
     print_r($errs);
  }

  /* display the results in an HTML table */
  echo "<table border='1'>" ;
  foreach( $rows as $row ) { /* loop for each returned row */
         print "<tr><td>" .$row['l'] . "</td><td>" . $row['c']. "</td></tr>";
  }
  echo "</table>"

  ?>
  </body>
</html>

but when I run my code on server side that's error handling

Query errorsArray ( [0] => Incomplete or invalid Group Graph pattern. Could not handle " ?university dbpedia-owl:count" in ARC2_SPARQLPlusParser [1] => Incomplete or invalid Group Graph pattern. Could not handle " { ?univers" in ARC2_SPARQLPlusParser )

So is there any solution? Many thanks

Answers


Your query doesn't include the prefixes for dbpedia-owl, dbpedia or dbpprop. When you use the web service interactively, these are defined automatically, but when you connect remotely, you still need to include them. You can see the full list of prefixes that get defined in the browser.

I'd guess that's what's happening is that when you get to dbpedia-owl:count it realizes that it's seen count, which is a legal SPARQL keyword, and then realizes that dbpedia-owl: didn't make sense. (I'm not familiar with ARC's parser, though; this is just a guess.)

I expect that you may also run into issues by doing:

$query = '...'fr'...';

I'm not a PHP user, so I'm not certain how that's handled, but it looks like those single quotes need to be escaped, or that you need to use double quotes.


Need Your Help

displaying the proper name for my pdf report

java spring jasper-reports ireport

I am working with iReport 4.5.0, Spring 3.0.5 Release. I am using this link as the sample to my project because it matches to my requirement exactly.

scribd_fu gsub error

ruby-on-rails gsub scribd

I have an application which allow user upload documents to Scribd. I tried to use scribd_fu in Rails. An error occurred when the controller try to save the model.