本文整理汇总了PHP中ARC2::getSPARQLXMLResultParser方法的典型用法代码示例。如果您正苦于以下问题:PHP ARC2::getSPARQLXMLResultParser方法的具体用法?PHP ARC2::getSPARQLXMLResultParser怎么用?PHP ARC2::getSPARQLXMLResultParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARC2
的用法示例。
在下文中一共展示了ARC2::getSPARQLXMLResultParser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runQuery
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;
}
示例2: isSameSelectResult
function isSameSelectResult($qr, $result, $result_base)
{
if (strpos($result, 'http://www.w3.org/2001/sw/DataAccess/tests/result-set#')) {
$parser = ARC2::getRDFParser($this->a);
$parser->parse($result_base, $result);
$index = $parser->getSimpleIndex(0);
//echo '<pre>' . print_r($index, 1) .'</pre>';
$valid_qr = $this->buildTurtleSelectQueryResult($index);
} else {
$parser = ARC2::getSPARQLXMLResultParser($this->a);
$parser->parse('', $result);
$valid_qr = $parser->getStructure();
}
if (isset($valid_qr['boolean'])) {
$pass = $valid_qr['boolean'] == $this->v('boolean', '', $qr);
} else {
$pass = 1;
if (count($valid_qr['variables']) != count($qr['variables'])) {
$pass = 0;
}
if (count($valid_qr['rows']) != count($qr['rows'])) {
$pass = 0;
}
if ($pass) {
foreach ($valid_qr['variables'] as $var) {
if (!in_array($var, $qr['variables'])) {
$pass = 0;
break;
}
}
}
if ($pass) {
$index = $this->buildArrayHashIndex($qr['rows']);
$valid_index = $this->buildArrayHashIndex($valid_qr['rows']);
if (($diff = array_diff($index, $valid_index)) || ($diff = array_diff($valid_index, $index))) {
$pass = 0;
//echo '<pre>' . print_r($diff, 1) . '</pre>';
}
}
}
return array('pass' => $pass, 'info' => $valid_qr);
}