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


PHP ARC2::getRDFXMLSerializer方法代码示例

本文整理汇总了PHP中ARC2::getRDFXMLSerializer方法的典型用法代码示例。如果您正苦于以下问题:PHP ARC2::getRDFXMLSerializer方法的具体用法?PHP ARC2::getRDFXMLSerializer怎么用?PHP ARC2::getRDFXMLSerializer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ARC2的用法示例。


在下文中一共展示了ARC2::getRDFXMLSerializer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _run_query

 function _run_query($query)
 {
     $response = $this->sparqlservice->graph($query);
     if ($response->is_success()) {
         require_once MORIARTY_ARC_DIR . '/ARC2.php';
         $parser = ARC2::getRDFParser();
         $parser->parse(false, $response->body);
         $changeset = $this->revert_changes($parser->getSimpleIndex(0));
         $ser = ARC2::getRDFXMLSerializer();
         $response->body = $ser->getSerializedIndex($changeset);
     }
     return $response;
 }
开发者ID:risis-eu,项目名称:RISIS_LinkedDataAPI,代码行数:13,代码来源:rollback.class.php

示例2: graph

 function graph($query)
 {
     require_once MORIARTY_ARC_DIR . '/ARC2.php';
     //$parser = ARC2::getRDFParser();
     $ser = ARC2::getRDFXMLSerializer();
     $body = false;
     $response = new HTTPResponse();
     //	if(stristr($query, 'DESCRIBE <#to_changeset>')){
     $r = new RollbackTest();
     $changes = $r->changes;
     $body = $ser->getSerializedIndex($changes);
     //	} else if(stristr($query, 'DESCRIBE ?cs ?statement')){
     // $r = new RollbackTest();
     // $changes  = $r->changes;
     // $body  = $ser->getSerializedIndex($changes);
     //	}
     $response->status_code = '200';
     $response->body = $body;
     return $response;
 }
开发者ID:risis-eu,项目名称:RISIS_LinkedDataAPI,代码行数:20,代码来源:rollback.test.php

示例3: triplesToRDFXML

 /**
  * Convert an ARC triples array into RDF/XML
  * @param array $triples
  * @return string $rdfxml
  */
 function triplesToRDFXML($triples)
 {
     $ser = ARC2::getRDFXMLSerializer();
     // TODO: Choose format depending on user choice
     // Serialize into RDF/XML, since it will contain
     // all URIs in un-abbreviated form, so that they
     // can easily be replaced by search-and-replace
     $rdfxml = $ser->getSerializedTriples($triples);
     if ($ser->getErrors()) {
         die("ARC Serializer Error: " . $ser->getErrors());
     }
     return $rdfxml;
 }
开发者ID:rdfio,项目名称:RDFIO,代码行数:18,代码来源:SpecialSPARQLEndpoint_body.php

示例4: sha1

