ARC2::getSPARQLXMLResultParser PHP Method

getSPARQLXMLResultParser() static public method

static public getSPARQLXMLResultParser ( $a = '' )
    static function getSPARQLXMLResultParser($a = '')
    {
        return ARC2::getParser('SPARQLXMLResult', $a);
    }

Usage Example

 private function runQuery($q, $qt = '', $infos = '')
 {
     /* ep */
     $ep = $this->_arc2_RemoteStore->v('remote_store_endpoint', 0, $this->_arc2_RemoteStore->a);
     if (!$ep) {
         return $this->_arc2_RemoteStore->addError('No Endpoint defined.');
     }
     /* prefixes */
     $q = $this->_arc2_RemoteStore->completeQuery($q);
     /* custom handling */
     $mthd = 'run' . $this->_arc2_RemoteStore->camelCase($qt) . 'Query';
     if (method_exists($this, $mthd)) {
         return $this->_arc2_RemoteStore->{$mthd}($q, $infos);
     }
     if (in_array($qt, array('insert', 'delete'))) {
         if ($this->_readOnly) {
             return $this->_arc2_RemoteStore->addError('No right to write in the triplestore.');
         } else {
             $s = new FourStore_Store($ep, $this->_debug);
             $r = $s->queryUpdate($q);
             if (!$r) {
                 $errmsg = "Error unknown.";
                 if (Net::ping($ep) == -1) {
                     $errmsg = "Could not connect to " . $ep;
                 }
                 return $this->_arc2_RemoteStore->addError($errmsg);
             }
         }
     } else {
         $s = new FourStore_Store($ep, $this->_debug);
         $resp = $s->queryRead($q);
         if ($resp == "") {
             $errmsg = "Error unknown.";
             if (Net::ping($ep) == -1) {
                 $errmsg = "Could not connect to " . $ep;
             }
             return $this->_arc2_RemoteStore->addError($errmsg);
         }
         if (preg_match_all('%<!--(.*error.*)-->%m', $resp, $errorResponse)) {
             $message4s = $errorResponse[1][0];
             return $this->_arc2_RemoteStore->addError("4Store message : " . $message4s . "\n query :\n" . $q);
         }
         $parser = @ARC2::getSPARQLXMLResultParser();
         $parser->parse('', $resp);
         $err = $parser->getErrors();
         if ($err) {
             return $this->_arc2_RemoteStore->addError($err);
         }
         if ($qt == 'ask') {
             $bid = $parser->getBooleanInsertedDeleted();
             $r = $bid['boolean'];
         } elseif ($qt == 'select' && !method_exists($parser, 'getRows')) {
             $r = $resp;
         } elseif ($qt == 'select') {
             $r = array('rows' => $parser->getRows(), 'variables' => $parser->getVariables());
         } else {
             $r = $parser->getSimpleIndex(0);
         }
         unset($parser);
     }
     return $r;
 }
All Usage Examples Of ARC2::getSPARQLXMLResultParser