当前位置: 首页>>代码示例>>PHP>>正文


PHP MemModel::addNamespace方法代码示例

本文整理汇总了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);
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:20,代码来源:Namespace_handling_tests.php

示例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;
}
开发者ID:ljarray,项目名称:dbpedia,代码行数:46,代码来源:flickrwrappr.php


注:本文中的MemModel::addNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。