$hash = sha1($ss . $ts);
$get = file_get_contents('http://www.slideshare.net/api/2/get_slideshow?' . '&slideshow_url=' . rawurlencode($url) . '&api_key=' . rawurlencode($api_key) . '&ts=' . rawurlencode($ts) . '&hash=' . rawurlencode($hash));
// Defns
$x = new SimpleXMLElement($get);
$type = 'avdoc';
$sl = array();
$sl[$url] = array();
$tags = array('id' => 'rdf:about', 'title' => 'dct:title', 'author' => array('name' => 'dct:creator'), 'summary' => 'bibo:abstract', 'link' => 'rdfs:seeAlso');
$types = array(0 => 'bibo:Article', 'bibo:AcademicArticle');
$ns = array('bibo' => 'http://purl.org/ontology/bibo/', 'dc' => 'http://purl.org/dc/elements/1.1/', 'dct' => 'http://purl.org/dc/terms/', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'foaf' => 'http://xmlns.com/foaf/0.1/');
// To add
$res = $x->xpath('/Slideshow/Title');
$sl[$url]['dct:title'] = (string) $res[0][0];
$label = (string) $res[0][0];
$res = $x->xpath('/Slideshow/ThumbnailURL');
$sl[$url]['foaf:img'] = (string) $res[0][0];
$res = $x->xpath('/Slideshow/Descripton');
$sl[$url]['dc:description'] = (string) $res[0][0];
$res = $x->xpath('/Slideshow/DownloadUrl');
$sl[$url]['rdfs:seeAlso'] = (string) $res[0][0];
$otherlinks = array();
$res = $x->xpath('/Slideshow/Username');
foreach ($res as $simpleobj) {
    $otherlinks[] = array('uri' => "bnode", 'rdf' => array(0 => array('pred' => "http://xmlns.com/foaf/0.1/name", 'obj' => (string) $simpleobj[0])), 'type' => 'person', 'rel' => 'http://purl.org/dc/terms/creator', 'inv' => false, 'shim' => "./shims/bnode.php");
}
include_once "../arc/ARC2.php";
$arcSerializerConf = array('ns' => $ns);
$serializer = ARC2::getRDFXMLSerializer($arcSerializerConf);
$si = $serializer->getSerializedIndex($sl);
$output = json_encode(array('label' => $label, 'uri' => $url, 'type' => $type, 'rdf' => array(0 => $si), 'sameas' => array(0 => $url), 'otherlinks' => $otherlinks));
echo $output;
开发者ID:RichardFish,项目名称:d-ROC,代码行数:31,代码来源:Slideshare.php

