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


PHP EasyRdf_Namespace::expand方法代码示例

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


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

示例1: __construct

 /** Constructor
  *
  */
 public function __construct($value, $lang = null, $datatype = null)
 {
     if (EasyRdf_Utils::is_associative_array($value)) {
         $this->_value = isset($value['value']) ? $value['value'] : null;
         $this->_lang = isset($value['lang']) ? $value['lang'] : null;
         $this->_datatype = isset($value['datatype']) ? $value['datatype'] : null;
     } else {
         $this->_value = $value;
         $this->_lang = $lang ? $lang : null;
         $this->_datatype = $datatype ? $datatype : null;
     }
     // Automatic datatype selection
     if ($this->_datatype == null) {
         if (is_float($this->_value)) {
             $this->_datatype = 'xsd:decimal';
         } else {
             if (is_int($this->_value)) {
                 $this->_datatype = 'xsd:integer';
             } else {
                 if (is_bool($this->_value)) {
                     $this->_datatype = 'xsd:boolean';
                 }
             }
         }
     }
     // Expand shortened URIs (qnames)
     if ($this->_datatype) {
         $this->_datatype = EasyRdf_Namespace::expand($this->_datatype);
     }
 }
开发者ID:nhukhanhdl,项目名称:easyrdf,代码行数:33,代码来源:Literal.php

示例2: generateList

 protected function generateList($subject, $property, $list)
 {
     $current = $subject;
     $prop = $property;
     // Output a blank node for each item in the list
     foreach ($list as $item) {
         $newNode = $this->_graph->newBNodeId();
         $this->addTriple($current, $prop, array('type' => 'bnode', 'value' => $newNode));
         $this->addTriple($newNode, 'rdf:first', $item);
         $current = $newNode;
         $prop = 'rdf:rest';
     }
     // Finally, terminate the list
     $this->addTriple($current, $prop, array('type' => 'uri', 'value' => EasyRdf_Namespace::expand('rdf:nil')));
 }
开发者ID:ASDAFF,项目名称:myprofile,代码行数:15,代码来源:Rdfa.php

示例3: testExpandNonString

 public function testExpandNonString()
 {
     $this->setExpectedException('InvalidArgumentException', '$shortUri should be a string and cannot be null or empty');
     EasyRdf_Namespace::expand($this);
 }
开发者ID:takin,项目名称:workshop-semantic-web,代码行数:5,代码来源:NamespaceTest.php

示例4: allOfType

 /** Get all the resources in the graph of a certain type
  *
  * If no resources of the type are available and empty
  * array is returned.
  *
  * @param  string  $type   The type of the resource (e.g. foaf:Person)
  * @return array The array of resources
  */
 public function allOfType($type)
 {
     $uri = EasyRdf_Namespace::expand($type);
     $resource = $this->resource($uri);
     return $resource->all('-rdf:type');
 }
开发者ID:nhukhanhdl,项目名称:easyrdf,代码行数:14,代码来源:Graph.php

