/**
  * Execute a SPARQL query and return an RepositoryResult object
  * that contains the results. Compared to GenericHttpDatabaseConnector::doQuery(),
  * this also supports the parameter "restricted=1" which 4Store provides
  * to enforce strict resource bounds on query answering. The method also
  * checks if these bounds have been met, and records this in the query
  * result.
  *
  * @note The restricted option in 4Store mainly enforces the given soft
  * limit more strictly. To disable/configure it, simply change the soft
  * limit settings of your 4Store server.
  *
  * @param $sparql string with the complete SPARQL query (SELECT or ASK)
  * @return RepositoryResult
  */
 public function doQuery($sparql)
 {
     if ($this->repositoryClient->getQueryEndpoint() === '') {
         throw new BadHttpDatabaseResponseException(BadHttpDatabaseResponseException::ERROR_NOSERVICE, $sparql, 'not specified');
     }
     $this->httpRequest->setOption(CURLOPT_URL, $this->repositoryClient->getQueryEndpoint());
     $this->httpRequest->setOption(CURLOPT_HTTPHEADER, array('Accept: application/sparql-results+xml,application/xml;q=0.8'));
     $this->httpRequest->setOption(CURLOPT_POST, true);
     $defaultGraph = $this->repositoryClient->getDefaultGraph();
     $parameterString = "query=" . urlencode($sparql) . "&restricted=1" . ($defaultGraph !== '' ? '&default-graph-uri=' . urlencode($defaultGraph) : '');
     $this->httpRequest->setOption(CURLOPT_POSTFIELDS, $parameterString);
     $httpResponse = $this->httpRequest->execute();
     if ($this->httpRequest->getLastErrorCode() == 0) {
         $xmlResponseParser = new XmlResponseParser();
         $result = $xmlResponseParser->parse($httpResponse);
     } else {
         $this->mapHttpRequestError($this->repositoryClient->getQueryEndpoint(), $sparql);
         $result = new RepositoryResult();
         $result->setErrorCode(RepositoryResult::ERROR_UNREACHABLE);
     }
     foreach ($result->getComments() as $comment) {
         if (strpos($comment, 'warning: hit complexity limit') === 0 || strpos($comment, 'some results have been dropped') === 0) {
             $result->setErrorCode(RepositoryResult::ERROR_INCOMPLETE);
         }
         //else debug_zval_dump($comment);
     }
     return $result;
 }
 public function testInvalidXmlThrowsException()
 {
     $rawResultProvider = new FakeRawResultProvider();
     $instance = new XmlResponseParser();
     $this->setExpectedException('\\SMW\\SPARQLStore\\Exception\\XmlParserException');
     $instance->parse($rawResultProvider->getInvalidSparqlResultXml());
 }
 /**
  * @see GenericHttpRepositoryConnector::doQuery
  */
 public function doQuery($sparql)
 {
     if ($this->repositoryClient->getQueryEndpoint() === '') {
         throw new BadHttpDatabaseResponseException(BadHttpDatabaseResponseException::ERROR_NOSERVICE, $sparql, 'not specified');
     }
     $this->httpRequest->setOption(CURLOPT_URL, $this->repositoryClient->getQueryEndpoint());
     $this->httpRequest->setOption(CURLOPT_HTTPHEADER, array('Accept: application/sparql-results+xml,application/xml;q=0.8', 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8'));
     $this->httpRequest->setOption(CURLOPT_POST, true);
     $defaultGraph = $this->repositoryClient->getDefaultGraph();
     $parameterString = "query=" . urlencode($sparql) . ($defaultGraph !== '' ? '&default-graph-uri=' . urlencode($defaultGraph) : '') . '&output=xml';
     $this->httpRequest->setOption(CURLOPT_POSTFIELDS, $parameterString);
     $httpResponse = $this->httpRequest->execute();
     if ($this->httpRequest->getLastErrorCode() == 0) {
         $xmlResponseParser = new XmlResponseParser();
         return $xmlResponseParser->parse($httpResponse);
     }
     $this->mapHttpRequestError($this->repositoryClient->getQueryEndpoint(), $sparql);
     $repositoryResult = new RepositoryResult();
     $repositoryResult->setErrorCode(RepositoryResult::ERROR_UNREACHABLE);
     return $repositoryResult;
 }