Source for file SparqlClient.php
Documentation is available at SparqlClient.php
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
* Client for querying a sparql server.
* @version $Id: fsource_sparql__sparqlSparqlClient.php.html 443 2007-06-01 16:25:38Z cax $
* @author Tobias Gauß <tobias.gauss@web.de>
* Constructor of SparlClient.
* @param String $server server address.
* Sets the output format for a SELECT or ASK query. Possible formats are "xml" for
* Sparql Query Results XML Format (http://www.w3.org/TR/rdf-sparql-XMLres/) or array
* for the format described in our SparqlEngine.
* @param String $format the format.
* Main function of SparqlClient.
* @param ClientQuery $query the ClientQuery object.
* @return mixed returns an array that contains the variables an their bindings or a MemModel
if(!is_a($query,"ClientQuery"))
* Helper function that builds the url.
* @param ClientQuery $query the ClientQuery Object.
foreach($query->default as $defaultg){
$url =
$url.
"&default-graph-uri=".
$defaultg;
foreach($query->named as $namedg){
$url =
$url.
"&named-graph-uri=".
$namedg;
* Returns the query result.
* @param String $result the result.
if(strpos($result,"<rdf:RDF")){
return $parser->generateModel(substr($result,strpos($result,"<rdf:RDF")));
$pos =
strpos($result,"<?xml");
// $pos = strpos($buffer,"<?xml");
return $parser->parse($buffer);
* Executes the GET Request.
* @param String $url the url.
$port = isset
($url['port']) ?
$url['port'] :
80;
fputs($fp, "GET ".
$replace.
"?".
$url['query'].
" HTTP/1.0\n");
fputs($fp, "Host:".
$url['host'].
" \r\n");
fputs($fp, "Accept: application/sparql-results+xml, application/rdf+xml\r\n");
fputs($fp, "Connection: close\n\n");
while ($tmp =
fread($fp, 1024))
$pos1 =
strpos($buffer,"\r\n\r\n");
$pos2 =
strpos($buffer,"\n\n");
Documentation generated on Fri, 1 Jun 2007 16:51:59 +0200 by phpDocumentor 1.3.2