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


PHP EasyRdf_Namespace::get方法代码示例

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


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

示例1: testGetEmptyNamespace

 public function testGetEmptyNamespace()
 {
     EasyRdf_Namespace::set('', 'http://xmlns.com/foaf/0.1/name');
     $url = EasyRdf_Namespace::get('');
     $this->assertSame('http://xmlns.com/foaf/0.1/name', $url);
 }
开发者ID:takin,项目名称:workshop-semantic-web,代码行数:6,代码来源:NamespaceTest.php

示例2: expandCurie

 protected function expandCurie($node, &$context, $value)
 {
     if (preg_match("/^(\\w*?):(.*)\$/", $value, $matches)) {
         list(, $prefix, $local) = $matches;
         $prefix = strtolower($prefix);
         if ($prefix === '_') {
             // It is a bnode
             return $this->remapBnode(substr($value, 2));
         } elseif (empty($prefix) and $context['vocab']) {
             // Empty prefix
             return $context['vocab'] . $local;
         } elseif (isset($context['prefixes'][$prefix])) {
             return $context['prefixes'][$prefix] . $local;
         } elseif ($uri = $node->lookupNamespaceURI($prefix)) {
             return $uri . $local;
         } elseif (!empty($prefix) and $uri = EasyRdf_Namespace::get($prefix)) {
             // Expand using well-known prefixes
             return $uri . $local;
         }
     }
 }
开发者ID:ASDAFF,项目名称:myprofile,代码行数:21,代码来源:Rdfa.php

示例3: parseQNameOrBoolean

 /**
  * Parses qnames and boolean values, which have equivalent starting
  * characters.
  * @ignore
  */
 protected function parseQNameOrBoolean()
 {
     // First character should be a ':' or a letter
     $c = $this->read();
     if ($c == -1) {
         throw new EasyRdf_Exception("Turtle Parse Error: unexpected end of file while readying value");
     }
     if ($c != ':' && !self::isPrefixStartChar($c)) {
         throw new EasyRdf_Exception("Turtle Parse Error: expected a ':' or a letter, found '{$c}'");
     }
     $namespace = NULL;
     if ($c == ':') {
         // qname using default namespace
         $namespace = $this->_namespaces[""];
         if ($namespace == NULL) {
             throw new EasyRdf_Exception("Turtle Parse Error: default namespace used but not defined");
         }
     } else {
         // $c is the first letter of the prefix
         $prefix = $c;
         $c = $this->read();
         while (self::isPrefixChar($c)) {
             $prefix .= $c;
             $c = $this->read();
         }
         if ($c != ':') {
             // prefix may actually be a boolean value
             $value = $prefix;
             if ($value == "true" || $value == "false") {
                 return array('type' => 'literal', 'value' => $value, 'datatype' => EasyRdf_Namespace::get('xsd') . 'boolean');
             }
         }
         $this->verifyCharacter($c, ":");
         if (isset($this->_namespaces[$prefix])) {
             $namespace = $this->_namespaces[$prefix];
         } else {
             throw new EasyRdf_Exception("Turtle Parse Error: namespace prefix '{$prefix}' used but not defined");
         }
     }
     // $c == ':', read optional local name
     $localName = '';
     $c = $this->read();
     if (self::isNameStartChar($c)) {
         $localName .= $c;
         $c = $this->read();
         while (self::isNameChar($c)) {
             $localName .= $c;
             $c = $this->read();
         }
     }
     // Unread last character
     $this->unread($c);
     // Note: namespace has already been resolved
     return array('type' => 'uri', 'value' => $namespace . $localName);
 }
开发者ID:ASDAFF,项目名称:myprofile,代码行数:60,代码来源:Turtle.php

