## ------------------------------------
// 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";
// Base URI of the new model (optional)
$baseURI = "baseURIofMyNewDbModel#";
// get a new DbModel
if ($rdf_database->modelExists($modelURI)) {
    echo "Model with the same URI: '{$modelURI}' already exists";
} else {
    $dbModel = $rdf_database->getNewModel($modelURI, $baseURI);
}
示例#2
0
    header('HTTP/1.0 500 Internal Server Error');
    echo "500 - Didn't get modelURI from URL rewriting.\n";
    return;
}
$modelId = $modelmap[$model];
if ($modelId == NULL) {
    // Didn't get modelID from URL rewriting
    header('HTTP/1.0 404 Not Found');
    echo "404 - Model " . $model . " not found";
    return;
} elseif (substr($modelId, 0, 3) == "db:") {
    // Database backed model
    $modelURI = substr($modelId, 3);
    $database = new DbStore($NETAPI_DB_DRIVER, $NETAPI_DB_HOST, $NETAPI_DB_DB, $NETAPI_DB_USER, $NETAPI_DB_PASS);
    $type = 'model';
    if ($database->modelExists($modelURI) == False) {
        $type = 'dataset';
        if ($database->datasetExists($modelURI) == False) {
            // 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