本文整理汇总了PHP中MemModel::addNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP MemModel::addNamespace方法的具体用法?PHP MemModel::addNamespace怎么用?PHP MemModel::addNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemModel
的用法示例。
在下文中一共展示了MemModel::addNamespace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOverwritingDefaultManual
/**
* tests if the manual set namespaceprefix 'foo' overwrites the prefix 'rdf' defined in
* the default_prefixes array.
*/
function testOverwritingDefaultManual()
{
$_SESSION['test'] = 'Overwriting default manual test';
$model = new MemModel();
$pars = new N3Parser();
$model = $pars->parse2model($this->_generateModelString());
$ser = new RdfSerializer();
$string = $ser->serialize($model);
$model2 = new MemModel();
$model2->load($string);
$this->assertEqual($model2->parsedNamespaces[RDF_NAMESPACE_URI], 'rdf');
$model2->addNamespace('foo', RDF_NAMESPACE_URI);
$this->assertEqual($model2->parsedNamespaces[RDF_NAMESPACE_URI], 'foo');
$model2->removeNamespace(RDF_NAMESPACE_URI);
//$this->assertEqual($model2->parsedNamespaces[RDF_NAMESPACE_URI] , null);
}
示例2: geoLookup
function geoLookup($lat, $long, $radius, &$resultsLabel)
{
global $FLICKRSERVICE;
$resURI = DBPEDIA_URI_ROOT . wikipediaEncode($_REQUEST['item']);
$locationURI = FLICKRWRAPPR_LOCATION_URI_ROOT . $_REQUEST['lat'] . '/' . $_REQUEST['long'] . '/' . $_REQUEST['radius'];
$dataURI = FLICKRWRAPPR_LOCATION_DATA_URI_ROOT . $_REQUEST['lat'] . '/' . $_REQUEST['long'] . '/' . $_REQUEST['radius'];
/* Initialize result model */
$resultModel = new MemModel();
$resultModel->addNamespace('foaf', 'http://xmlns.com/foaf/0.1/');
$resultModel->addNamespace('dcterms', 'http://purl.org/dc/terms/');
$resultModel->addNamespace('rdfs', 'http://www.w3.org/2000/01/rdf-schema#');
//$resultModel->addNamespace('geonames', 'http://www.geonames.org/ontology#');
$resultModel->addNamespace('geo', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
$resultModel->addNamespace('georss', 'http://www.georss.org/georss/');
/* Perform flickr search */
$flickrPhotos = $FLICKRSERVICE->getFlickrPhotos('', $lat, $long, $radius / 1000);
/* Process found photos */
foreach ($flickrPhotos as $flickrPhoto) {
/* Provide the picture itself (small version) */
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://xmlns.com/foaf/0.1/depiction"), new Resource($flickrPhoto['imgsmall'])));
/* Provide its page on flickr */
$resultModel->add(new Statement(new Resource($flickrPhoto['imgsmall']), new Resource("http://xmlns.com/foaf/0.1/page"), new Resource($flickrPhoto['flickrpage'])));
}
if ($resultModel->size() > 0) {
/* Add metadata for location */
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), new Resource("http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing")));
$latLiteral = new Literal($lat);
$latLiteral->setDatatype("http://www.w3.org/2001/XMLSchema#float");
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://www.w3.org/2003/01/geo/wgs84_pos#lat"), $latLiteral));
$longLiteral = new Literal($long);
$longLiteral->setDatatype("http://www.w3.org/2001/XMLSchema#float");
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://www.w3.org/2003/01/geo/wgs84_pos#long"), $longLiteral));
$radiusLiteral = new Literal($radius);
$radiusLiteral->setDatatype("http://www.w3.org/2001/XMLSchema#double");
$resultModel->add(new Statement(new Resource($locationURI), new Resource("http://www.georss.org/georss/radius"), $radiusLiteral));
/* Add metadata for document */
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), new Resource("http://xmlns.com/foaf/0.1/Document")));
$resultsLabel = "Photos taken within {$radius} meters of geographic location lat={$lat} long={$long}";
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://www.w3.org/2000/01/rdf-schema#label"), new Literal($resultsLabel, "en")));
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://xmlns.com/foaf/0.1/primaryTopic"), new Resource($locationURI)));
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://purl.org/dc/terms/license"), new Resource(FLICKR_TOS_URL)));
$resultModel->add(new Statement(new Resource($dataURI), new Resource("http://xmlns.com/foaf/0.1/maker"), new Resource(FLICKRWRAPPR_HOMEPAGE)));
$resultModel->add(new Statement(new Resource(FLICKRWRAPPR_HOMEPAGE), new Resource("http://www.w3.org/2000/01/rdf-schema#label"), new Literal("flickr(tm) wrappr", "en")));
}
return $resultModel;
}