示例4: serialisePrefixes

 /**
  * @ignore
  */
 protected function serialisePrefixes()
 {
     $turtle = '';
     foreach ($this->_prefixes as $prefix => $count) {
         $url = EasyRdf_Namespace::get($prefix);
         $turtle .= "@prefix {$prefix}: <{$url}> .\n";
     }
     return $turtle;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:Turtle.php

示例5: getVocabularies

 /**
  * Returns the cached vocabularies.
  * @return array of Vocabulary dataobjects
  */
 public function getVocabularies()
 {
     if ($this->all_vocabularies === null) {
         // initialize cache
         $vocs = $this->graph->allOfType('skosmos:Vocabulary');
         $this->all_vocabularies = $this->createDataObjects("Vocabulary", $vocs);
         foreach ($this->all_vocabularies as $voc) {
             // register vocabulary ids as RDF namespace prefixes
             $prefix = preg_replace('/\\W+/', '', $voc->getId());
             // strip non-word characters
             try {
                 if ($prefix != '' && EasyRdf_Namespace::get($prefix) === null) {
                     EasyRdf_Namespace::set($prefix, $voc->getUriSpace());
                 }
             } catch (Exception $e) {
                 // not valid as namespace identifier, ignore
             }
         }
     }
     return $this->all_vocabularies;
 }
开发者ID:jneubert,项目名称:Skosmos,代码行数:25,代码来源:Model.php

示例6: testDeleteNamespace

 public function testDeleteNamespace()
 {
     EasyRdf_Namespace::set('po', 'http://purl.org/ontology/po/');
     $this->assertNotNull(EasyRdf_Namespace::get('po'));
     EasyRdf_Namespace::delete('po');
     $this->assertNull(EasyRdf_Namespace::get('po'));
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:7,代码来源:NamespaceTest.php

示例7: serialise

 /**
  * Method to serialise an EasyRdf_Graph to RDF/XML
  *
  * @param object EasyRdf_Graph $graph   An EasyRdf_Graph object.
  * @param string  $format               The name of the format to convert to.
  * @return string                       The RDF in the new desired format.
  */
 public function serialise($graph, $format)
 {
     parent::checkSerialiseParams($graph, $format);
     if ($format != 'rdfxml') {
         throw new EasyRdf_Exception("EasyRdf_Serialiser_RdfXml does not support: {$format}");
     }
     // store of namespaces to be appended to the rdf:RDF tag
     $this->_prefixes = array('rdf' => true);
     // store of the resource URIs we have serialised
     $this->_outputtedResources = array();
     $xml = '';
     foreach ($graph->resources() as $resource) {
         $xml .= $this->rdfxmlResource($resource, true, 1);
     }
     // iterate through namepsaces array prefix and output a string.
     $namespaceStr = '';
     foreach ($this->_prefixes as $prefix => $count) {
         $url = EasyRdf_Namespace::get($prefix);
         if (strlen($namespaceStr)) {
             $namespaceStr .= "\n        ";
         }
         $namespaceStr .= ' xmlns:' . $prefix . '="' . htmlspecialchars($url) . '"';
     }
     return "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" . "<rdf:RDF" . $namespaceStr . ">\n" . $xml . "\n</rdf:RDF>\n";
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:32,代码来源:RdfXml.php

示例8: serialise

 /**
  * Method to serialise an EasyRdf_Graph to RDF/XML
  *
  * @param string  $graph   An EasyRdf_Graph object.
  * @param string  $format  The name of the format to convert to.
  * @return string          The RDF in the new desired format.
  */
 public function serialise($graph, $format)
 {
     parent::checkSerialiseParams($graph, $format);
     if ($format != 'rdfxml') {
         throw new EasyRdf_Exception("EasyRdf_Serialiser_RdfXml does not support: {$format}");
     }
     // store of namespaces to be appended to the rdf:RDF tag
     $this->_prefixes = array('rdf' => true);
     $xml = '';
     foreach ($graph->resources() as $resource) {
         $properties = $resource->propertyUris();
         if (count($properties) == 0) {
             continue;
         }
         $xml .= "\n  " . $this->rdfxmlResource($resource) . "\n";
         foreach ($properties as $property) {
             $short = EasyRdf_Namespace::shorten($property, true);
             if ($short) {
                 $this->addPrefix($short);
                 $objects = $resource->all($property);
                 foreach ($objects as $object) {
                     $xml .= $this->rdfxmlObject($short, $object);
                 }
             } else {
                 throw new EasyRdf_Exception("It is not possible to serialse the property " . "'{$property}' to RDF/XML.");
             }
         }
         $xml .= "  </rdf:Description>\n";
     }
     // iterate through namepsaces array prefix and output a string.
     $namespaceStr = '';
     foreach ($this->_prefixes as $prefix => $count) {
         $url = EasyRdf_Namespace::get($prefix);
         if (strlen($namespaceStr)) {
             $namespaceStr .= "\n        ";
         }
         $namespaceStr .= ' xmlns:' . $prefix . '="' . htmlspecialchars($url) . '"';
     }
     return "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" . "<rdf:RDF" . $namespaceStr . ">\n" . $xml . "\n</rdf:RDF>\n";
 }
开发者ID:nhukhanhdl,项目名称:easyrdf,代码行数:47,代码来源:RdfXml.php


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