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


PHP EasyRdf_Graph::addLiteral方法代码示例

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


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

示例1: toFile

 public static function toFile($filePath, $triples)
 {
     $graph = new \EasyRdf_Graph();
     foreach ($triples as $triple) {
         if (!empty($triple->lg)) {
             $graph->addLiteral($triple->subject, $triple->predicate, $triple->object, $triple->lg);
         } elseif (\common_Utils::isUri($triple->object)) {
             $graph->add($triple->subject, $triple->predicate, $triple->object);
         } else {
             $graph->addLiteral($triple->subject, $triple->predicate, $triple->object);
         }
     }
     $format = \EasyRdf_Format::getFormat('rdfxml');
     return file_put_contents($filePath, $graph->serialise($format));
 }
开发者ID:nagyist,项目名称:generis,代码行数:15,代码来源:FileModel.php

示例2: statement2rdf

 /**
  * @ignore
  */
 private static function statement2rdf(PDOStatement $statement)
 {
     $graph = new EasyRdf_Graph();
     while ($r = $statement->fetch()) {
         if (isset($r['l_language']) && !empty($r['l_language'])) {
             $graph->addLiteral($r['subject'], $r['predicate'], $r['object'], $r['l_language']);
         } elseif (common_Utils::isUri($r['object'])) {
             $graph->add($r['subject'], $r['predicate'], $r['object']);
         } else {
             $graph->addLiteral($r['subject'], $r['predicate'], $r['object']);
         }
     }
     $format = EasyRdf_Format::getFormat('rdfxml');
     return $graph->serialise($format);
 }
开发者ID:nagyist,项目名称:generis,代码行数:18,代码来源:class.ModelExporter.php

示例3: outputRDF


//.........这里部分代码省略.........
             \EasyRdf_Namespace::set($prefix, $uri);
         }
     }
     //-------------
     // result block
     // ------------
     if ($symbol && strpos($symbol, 'http') === 0) {
         $graph_uri = $meta_uri = $graph->resource($symbol);
     } else {
         $graph_uri = $graph->newBNode();
     }
     $result_block = $graph->resource($graph_uri);
     //-------------
     // meta block
     // ------------
     $meta_uri = $this->app->request()->getURL() . $_SERVER['REQUEST_URI'];
     $meta_block = $graph->resource($meta_uri);
     // if this part is added, EasyRDF will merge the result block with the meta block
     // $meta_block->add('foaf:primaryTopic', $graph->resource( '_:' . $result_block->getBNodeId() ));
     $meta_block->set('dc:creator', 'sameAsLite');
     // TODO: maybe also add info about store (storename, URI)?
     if ($store) {
         $meta_block->set('dc:source', $graph->resource($storeurl));
     }
     // $meta_block->set('dc:title', 'Co-references from sameAs.org for ' . $symbol);
     if (isset($this->appOptions['license']['url'])) {
         $meta_block->add('dct:license', $graph->resource($this->appOptions['license']['url']));
     }
     // list
     if ($format === 'list') {
         // simple list
         foreach ($data as $str) {
             if (strpos($str, 'http') === 0) {
                 // resource
                 $result_block->add($predicate, $graph->resource(urldecode($str)));
             } else {
                 // literal values - not technically correct, because sameAs expects a resource
                 // but validates in W3C Validator
                 $result_block->add($predicate, $str);
             }
         }
     } elseif ($format === 'table') {
         // table output
         // data is in the form of:
         // [ [header1, header2, ...], [row1_1, row1_2, ...], [row2_1, row2_2, ...] ]
         $preds = array_shift($data);
         foreach ($data as $arr) {
             // if (isset($val['url'])) {
             //     $url = $val['url'];
             //     unset($val['url']);
             // } else {
             //     $url = $graph_uri;
             // }
             $resources = array();
             for ($i = 0, $s = count($arr); $i < $s; $i++) {
                 $resources[$i] = $graph->resource($storeurl);
                 // TODO
                 for ($k = 0, $t = count($preds); $k < $t; $k++) {
                     if (strpos($arr[$i], 'http') === 0) {
                         // resource
                         $graph->addResource($resources[$i], $preds[$k], $graph->resource(urldecode($arr[$i])));
                     } else {
                         // literal
                         $graph->addLiteral($resources[$i], $preds[$k], urldecode($arr[$i]));
                     }
                 }
             }
         }
     } else {
         // keyed = 'arbitrary' output format (e.g. for analysis)
         // Accepts data in the form of:
         // [ [ $key1 => $value1 ], [ $key2 => $value2 ], [...] ]
         // Will take key as predicate and
         // value as resource (if url) or literal
         $resource = $graph->resource($storeurl);
         foreach ($data as $key => $value) {
             if (strpos($value, 'http') === 0) {
                 // resource
                 $graph->addResource($resource, $key, $graph->resource(urldecode($value)));
             } else {
                 // literal
                 $graph->addLiteral($resource, $key, $value);
             }
         }
     }
     // ------
     // output
     // ------
     if ($this->mimeBest === 'application/rdf+xml') {
         $outFormat = 'rdf';
     } else {
         $outFormat = 'turtle';
     }
     $data = $graph->serialise($outFormat);
     if (!is_scalar($data)) {
         $data = var_export($data, true);
     }
     $this->app->response->setBody($data);
     $this->app->stop();
 }
