本文整理汇总了PHP中MemModel::load方法的典型用法代码示例。如果您正苦于以下问题:PHP MemModel::load方法的具体用法?PHP MemModel::load怎么用?PHP MemModel::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemModel
的用法示例。
在下文中一共展示了MemModel::load方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function _doFindFromFile($file, &$model)
{
$nullVarURIs = array('var:x', 'var:y', 'var:z');
$mod = new MemModel();
$mod->load($file);
$return = new MemModel();
foreach ($mod->triples as $statement) {
if (in_array($statement->getLabelSubject(), $nullVarURIs)) {
$findS = null;
} else {
$findS = $statement->getSubject();
}
if (in_array($statement->getLabelPredicate(), $nullVarURIs)) {
$findP = null;
} else {
$findP = $statement->getPredicate();
}
if (in_array($statement->getLabelObject(), $nullVarURIs)) {
$findO = null;
} else {
$findO = $statement->getObject();
}
$return->addModel($model->find($findS, $findP, $findO));
}
return $return;
}
示例2: testRdfParser
function testRdfParser()
{
$_SESSION['test'] = 'Rdf- Parser Empty Resource test';
$mod1 = new MemModel();
$mod2 = new MemModel();
$mod1->load('emptyResource.rdf');
$mod2->load('emptyResource_serialized.rdf');
if ($mod1->equals($mod2)) {
$pass = true;
} else {
$pass = false;
}
$this->assertTrue($pass);
}
示例3: testIsEquals
function testIsEquals()
{
foreach ($_SESSION['rdf_positive_tests'] as $key => $value) {
$model1 = new MemModel();
$model2 = new MemModel();
$file = $value;
$_SESSION['test'] =& $value;
$_SESSION['key'] =& $key;
$model1->load(TESTCASES_DIR . $file . ".rdf");
$_SESSION['mod1'] = $model1;
$model2->load(TESTCASES_DIR . $file . ".nt");
$_SESSION['mod2'] = $model2;
$this->assertTrue($model1->equals($model2));
}
}
示例4: loadNamespaces
/**
* loads namespaces from file or rewrites from configuration model
*/
function loadNamespaces($url)
{
if ($url) {
$nmsp_m = new MemModel();
$nmsp_m->load($url);
$this->ns = $nmsp_m->getParsedNamespaces();
if (!$this->ns) {
trigger_error("The file:" . $url . "does not contain any namespace declarations." . "The prefixes from the configuration model will be used instead");
}
} else {
$nmsp = $this->m->getParsedNamespaces();
if ($nmsp) {
$this->ns = RAPpubbyURIrewriter::rewrNamespaces($nmsp);
}
}
}
示例5: testOverwritingDefaultParser
/**
* parser overwrites the prefixes defined in the default_prefixes array
*/
function testOverwritingDefaultParser()
{
$_SESSION['test'] = 'Overwriting default parser test';
$string = "<?xml version='1.0'?>\n \t\t\t\t<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'\n \t\t\txmlns:exterms='http://www.example.org/terms/'>\n\t\t\t\t\t<rdf:Description rdf:about='http://www.example.org/index.html'>\n\t\t\t\t\t\t<exterms:creation-date>August 16, 1999</exterms:creation-date>\n\t\t\t\t\t</rdf:Description>\n\t\t\t\t</rdf:RDF>";
// delete default prefixes
global $default_prefixes;
$backup = $default_prefixes;
foreach ($default_prefixes as $name => $pref) {
unset($default_prefixes[$name]);
}
$default_prefixes = array('foo' => RDF_NAMESPACE_URI);
$model = new MemModel();
$model->load($string);
$nmsp = $model->getParsedNamespaces();
$this->assertEqual($nmsp[RDF_NAMESPACE_URI], 'rdf');
$default_prefixes = $backup;
}
示例6: testRdfSerializer
function testRdfSerializer()
{
$_SESSION['test'] = 'Rdf- Parser Empty Resource test';
$mod1 = new MemModel();
$mod2 = new MemModel();
$mod3 = new MemModel();
$mod1->load('multipleTypes.rdf');
$mod1->saveAs('mt1.rdf', 'rdf');
$mod3->load('mt1.rdf');
$mod2->load('multipleTypes.rdf');
$_SESSION['mod1'] = $mod3;
$_SESSIOn['mod2'] = $mod2;
if ($mod3->equals($mod2)) {
$pass = true;
} else {
$pass = false;
}
$this->assertTrue($pass);
}
示例7: unset
function testGetModelByRDQL6()
{
if (isset($model2)) {
}
unset($model2);
$_SESSION['test'] = 'simple rdql query6';
$model = new MemModel();
$model->load('employees.rdf');
$query = ' SELECT ?resource, ?email
WHERE (?resource, vcard:N, ?blank1)
(?blank1, vcard:Family, ?familyName)
(?resource, vcard:EMAIL, ?blank2)
(?blank2, rdf:value, ?email)
(?blank2, rdf:type, vcard:work)
AND ?familyName ~~ "/^M/"
USING vcard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>';
$model2 = $model->getMemModelByRDQL($query);
$this->assertEqual($model2->size(), 5);
}
示例8: database
define("RDFAPI_INCLUDE_DIR", "./../api/");
include RDFAPI_INCLUDE_DIR . "RdfAPI.php";
## 1. Connect to MsAccess database (via ODBC)
## ------------------------------------------
// Connect to MsAccess (rdf_db DSN) database using connection settings
// defined in constants.php :
$rdf_database = new DbStore();
## 2. Store a memory model in database.
## ------------------------------------
// Load an RDF-Documtent into a memory model
// Filename of an RDF document
$base = "example1.rdf";
// Create a new memory model
$memModel = new MemModel();
// Load and parse document
$memModel->load($base);
// Now store the model in database
// An unique modelURI will be generated
$rdf_database->putModel($memModel);
// You can also provide an URI for the model to be stored
$modelURI = "example1.rdf";
// But then you must check if there already is a model with the same modelURI
// otherwise the method putModel() will return FALSE
if ($rdf_database->modelExists($modelURI)) {
echo "Model with the same URI: '{$modelURI}' already exists";
} else {
$rdf_database->putModel($memModel, $modelURI);
}
## 3. Create a new database model
## ------------------------------
$modelURI = "newDbModel";
示例9: MemModel
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test Traverse MemModel</title>
</head>
<body>
<?php
define("RDFAPI_INCLUDE_DIR", "./../api/");
include RDFAPI_INCLUDE_DIR . "RdfAPI.php";
// Filename of an RDF document
$base = "example1.rdf";
// Create a new MemModel
$model = new MemModel();
// Load and parse document
$model->load($base);
// Get Iterator from model
$it = $model->getStatementIterator();
// Traverse model and output statements
while ($it->hasNext()) {
$statement = $it->next();
echo "Statement number: " . $it->getCurrentPosition() . "<BR>";
echo "Subject: " . $statement->getLabelSubject() . "<BR>";
echo "Predicate: " . $statement->getLabelPredicate() . "<BR>";
echo "Object: " . $statement->getLabelObject() . "<P>";
}
// Move to the last statement and print it
$it->moveLast();
$statement = $it->current();
// Traverse model backward and print statements
echo $statement->toString() . "<BR>";
示例10: header
// Model not found in the database
header('HTTP/1.0 404 Not Found');
echo "404 - Model " . $model . " not found\n";
return;
}
}
if ($type == 'model') {
$model1 = $database->getModel($modelURI);
} else {
$model1 = $database->getDatasetDb($modelURI);
}
} elseif (substr($modelId, 0, 5) == "file:") {
// File backed model
$modelURI = substr($modelId, 5);
$model1 = new MemModel();
$model1->load($modelURI);
} else {
// Undefined repository type
header('HTTP/1.0 500 Internal Server Error');
echo "500 - I don't understand " . $modelId;
}
// Process query or update operation
if ($_SERVER['QUERY_STRING'] != '') {
$headers = getallheaders();
if (isset($_REQUEST['op'])) {
$op = $_REQUEST['op'];
if ($op == "add") {
// Add Operation
if (NETAPI_ALLOW_ADD == True) {
addStatementsToModel($model1, $headers['Content-Type'], $HTTP_RAW_POST_DATA);
} else {
示例11: testAllTestgroupsNoReload
public function testAllTestgroupsNoReload()
{
echo "<b>SparqlDbTests</b><br/>\n";
//prepare
$parser = new SparqlParser();
$strLastDataFile = null;
foreach ($_SESSION['sparqlTestGroups'] as $arGroup) {
if (isset($arGroup['deact'])) {
continue;
}
//echo count($_SESSION[$arGroup['tests']]) . " tests\n";
foreach ($_SESSION[$arGroup['tests']] as $name) {
if (isset($name['type']) && ($name['type'] == 'syntax-negative' || $name['type'] == 'syntax-positive')) {
//skip syntax tests; they are run in SparqlParserTests
continue;
}
$checkfunc = $arGroup['checkfunc'];
$fileData = null;
$fileResult = null;
$fileQuery = null;
if (is_array($name)) {
if (isset($name['data'])) {
if (!file_exists(SPARQL_TESTFILES . $name['data'])) {
$fileData = 'data/' . $name['data'];
} else {
$fileData = $name['data'];
}
}
if (!file_exists(SPARQL_TESTFILES . $name['query'])) {
$fileQuery = 'query/' . $name['query'] . '.rq';
} else {
$fileQuery = $name['query'];
}
if (isset($name['result'])) {
if (!file_exists(SPARQL_TESTFILES . $name['result'])) {
$fileResult = 'result/' . $name['result'] . '.res';
} else {
$fileResult = $name['result'];
}
}
if (isset($name['title'])) {
$title = $name['title'];
} else {
$title = $name['query'];
}
} else {
$fileData = 'data/' . $name . '.n3';
$fileQuery = 'query/' . $name . '.rq';
$fileResult = 'result/' . $name . '.res';
$title = $name;
}
if (in_array($title, $_SESSION['testSparqlDbTestsIgnores'])) {
if (isset($GLOBALS['debugTests'])) {
echo Console_Color::convert('%y');
echo ' ignoring ' . $title . "\n";
echo Console_Color::convert('%n');
}
continue;
}
//echo ' ' . $title . "\n";
$_SESSION['test'] = $title . ' test';
$e = null;
if (isset($name['earl:name'])) {
//fix some weird issue with simpletest
$earlname = $name['earl:name'];
$this->signal('earl:name', $earlname);
}
if ($fileData != null && $fileData != $strLastDataFile) {
//re-use database if not changed
list($database, $dbModel) = $this->prepareDatabase();
//import statements into database
$dbModel->load(SPARQL_TESTFILES . $fileData, 'n3');
$strLastDataFile = $fileData;
}
$qs = file_get_contents(SPARQL_TESTFILES . $fileQuery);
if ($fileResult !== null) {
$res = file_get_contents(SPARQL_TESTFILES . $fileResult);
if (substr($fileResult, -4) == '.srx') {
//Sparql XML result
$resParser = new SparqlResultParser();
$result = $resParser->parse($res);
} else {
if (substr($fileResult, -4) == '.rdf') {
//same format as .ttl, but serialized as xml
//rdf xml sorted
$resModel = new MemModel();
$resModel->load(SPARQL_TESTFILES . $fileResult, 'rdf');
$result = SparqlTestHelper::convertModelToResultArray($resModel);
unset($resModel);
$checkfunc = 'resultCheckSort';
} else {
if (substr($fileResult, -4) == '.res') {
//our own php code
unset($result);
eval($res);
} else {
if (substr($fileResult, -4) == '.ttl') {
//N3
$resModel = new MemModel();
$resModel->load(SPARQL_TESTFILES . $fileResult, 'n3');
//.........这里部分代码省略.........