示例5: getRDF

 function getRDF($param = array())
 {
     /* { Comments
     		
     		$param format
     			array
     			(
     			'resources'	=> array ( 0 => 
     				array ( 
     					'type'	=> string ∈ taglistlist.keys ,
     					'uri'	=> string	
     					'rdf'	=> rdf to parse
     				)
     			)
     			'relations' => array ( 0 => 'Relation1', 'Relation2'... ) 
     																					
     			);
     			where uri = graphite_resource	
     		
     		}*/
     // Convinience
     $inputRes = $param['resources'];
     // Checks it's non-empty
     if (is_null($inputRes)) {
         die("No URI<br />");
     }
     // Creates Graphite
     $this->g = new Graphite($this->nsArr);
     // Adds RDFXML data to graphite
     foreach ($inputRes as $resource) {
         foreach ($resource['rdf'] as $rdfxml) {
             $this->g->addRDFXML("", $rdfxml);
         }
     }
     // Array that will be in an appropriate format for RDFXML serialization via ARC2
     $serializableList = array();
     // Array treated as a stack of all objects we are interested in.
     $tasks = array();
     // Populates the stack with all the entries fed into the script
     foreach ($inputRes as $inRes) {
         $tasks[] = array('uri' => $inRes['uri'], 'type' => $inRes['type']);
     }
     // Adds all special relations
     foreach ($param['relations'] as $relation) {
         // Adds each relation to the end result - they'll all be significant
         if (is_null($serializableList[$relation['sub']][$relation['pred']])) {
             $serializableList[$relation['sub']][$relation['pred']] = array();
         }
         $serializableList[$relation['sub']][$relation['pred']][] = $relation['obj'];
         // INFO: You have leveled up in skill: Associative arrays!
         // Adds each relationship to graphite, so it can reason over them
         $this->g->addTriple($relation['sub'], $relation['pred'], $relation['obj']);
     }
     // Runs 'till the stack is depleted
     while (($query = array_pop($tasks)) != NULL) {
         // query = current entry being worked on
         // 			$query = array_pop($tasks);
         // Loads the current query as a graphite resource
         $graphuri = $this->g->resource($query['uri']);
         // Loads 1 round of sameAs links
         $graphuri->loadSameAs();
         // Gets all relevant fields
         $ret = $this->getFields(array('uri' => $query['uri'], 'taglist' => $this->taglistlist[$query['type']]));
         //			print_r($ret);
         if (is_null($serializableList[$ret['uri']])) {
             $serializableList[$ret['uri']] = array();
         }
         $serializableList[$ret['uri']] = array_merge_recursive($serializableList[$ret['uri']], $ret['results']);
         //$serializableList = array_unique($serializableList, SORT_REGULAR);
         // Special handling based on type : eg adding all authors of a article to the stack
         switch ($query['type']) {
             case 'person':
                 break;
             case 'article':
                 // Now handled by the shims
                 //				foreach( $graphuri->all( "dct:creator" ) as $creator){
                 //					if (!is_null($creator->uri))
                 //						$tasks[] = array( 'type' => 'person', 'uri' => $creator->uri);
                 //				}
                 break;
             case 'avdoc':
                 break;
             case 'seminar':
                 break;
             case 'conference':
                 break;
             case 'default':
                 break;
         }
     }
     // Recursively calls array_unique on an hashtablearray
     $serializableList = $this->recursiveUnique($serializableList);
     // sets up the rdf serializer and serializes the RO just built.
     $arcSerializerConf = array('ns' => $this->nsArr);
     $serializer = ARC2::getRDFXMLSerializer($arcSerializerConf);
     $si = $serializer->getSerializedIndex($serializableList);
     // writes rdf to a file
     $file = "results.rdf";
     $fh = fopen($file, 'w+') or die("cant open file");
     fwrite($fh, $si);
//.........这里部分代码省略.........
开发者ID:RichardFish,项目名称:d-ROC,代码行数:101,代码来源:ROBuilder.php

示例6: getRdf

 /**
  * getRdf get the full BIBO RDF serialization of the collection of entries
  * @param $format the serialization format
  * @throws Exception if PHP_ZOTERO_ENTRIES_ARC_PATH is not defined
  */
 public function getRdf($format = 'rdf/xml')
 {
     if (!defined('PHP_ZOTERO_ENTRIES_ARC_PATH')) {
         throw new Exception('PHP_ZOTERO_ENTRIES_ARC_PATH must be defined and valid to use RDF methods');
     }
     require_once PHP_ZOTERO_ENTRIES_ARC_PATH;
     switch ($format) {
         case 'rdf/xml':
             $ser = ARC2::getRDFXMLSerializer($this->arcConf);
             break;
         case 'rdf/json':
             $ser = ARC2::getRDFJsonSerializer($this->arcConf);
             break;
         case 'turtle':
             $ser = ARC2::getTurtleSerializer($this->arcConf);
             break;
         case 'ntriples':
             $ser = ARC2::getNTriplesSerializer($this->arcConf);
             break;
     }
     return $ser->getSerializedIndex($this->getArcIndex());
 }
开发者ID:patrickmj,项目名称:ZItem,代码行数:27,代码来源:phpZoteroEntries.php

示例7: preg_replace

<?php

//TODO: Given time, attempt to scrape html with assumption that there is no RDF/other useful metadata
$uri = $_REQUEST['URI'];
$uri = preg_replace("/^(?!http:\\/\\/)/", "http://", $uri);
$name = "Generic Web Resource";
$type = "none";
$sl = array();
$sl[$uri] = array();
include_once "../arc/ARC2.php";
$serializer = ARC2::getRDFXMLSerializer();
$si = $serializer->getSerializedIndex($sl);
$output = json_encode(array('label' => $name, 'uri' => $uri, 'type' => $type, 'rdf' => array(0 => $si), 'sameas' => array(0 => $uri), 'otherlinks' => null));
echo $output;
开发者ID:RichardFish,项目名称:d-ROC,代码行数:14,代码来源:Generic+Resource.php

示例8: serializeRdf

 public static function serializeRdf($data, $extension = 'rdf')
 {
     global $conf;
     global $lodspk;
     $ser;
     $dPointer;
     $docs = Utils::travelTree($data);
     require_once $conf['home'] . 'lib/arc2/ARC2.php';
     $parser = ARC2::getRDFParser();
     $triples = array();
     foreach ($docs as $d) {
         $parser->parse($conf['basedir'], $d);
         $t = $parser->getTriples();
         $triples = array_merge($triples, $t);
     }
     if ($lodspk['mirror_external_uris']) {
         global $uri;
         global $localUri;
         $t = array();
         $t['s'] = $localUri;
         $t['s_type'] = 'uri';
         $t['p'] = "http://www.w3.org/2002/07/owl#sameAs";
         $t['o'] = $uri;
         $t['o_type'] = 'uri';
         array_push($triples, $t);
         $t['p'] = "http://www.w3.org/2000/10/swap/pim/contact#preferredURI";
         array_push($triples, $t);
     }
     switch ($extension) {
         case 'ttl':
             $ser = ARC2::getTurtleSerializer();
             break;
         case 'nt':
             $ser = ARC2::getNTriplesSerializer();
             break;
         case 'json':
             $ser = ARC2::getRDFJSONSerializer();
             break;
         case 'rdf':
             $ser = ARC2::getRDFXMLSerializer();
             break;
         case 'html':
             return array("content" => $triples, "serialized" => false);
             break;
         default:
             $ser = null;
     }
     if ($ser != null) {
         $doc = $ser->getSerializedTriples($triples);
     } else {
         $doc = var_export($data, true);
     }
     return array("content" => $doc, "serialized" => true);
 }
开发者ID:OpenDataServices,项目名称:lodspeakr,代码行数:54,代码来源:Utils.php

示例9: trim

    $resource->setProp('dcterms:title', trim($title));
    $meta = get_meta_data($contents);
    if (!empty($meta)) {
        $desc = '';
        foreach ($meta as $row) {
            if (empty($row[1])) {
                continue;
            }
            if ($row[1][0] == 'name' && $row[2][0] == 'description') {
                $desc = $row[3][0];
            }
        }
        if (empty($desc)) {
            //$desc = create_excerpt( strip_tags(getTextBetweenTags($contents, 'body')) );
        }
        $resource->setProp('dcterms:description', trim($desc));
    }
}
switch (strtolower($format)) {
    case 'xml':
        header("content-type: text/xml");
        $conf = array('ns' => $ns, 'serializer_prettyprint_container' => true);
        $ser = @ARC2::getRDFXMLSerializer($conf);
        $doc = @$ser->getSerializedIndex($resource->index);
        break;
    case 'json':
        $parser = @ARC2::getRDFParser();
        $doc = @$parser->toRDFJSON($resource->index);
        break;
}
echo $doc;
开发者ID:paulshannon,项目名称:scalar,代码行数:31,代码来源:html_to_rdf_proxy.php