示例5: delete

 /**
  * Delete an existing RDF type mapping.
  *
  * @param  string  $type   The RDF type (e.g. foaf:Person)
  */
 public static function delete($type)
 {
     if (!is_string($type) or $type == null or $type == '') {
         throw new InvalidArgumentException("\$type should be a string and cannot be null or empty");
     }
     $type = EasyRdf_Namespace::expand($type);
     if (isset(self::$_map[$type])) {
         unset(self::$_map[$type]);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:TypeMapper.php

示例6: addType

 /** Add one or more rdf:type properties to a resource
  *
  * @param  string  $resource The resource to add the type to
  * @param  string  $type     The new type (e.g. foaf:Person)
  */
 public function addType($resource, $types)
 {
     $this->checkResourceParam($resource, true);
     if (!is_array($types)) {
         $types = array($types);
     }
     foreach ($types as $type) {
         $type = EasyRdf_Namespace::expand($type);
         $this->add($resource, 'rdf:type', array('type' => 'uri', 'value' => $type));
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:16,代码来源:Graph.php

示例7: to_rdfphp

 /**
  * Method to serialise an EasyRdf_Graph into RDF/PHP
  *
  * http://n2.talis.com/wiki/RDF_PHP_Specification
  */
 protected function to_rdfphp($graph)
 {
     $rdfphp = array();
     foreach ($graph->resources() as $resource) {
         $properties = $resource->properties();
         if (count($properties) == 0) {
             continue;
         }
         $subj = $resource->getUri();
         if (!isset($rdfphp[$subj])) {
             $rdfphp[$subj] = array();
         }
         foreach ($properties as $property) {
             $prop = EasyRdf_Namespace::expand($property);
             if ($prop) {
                 if (!isset($rdfphp[$subj][$prop])) {
                     $rdfphp[$subj][$prop] = array();
                 }
                 $objects = $resource->all($property);
                 foreach ($objects as $obj) {
                     if (is_object($obj) and $obj instanceof EasyRdf_Resource) {
                         if ($obj->isBNode()) {
                             $object = array('type' => 'bnode', 'value' => $obj->getUri());
                         } else {
                             $object = array('type' => 'uri', 'value' => $obj->getUri());
                         }
                     } else {
                         $object = array('type' => 'literal', 'value' => $obj);
                     }
                     array_push($rdfphp[$subj][$prop], $object);
                 }
             }
         }
     }
     return $rdfphp;
 }
开发者ID:richardhodgson,项目名称:console,代码行数:41,代码来源:Builtin.php

示例8: __construct

 /** Constructor for creating a new literal
  *
  * @param  string $value     The value of the literal
  * @param  string $lang      The natural language of the literal or null (e.g. 'en')
  * @param  string $datatype  The datatype of the literal or null (e.g. 'xsd:string')
  * @return object EasyRdf_Literal
  */
 public function __construct($value, $lang = null, $datatype = null)
 {
     $this->_value = $value;
     $this->_lang = $lang ? $lang : null;
     $this->_datatype = $datatype ? $datatype : null;
     if ($this->_datatype) {
         // Expand shortened URIs (qnames)
         $this->_datatype = EasyRdf_Namespace::expand($this->_datatype);
         // Literals can not have both a language and a datatype
         $this->_lang = null;
     } else {
         // Set the datatype based on the subclass
         $class = get_class($this);
         if (isset(self::$_classMap[$class])) {
             $this->_datatype = self::$_classMap[$class];
             $this->_lang = null;
         }
     }
     // Cast to string if it is a string
     if ($this->_lang or !$this->_datatype or $this->_datatype == 'http://www.w3.org/2001/XMLSchema#string') {
         settype($this->_value, 'string');
     }
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:30,代码来源:Literal.php

示例9: formatTypes

 /**
  * Formats a sparql query clause for limiting the search to specific concept types.
  * @param array $types limit search to concepts of the given type(s)
  * @param string $arrayClass the URI for thesaurus array class, or null if not used
  * @return string sparql query clause
  */
 protected function formatTypes($types, $arrayClass)
 {
     $unprefixed_types = array();
     $type = '';
     if (!empty($types)) {
         foreach ($types as $type) {
             $unprefixed_types[] = EasyRdf_Namespace::expand($type);
         }
     }
     // extra types to query, if using thesaurus arrays and no additional type restrictions have been applied
     $extratypes = $arrayClass && $types === array('skos:Concept') ? "UNION { ?s a <{$arrayClass}> }" : "";
     if (sizeof($unprefixed_types) === 1) {
         $type = '<' . $unprefixed_types[0] . '>';
     } else {
         // multiple type limitations require setting a UNION for each of those
         $type = '[]';
         foreach ($unprefixed_types as $utype) {
             $extratypes .= "\nUNION { ?s a <{$utype}> }";
         }
     }
     return "{ ?s rdf:type {$type} } UNION { ?s a isothes:ConceptGroup } {$extratypes}";
 }
开发者ID:jneubert,项目名称:Skosmos,代码行数:28,代码来源:GenericSparql.php

示例10: __construct

 /** Constructor for creating a new literal
  *
  * @param  string $value     The value of the literal
  * @param  string $lang      The natural language of the literal or null (e.g. 'en')
  * @param  string $datatype  The datatype of the literal or null (e.g. 'xsd:string')
  * @return object EasyRdf_Literal
  */
 public function __construct($value, $lang = null, $datatype = null)
 {
     $this->value = $value;
     $this->lang = $lang ? $lang : null;
     $this->datatype = $datatype ? $datatype : null;
     if ($this->datatype) {
         if (is_object($this->datatype)) {
             // Convert objects to strings
             $this->datatype = strval($this->datatype);
         } else {
             // Expand shortened URIs (CURIEs)
             $this->datatype = EasyRdf_Namespace::expand($this->datatype);
         }
         // Literals can not have both a language and a datatype
         $this->lang = null;
     } else {
         // Set the datatype based on the subclass
         $class = get_class($this);
         if (isset(self::$classMap[$class])) {
             $this->datatype = self::$classMap[$class];
             $this->lang = null;
         }
     }
     // Cast value to string
     settype($this->value, 'string');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:33,代码来源:Literal.php

示例11: __construct

 /** Constructor for creating a new literal
  *
  * @param  string $value     The value of the literal
  * @param  string $lang      The natural language of the literal or null (e.g. 'en')
  * @param  string $datatype  The datatype of the literal or null (e.g. 'xsd:string')
  * @return object EasyRdf_Literal
  */
 public function __construct($value, $lang = null, $datatype = null)
 {
     $this->value = $value;
     $this->lang = $lang ? $lang : null;
     $this->datatype = $datatype ? $datatype : null;
     if ($this->datatype) {
         if (is_object($this->datatype)) {
             // Convert objects to strings
             $this->datatype = strval($this->datatype);
         } else {
             // Expand shortened URIs (CURIEs)
             $this->datatype = EasyRdf_Namespace::expand($this->datatype);
         }
         // Literals can not have both a language and a datatype
         $this->lang = null;
     } else {
         // Set the datatype based on the subclass
         $class = get_class($this);
         if (isset(self::$classMap[$class])) {
             $this->datatype = self::$classMap[$class];
             $this->lang = null;
         }
     }
     if (is_float($this->value)) {
         // special handling of floats, as they suffer from locale [mis]configuration
         $this->value = rtrim(sprintf('%F', $this->value), '0');
     } else {
         // Cast value to string
         settype($this->value, 'string');
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:38,代码来源:Literal.php

示例12: testExpandNonString

 public function testExpandNonString()
 {
     $this->setExpectedException('InvalidArgumentException');
     EasyRdf_Namespace::expand($this);
 }
开发者ID:nhukhanhdl,项目名称:easyrdf,代码行数:5,代码来源:NamespaceTest.php

示例13: is_a

 /** Check if a resource is of the specified type
  *
  * @param  string  $type The type to check (e.g. foaf:Person)
  * @return boolean       True if resource is of specified type.
  */
 public function is_a($type)
 {
     $type = EasyRdf_Namespace::expand($type);
     foreach ($this->all('rdf:type') as $t) {
         if ($t->getUri() == $type) {
             return true;
         }
     }
     return false;
 }
开发者ID:nhukhanhdl,项目名称:easyrdf,代码行数:15,代码来源:Resource.php


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