开发者ID:joetm,项目名称:sameAs-Lite,代码行数:101,代码来源:WebApp.php

示例4: addMetaTriples

 /**
  * Add void and hydra meta-data to an existing graph
  *
  * @param EasyRdf_Graph $graph    The graph to which meta data has to be added
  * @param integer       $count    The total amount of triples that match the URI
  *
  * @return EasyRdf_Graph $graph
  */
 public function addMetaTriples($graph, $limit, $offset, $count)
 {
     // Add the void and hydra namespace to the EasyRdf framework
     \EasyRdf_Namespace::set('hydra', 'http://www.w3.org/ns/hydra/core#');
     \EasyRdf_Namespace::set('void', 'http://rdfs.org/ns/void#');
     \EasyRdf_Namespace::set('dcterms', 'http://purl.org/dc/terms/');
     // Add the meta data semantics to the graph
     $root = \Request::root();
     $root .= '/';
     $base_uri = $root . 'all';
     $identifier = str_replace($root, '', $base_uri);
     $graph->addResource($base_uri . '#dataset', 'a', 'void:Dataset');
     $graph->addResource($base_uri . '#dataset', 'a', 'hydra:Collection');
     $resource = $graph->resource($base_uri);
     $subject_temp_mapping = $graph->newBNode();
     $subject_temp_mapping->addResource('a', 'hydra:IriTemplateMapping');
     $subject_temp_mapping->addLiteral('hydra:variable', 'subject');
     $subject_temp_mapping->addResource('hydra:property', 'rdf:subject');
     $predicate_temp_mapping = $graph->newBNode();
     $predicate_temp_mapping->addResource('a', 'hydra:IriTemplateMapping');
     $predicate_temp_mapping->addLiteral('hydra:variable', 'predicate');
     $predicate_temp_mapping->addResource('hydra:property', 'rdf:predicate');
     $object_temp_mapping = $graph->newBNode();
     $object_temp_mapping->addResource('a', 'hydra:IriTemplateMapping');
     $object_temp_mapping->addLiteral('hydra:variable', 'object');
     $object_temp_mapping->addResource('hydra:property', 'rdf:object');
     $iri_template = $graph->newBNode();
     $iri_template->addResource('a', 'hydra:IriTemplate');
     $iri_template->addLiteral('hydra:template', $root . 'all' . '{?subject,predicate,object}');
     $iri_template->addResource('hydra:mapping', $subject_temp_mapping);
     $iri_template->addResource('hydra:mapping', $predicate_temp_mapping);
     $iri_template->addResource('hydra:mapping', $object_temp_mapping);
     // Add the template to the requested URI resource in the graph
     $graph->addResource($base_uri . '#dataset', 'hydra:search', $iri_template);
     $is_deferenced = false;
     if (strtolower(\Request::segment(1)) != 'all') {
         $full_url = \Request::root() . '/' . \Request::path();
         $is_deferenced = true;
     } else {
         $full_url = $base_uri . '?';
     }
     $template_url = $full_url;
     $templates = array('subject', 'predicate', 'object');
     $has_param = false;
     $query_string = $_SERVER['QUERY_STRING'];
     $query_parts = explode('&', $query_string);
     foreach ($query_parts as $part) {
         if (!empty($part)) {
             $couple = explode('=', $part);
             if (strtolower($couple[0]) == 'subject') {
                 $template_url .= $couple[0] . '=' . $couple[1] . '&';
                 $has_param = true;
             }
             if (strtolower($couple[0]) == 'predicate') {
                 $template_url .= $couple[0] . '=' . $couple[1] . '&';
                 $has_param = true;
             }
             if (strtolower($couple[0]) == 'object') {
                 $template_url .= $couple[0] . '=' . $couple[1] . '&';
                 $has_param = true;
             }
             $full_url .= $couple[0] . '=' . $couple[1] . '&';
         }
     }
     $full_url = rtrim($full_url, '?');
     $full_url = rtrim($full_url, '&');
     $template_url = rtrim($template_url, '?');
     $template_url = rtrim($template_url, '&');
     $full_url = str_replace('#', '%23', $full_url);
     $template_url = str_replace('#', '%23', $template_url);
     if ($is_deferenced) {
         $full_url .= '#dataset';
     }
     // Add paging information
     $graph->addLiteral($full_url, 'hydra:totalItems', \EasyRdf_Literal::create($count, null, 'xsd:integer'));
     $graph->addLiteral($full_url, 'void:triples', \EasyRdf_Literal::create($count, null, 'xsd:integer'));
     $graph->addLiteral($full_url, 'hydra:itemsPerPage', \EasyRdf_Literal::create($limit, null, 'xsd:integer'));
     $graph->addResource($full_url, 'void:subset', \Request::root() . '/all#dataset');
     $paging_info = $this->getPagingInfo($limit, $offset, $count);
     foreach ($paging_info as $key => $info) {
         switch ($key) {
             case 'next':
                 if ($has_param) {
                     $glue = '&';
                 } else {
                     $glue = '?';
                 }
                 $graph->addResource($full_url, 'hydra:nextPage', $template_url . $glue . 'limit=' . $info['limit'] . '&offset=' . $info['offset']);
                 break;
             case 'previous':
                 if ($has_param) {
                     $glue = '&';
//.........这里部分代码省略.........
开发者ID:tdt,项目名称:triples,代码行数:101,代码来源:TripleRepository.php

示例5:

<?php 
if (isset($_REQUEST['uri'])) {
    $graph = new EasyRdf_Graph();
    # 1st Technique
    $me = $graph->resource($_REQUEST['uri'], 'foaf:Person');
    $me->set('foaf:name', $_REQUEST['title'] . ' ' . $_REQUEST['given_name'] . ' ' . $_REQUEST['family_name']);
    if ($_REQUEST['email']) {
        $email = $graph->resource("mailto:" . $_REQUEST['email']);
        $me->add('foaf:mbox', $email);
    }
    if ($_REQUEST['homepage']) {
        $homepage = $graph->resource($_REQUEST['homepage']);
        $me->add('foaf:homepage', $homepage);
    }
    # 2nd Technique
    $graph->addLiteral($_REQUEST['uri'], 'foaf:title', $_REQUEST['title']);
    $graph->addLiteral($_REQUEST['uri'], 'foaf:givenname', $_REQUEST['given_name']);
    $graph->addLiteral($_REQUEST['uri'], 'foaf:family_name', $_REQUEST['family_name']);
    $graph->addLiteral($_REQUEST['uri'], 'foaf:nick', $_REQUEST['nickname']);
    # Add friends
    for ($i = 1; $i <= 4; $i++) {
        if ($_REQUEST["person_{$i}"]) {
            $person = $graph->resource($_REQUEST["person_{$i}"]);
            $graph->add($me, 'foaf:knows', $person);
        }
    }
    # Finally output the graph
    $data = $graph->serialise($_REQUEST['format']);
    if (!is_scalar($data)) {
        $data = var_export($data, true);
    }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:foafmaker.php

示例6: getDcatDocument

 /**
  * Return a DCAT document based on the definitions that are passed
  *
  * @param array Array with definition configurations
  *
  * @return \EasyRdf_Graph
  */
 public function getDcatDocument(array $definitions, $oldest_definition)
 {
     // Create a new EasyRDF graph
     $graph = new \EasyRdf_Graph();
     \EasyRdf_Namespace::set('adms', 'http://www.w3.org/ns/adms#');
     $all_settings = $this->settings->getAll();
     $uri = \Request::root();
     // Add the catalog and a title
     $graph->addResource($uri . '/api/dcat', 'a', 'dcat:Catalog');
     $graph->addLiteral($uri . '/api/dcat', 'dct:title', $all_settings['catalog_title']);
     // Fetch the catalog description, issued date and language
     $graph->addLiteral($uri . '/api/dcat', 'dct:description', $all_settings['catalog_description']);
     $graph->addLiteral($uri . '/api/dcat', 'dct:issued', $this->getIssuedDate());
     $lang = $this->languages->getByCode($all_settings['catalog_language']);
     if (!empty($lang)) {
         $graph->addResource($uri . '/api/dcat', 'dct:language', 'http://lexvo.org/id/iso639-3/' . $lang['lang_id']);
         $graph->addResource('http://lexvo.org/id/iso639-3/' . $lang['lang_id'], 'a', 'dct:LinguisticSystem');
     }
     // Fetch the homepage and rights
     $graph->addResource($uri . '/api/dcat', 'foaf:homepage', $uri);
     $graph->addResource($uri . '/api/dcat', 'dct:license', 'http://www.opendefinition.org/licenses/cc-zero');
     $graph->addResource('http://www.opendefinition.org/licenses/cc-zero', 'a', 'dct:LicenseDocument');
     // Add the publisher resource to the catalog
     $graph->addResource($uri . '/api/dcat', 'dct:publisher', $all_settings['catalog_publisher_uri']);
     $graph->addResource($all_settings['catalog_publisher_uri'], 'a', 'foaf:Agent');
     $graph->addLiteral($all_settings['catalog_publisher_uri'], 'foaf:name', $all_settings['catalog_publisher_name']);
     if (count($definitions) > 0) {
         // Add the last modified timestamp in ISO8601
         $graph->addLiteral($uri . '/api/dcat', 'dct:modified', date(\DateTime::ISO8601, strtotime($oldest_definition['updated_at'])));
         foreach ($definitions as $definition) {
             // Create the dataset uri
             $dataset_uri = $uri . "/" . $definition['collection_uri'] . "/" . $definition['resource_name'];
             $dataset_uri = str_replace(' ', '%20', $dataset_uri);
             $source_type = $definition['type'];
             // Add the dataset link to the catalog
             $graph->addResource($uri . '/api/dcat', 'dcat:dataset', $dataset_uri);
             // Add the dataset resource and its description
             $graph->addResource($dataset_uri, 'a', 'dcat:Dataset');
             $title = null;
             if (!empty($definition['title'])) {
                 $title = $definition['title'];
             } else {
                 $title = $definition['collection_uri'] . '/' . $definition['resource_name'];
             }
             $graph->addLiteral($dataset_uri, 'dct:title', $title);
             // Add the description, identifier, issued date, modified date, contact point and landing page of the dataset
             $graph->addLiteral($dataset_uri, 'dct:description', @$definition['description']);
             $graph->addLiteral($dataset_uri, 'dct:identifier', str_replace(' ', '%20', $definition['collection_uri'] . '/' . $definition['resource_name']));
             $graph->addLiteral($dataset_uri, 'dct:issued', date(\DateTime::ISO8601, strtotime($definition['created_at'])));
             $graph->addLiteral($dataset_uri, 'dct:modified', date(\DateTime::ISO8601, strtotime($definition['updated_at'])));
             $graph->addResource($dataset_uri, 'dcat:landingPage', $dataset_uri);
             // Backwards compatibility
             if (!empty($definition['contact_point'])) {
                 $graph->addResource($dataset_uri, 'adms:contactPoint', $definition['contact_point']);
             }
             // Add the publisher resource to the dataset
             if (!empty($definition['publisher_name']) && !empty($definition['publisher_uri'])) {
                 $graph->addResource($dataset_uri, 'dct:publisher', $definition['publisher_uri']);
                 $graph->addResource($definition['publisher_uri'], 'a', 'foaf:Agent');
                 $graph->addLiteral($definition['publisher_uri'], 'foaf:name', $definition['publisher_name']);
             }
             // Add the keywords to the dataset
             if (!empty($definition['keywords'])) {
                 foreach (explode(',', $definition['keywords']) as $keyword) {
                     $keyword = trim($keyword);
                     $graph->addLiteral($dataset_uri, 'dcat:keyword', $keyword);
                 }
             }
             // Add the source resource if it's a URI
             if (strpos($definition['source'], 'http://') !== false || strpos($definition['source'], 'https://')) {
                 $graph->addResource($dataset_uri, 'dct:source', str_replace(' ', '%20', $definition['source']));
             }
             // Optional dct terms
             $optional = array('date', 'language', 'theme');
             foreach ($optional as $dc_term) {
                 if (!empty($definition[$dc_term])) {
                     if ($dc_term == 'language') {
                         $lang = $this->languages->getByName($definition[$dc_term]);
                         if (!empty($lang)) {
                             $graph->addResource($dataset_uri, 'dct:' . $dc_term, 'http://lexvo.org/id/iso639-3/' . $lang['lang_id']);
                             $graph->addResource('http://lexvo.org/id/iso639-3/' . $lang['lang_id'], 'a', 'dct:LinguisticSystem');
                         }
                     } elseif ($dc_term == 'theme') {
                         $theme = $this->themes->getByLabel($definition[$dc_term]);
                         if (!empty($theme)) {
                             $graph->addResource($dataset_uri, 'dcat:' . $dc_term, $theme['uri']);
                             $graph->addLiteral($theme['uri'], 'rdfs:label', $theme['label']);
                         }
                     } else {
                         $graph->addLiteral($dataset_uri, 'dct:' . $dc_term, $definition[$dc_term]);
                     }
                 }
             }
//.........这里部分代码省略.........
开发者ID:jalbertbowden,项目名称:core,代码行数:101,代码来源:DcatRepository.php

示例7: addResource

 /**
  * Add a resource to the graph
  * 
  * @param EasyRdf_Graph $graph
  * @param core_kernel_classes_Resource $resource
  * @ignore
  */
 private function addResource(EasyRdf_Graph $graph, core_kernel_classes_Resource $resource)
 {
     foreach ($resource->getRdfTriples() as $triple) {
         if (!empty($triple->lg)) {
             $graph->addLiteral($triple->subject, $triple->predicate, $triple->object, $triple->lg);
         } elseif (common_Utils::isUri($triple->object)) {
             $graph->add($triple->subject, $triple->predicate, $triple->object);
         } else {
             $graph->addLiteral($triple->subject, $triple->predicate, $triple->object);
         }
     }
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:19,代码来源:class.GenerisAdapterRdf.php

示例8: getBody

 public static function getBody($dataObj)
 {
     // Query parameters
     $query_string = '';
     if (!empty($_GET)) {
         $query_string = '?' . http_build_query(\Input::all());
     }
     // Links to pages
     $prev_link = '';
     $next_link = '';
     if (!empty($dataObj->paging)) {
         $input_array = array_except(\Input::all(), array('limit', 'offset'));
         $query_string = '';
         if (!empty($input_array)) {
             $query_string = '&' . http_build_query($input_array);
         }
         if (!empty($dataObj->paging['previous'])) {
             $prev_link = '?offset=' . $dataObj->paging['previous'][0] . '&limit=' . $dataObj->paging['previous'][1] . $query_string;
         }
         if (!empty($dataObj->paging['next'])) {
             $next_link = '?offset=' . $dataObj->paging['next'][0] . '&limit=' . $dataObj->paging['next'][1] . $query_string;
         }
     }
     // Create the link to the dataset
     $dataset_link = \URL::to($dataObj->definition['collection_uri'] . "/" . $dataObj->definition['resource_name']);
     // Append rest parameters
     if (!empty($dataObj->rest_parameters)) {
         $dataset_link .= '/' . implode('/', $dataObj->rest_parameters);
     }
     if (!empty($dataObj->source_definition)) {
         $type = $dataObj->source_definition['type'];
         // Check if other views need to be served
         switch ($type) {
             case 'XLS':
             case 'CSV':
                 $first_row = array_shift($dataObj->data);
                 array_unshift($dataObj->data, $first_row);
                 if (is_array($first_row) || is_object($first_row)) {
                     $view = 'dataset.tabular';
                     $data = $dataObj->data;
                 } else {
                     $view = 'dataset.code';
                     $data = self::displayTree($dataObj->data);
                 }
                 break;
             case 'SHP':
                 $view = 'dataset.map';
                 $data = $dataset_link . '.map' . $query_string;
                 break;
             case 'XML':
                 $view = 'dataset.code';
                 $data = self::displayTree($dataObj->data, 'xml');
                 break;
             default:
                 if ($dataObj->is_semantic) {
                     // This data object is always semantic
                     $view = 'dataset.turtle';
                     // Check if a configuration is given
                     $conf = array();
                     if (!empty($dataObj->semantic->conf)) {
                         $conf = $dataObj->semantic->conf;
                     }
                     $data = $dataObj->data->serialise('turtle');
                 } else {
                     $view = 'dataset.code';
                     $data = self::displayTree($dataObj->data);
                 }
                 break;
         }
     } elseif ($dataObj->is_semantic) {
         // The data object can be semantic without a specified source type
         $view = 'dataset.code';
         $data = $dataObj->data->serialise('turtle');
     } else {
         // Collection view
         $view = 'dataset.collection';
         $data = $dataObj->data;
     }
     // Gather meta-data to inject as a JSON-LD document so it can be picked up by search engines
     $definition = $dataObj->definition;
     $uri = \Request::root();
     $graph = new \EasyRdf_Graph();
     // Create the dataset uri
     $dataset_uri = $uri . "/" . $definition['collection_uri'] . "/" . $definition['resource_name'];
     $dataset_uri = str_replace(' ', '%20', $dataset_uri);
     // Add the dataset resource and its description
     $graph->addResource($dataset_uri, 'a', 'schema:Dataset');
     // Add the title to the dataset resource of the catalog
     if (!empty($definition['title'])) {
         $graph->addLiteral($dataset_uri, 'schema:headline', $definition['title']);
     }
     // Add the description, identifier, issues, modified of the dataset
     $graph->addLiteral($dataset_uri, 'schema:description', @$definition['description']);
     $graph->addLiteral($dataset_uri, 'schema:dateCreated', date(\DateTime::ISO8601, strtotime($definition['created_at'])));
     $graph->addLiteral($dataset_uri, 'schema:dateModified', date(\DateTime::ISO8601, strtotime($definition['updated_at'])));
     // Add the publisher resource to the dataset
     if (!empty($definition['publisher_name']) && !empty($definition['publisher_uri'])) {
         $graph->addResource($dataset_uri, 'schema:publisher', $definition['publisher_uri']);
     }
     // Optional dct terms
//.........这里部分代码省略.........
开发者ID:jalbertbowden,项目名称:core,代码行数:101,代码来源:HTMLFormatter.php

示例9: testSerialiseReferenceAlreadyOutput

 /**
  * testSerialiseReferenceAlreadyOutput
  *
  * Test referencing a resource with a single property that
  * has already been output.
  */
 function testSerialiseReferenceAlreadyOutput()
 {
     $graph = new EasyRdf_Graph();
     $graph->addLiteral('http://example.com/2', 'rdf:label', 'label');
     $graph->addResource('http://example.com/1', 'foaf:homepage', 'http://example.com/2');
     $this->assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" . "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" . "         xmlns:foaf=\"http://xmlns.com/foaf/0.1/\">\n\n" . "  <rdf:Description rdf:about=\"http://example.com/2\">\n" . "    <rdf:label>label</rdf:label>\n" . "  </rdf:Description>\n\n" . "  <rdf:Description rdf:about=\"http://example.com/1\">\n" . "    <foaf:homepage rdf:resource=\"http://example.com/2\"/>\n" . "  </rdf:Description>\n\n" . "</rdf:RDF>\n", $this->_serialiser->serialise($graph, 'rdfxml'));
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:13,代码来源:RdfXmlTest.php

示例10:

 * @copyright  Copyright (c) 2009-2013 Nicholas J Humfrey
 * @license    http://unlicense.org/
 */
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "EasyRdf.php";
?>
<html>
<head>
  <title>Example of using EasyRdf_Graph directly</title>
</head>
<body>

<?php 
$graph = new EasyRdf_Graph();
$graph->addResource("http://example.com/joe", "rdf:type", "foaf:Person");
$graph->addLiteral("http://example.com/joe", "foaf:name", "Joe Bloggs");
$graph->addLiteral("http://example.com/joe", "foaf:name", "Joseph Bloggs");
$graph->add("http://example.com/joe", "rdfs:label", "Joe");
$graph->setType("http://njh.me/", "foaf:Person");
$graph->add("http://njh.me/", "rdfs:label", "Nick");
$graph->addLiteral("http://njh.me/", "foaf:name", "Nicholas Humfrey");
$graph->addResource("http://njh.me/", "foaf:homepage", "http://www.aelius.com/njh/");
?>

<p>
  <b>Name:</b> <?php 
echo $graph->get("http://example.com/joe", "foaf:name");
?>
 <br />
  <b>Names:</b> <?php 
echo $graph->join("http://example.com/joe", "foaf:name");
开发者ID:gitter-badger,项目名称:mexproject,代码行数:31,代码来源:graph_direct.php


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