示例10: actionSaveFile

 public function actionSaveFile($ids = null)
 {
     $ids = explode(',', urldecode(Yii::app()->request->getPost('ids')));
     if ($ids === null) {
         $ids = array();
         for ($i = 0; $i < 20; $i++) {
             $ids[] = rand(0, 80000);
         }
     }
     $nodes = Node::model()->in('id', $ids)->findAll();
     $triples = array();
     foreach ($nodes as $node) {
         $triples[trim($node->title)] = $node->toTriplet();
     }
     require Yii::getPathOfAlias('ext.arc.ARC2') . '.php';
     $ns = array('foaf' => 'http://xmlns.com/foaf/0.1/', 'dc' => 'http://purl.org/dc/elements/1.1/');
     $conf = array('ns' => $ns);
     $ser = ARC2::getRDFXMLSerializer($conf);
     $doc = $ser->getSerializedIndex($triples);
     header("Pragma: no-cache");
     // required
     header('Content-type: application/force-download');
     header('Content-Disposition: attachment; filename="result.rdf"');
     echo $doc;
 }
开发者ID:nizsheanez,项目名称:kur.ru,代码行数:25,代码来源:RunController.php

示例11: journo_emitRDFXML

function journo_emitRDFXML(&$j)
{
    global $_conf;
    $ser = ARC2::getRDFXMLSerializer($_conf);
    #    $triples = journo_asARC2Triples($j);
    #    $doc = $ser->getSerializedTriples($triples);
    $idx = journo_asARC2Index($j);
    $doc = $ser->getSerializedIndex($idx);
    print $doc;
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:10,代码来源:journo_rdf.php

示例12: getItemAsRdf

 /**
  * getItemAsRdf returns the BIBO RDF for the entire Zotero Item
  * @param $format default 'rdf/xml' the rdf serialization to use
  * @return string the RDF serialization
  * @throw Exception if PHP_ZOTERO_ENTRIES_ARC_PATH is not defined
  */
 public function getItemAsRdf($format = 'rdf/xml')
 {
     if (!defined('PHP_ZOTERO_ENTRIES_ARC_PATH')) {
         throw new Exception('PHP_ZOTERO_ENTRIES_ARC_PATH must be defined and valid to use RDF methods');
     }
     if (!$this->arcIndex) {
         $this->setRdf();
     }
     switch ($format) {
         case 'rdf/xml':
             $ser = ARC2::getRDFXMLSerializer($this->arcConf);
             break;
         case 'rdf/json':
             $ser = ARC2::getRDFJsonSerializer($this->arcConf);
             break;
         case 'turtle':
             $ser = ARC2::getTurtleSerializer($this->arcConf);
             break;
         case 'ntriples':
             $ser = ARC2::getNTriplesSerializer($this->arcConf);
             break;
     }
     return $ser->getSerializedIndex(array($this->itemUri => $this->arcIndex[$this->itemUri]));
 }
开发者ID:patrickmj,项目名称:ZItem,代码行数:30,代码来源:phpZoteroEntry.php

示例13: get_RDF

 public function get_RDF($print = false)
 {
     $config = array('ns' => $this->namespaces);
     $ser = ARC2::getRDFXMLSerializer($config);
     $result = $this->store->query($this->format_namespaces() . "SELECT ?s ?p ?o WHERE { ?s ?p ?o }");
     $rdf = $ser->getSerializedTriples($result["result"]["rows"]);
     if ($print) {
         header("Content-type: " . $ser->content_header);
         print $rdf;
     } else {
         return $rdf;
     }
 }
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:13,代码来源:onto_store_arc2.class.php

示例14: to_rdfxml

 /**
  * Serialise the graph to RDF/XML
  * @return string the RDF/XML version of the graph
  */
 public function to_rdfxml()
 {
     /** @var \ARC2_RDFSerializer $serializer */
     $serializer = \ARC2::getRDFXMLSerializer(array('ns' => $this->_labeller->get_ns()));
     return $serializer->getSerializedIndex($this->_to_arc_index($this->_index));
 }
开发者ID:talis,项目名称:tripod-php,代码行数:10,代码来源:ExtendedGraph.class.php

示例15: content_negociated_user_home

 /**
  * Outputs user's FOAF profile
  * @param unknown_type $params
  */
 function content_negociated_user_home(&$params)
 {
     $username = $params['username'];
     $accept = $params['accept'];
     if ($accept == 'application/rdf+xml') {
         $params['content_type'] = 'application/rdf+xml';
         $user_obj = user_get_object_by_name($username);
         $user_real_name = $user_obj->getRealName();
         $user_email = $user_obj->getEmail();
         $mbox = 'mailto:' . $user_email;
         $mbox_sha1sum = sha1($mbox);
         $projects = $user_obj->getGroups();
         sortProjectList($projects);
         $roles = RBACEngine::getInstance()->getAvailableRolesForUser($user_obj);
         sortRoleList($roles);
         // Construct an ARC2_Resource containing the project's RDF (DOAP) description
         $ns = array('rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'foaf' => 'http://xmlns.com/foaf/0.1/', 'sioc' => 'http://rdfs.org/sioc/ns#', 'doap' => 'http://usefulinc.com/ns/doap#', 'dcterms' => 'http://purl.org/dc/terms/', 'planetforge' => 'http://coclico-project.org/ontology/planetforge#');
         $conf = array('ns' => $ns);
         // First, let's deal with the account
         $account_res = ARC2::getResource($conf);
         $account_uri = util_make_url_u($username, $user_obj->getID());
         $account_uri = rtrim($account_uri, '/');
         $person_uri = $account_uri . '#person';
         $account_res->setURI($account_uri);
         // $account_res->setRel('rdf:type', 'foaf:OnlineAccount');
         rdfutils_setPropToUri($account_res, 'rdf:type', 'foaf:OnlineAccount');
         rdfutils_setPropToUri($account_res, 'foaf:accountServiceHomepage', $account_uri . '/');
         $account_res->setProp('foaf:accountName', $username);
         rdfutils_setPropToUri($account_res, 'sioc:account_of', $person_uri);
         rdfutils_setPropToUri($account_res, 'foaf:accountProfilePage', $account_uri);
         $groups_index = array();
         $projects_index = array();
         $roles_index = array();
         $usergroups_uris = array();
         // see if there were any groups
         if (count($projects) >= 1) {
             foreach ($projects as $p) {
                 // TODO : report also private projects if authenticated, for instance through OAuth
                 if ($p->isPublic()) {
                     $project_link = util_make_link_g($p->getUnixName(), $p->getID(), $p->getPublicName());
                     $project_uri = util_make_url_g($p->getUnixName(), $p->getID());
                     // sioc:UserGroups for all members of a project are named after /projects/A_PROJECT/members/
                     $usergroup_uri = $project_uri . 'members/';
                     $role_names = array();
                     $usergroups_uris[] = $usergroup_uri;
                     $usergroup_res = ARC2::getResource($conf);
                     $usergroup_res->setURI($usergroup_uri);
                     rdfutils_setPropToUri($usergroup_res, 'rdf:type', 'sioc:UserGroup');
                     rdfutils_setPropToUri($usergroup_res, 'sioc:usergroup_of', $project_uri);
                     $roles_uris = array();
                     foreach ($roles as $r) {
                         if ($r instanceof RoleExplicit && $r->getHomeProject() != NULL && $r->getHomeProject()->getID() == $p->getID()) {
                             $role_names[$r->getID()] = $r->getName();
                             $role_uri = $project_uri . 'roles/' . $r->getID();
                             $roles_uris[] = $role_uri;
                         }
                     }
                     rdfutils_setPropToUri($usergroup_res, 'planetforge:group_has_function', $roles_uris);
                     $project_res = ARC2::getResource($conf);
                     $project_res->setURI($project_uri);
                     rdfutils_setPropToUri($project_res, 'rdf:type', 'planetforge:ForgeProject');
                     $project_res->setProp('doap:name', $p->getUnixName());
                     $projects_index = ARC2::getMergedIndex($projects_index, $project_res->index);
                     foreach ($role_names as $id => $name) {
                         $role_res = ARC2::getResource($conf);
                         $role_res->setURI($project_uri . 'roles/' . $id);
                         rdfutils_setPropToUri($role_res, 'rdf:type', 'sioc:Role');
                         $role_res->setProp('sioc:name', $name);
                         $roles_index = ARC2::getMergedIndex($roles_index, $role_res->index);
                     }
                     $groups_index = ARC2::getMergedIndex($groups_index, $usergroup_res->index);
                 }
             }
         }
         // end if groups
         rdfutils_setPropToUri($account_res, 'sioc:member_of', $usergroups_uris);
         // next, deal with the person
         $person_res = ARC2::getResource($conf);
         $person_res->setURI($person_uri);
         rdfutils_setPropToUri($person_res, 'rdf:type', 'foaf:Person');
         $person_res->setProp('foaf:name', $user_real_name);
         rdfutils_setPropToUri($person_res, 'foaf:holdsAccount', $account_uri);
         $person_res->setProp('foaf:mbox_sha1sum', $mbox_sha1sum);
         // merge the two sets of triples
         $merged_index = ARC2::getMergedIndex($account_res->index, $person_res->index);
         $merged_index = ARC2::getMergedIndex($merged_index, $groups_index);
         $merged_index = ARC2::getMergedIndex($merged_index, $projects_index);
         $merged_index = ARC2::getMergedIndex($merged_index, $roles_index);
         $conf = array('ns' => $ns, 'serializer_type_nodes' => true);
         $ser = ARC2::getRDFXMLSerializer($conf);
         /* Serialize a resource index */
         $doc = $ser->getSerializedIndex($merged_index);
         $params['content'] = $doc . "\n";
     }
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:99,代码来源:foafprofilesPlugin.class.php


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