Ejemplo n.º 1
0
 /**
  * @return string
  * @throws \Exception
  */
 public function getDatatype()
 {
     $nodeFactory = new NodeFactory();
     $datatypeUri = self::$xsdString;
     $datatype = librdf_node_get_literal_value_datatype_uri($this->redlandNode);
     if ($datatype !== null) {
         $datatypeUri = librdf_uri_to_string($datatype);
     } elseif ($this->getLanguage() !== null) {
         $datatypeUri = self::$rdfLangString;
     }
     return $nodeFactory->createNamedNode($datatypeUri);
 }
 /**
  * Convert a node into an associate array
  * @ignore
  */
 protected static function nodeToArray($node)
 {
     $object = array();
     $object['type'] = EasyRdf_Parser_Redland::nodeTypeString($node);
     if ($object['type'] == 'uri') {
         $object['value'] = EasyRdf_Parser_Redland::nodeUriString($node);
     } else {
         if ($object['type'] == 'bnode') {
             $object['value'] = '_:' . librdf_node_get_blank_identifier($node);
         } else {
             if ($object['type'] == 'literal') {
                 $object['value'] = librdf_node_get_literal_value($node);
                 $lang = librdf_node_get_literal_value_language($node);
                 if ($lang) {
                     $object['lang'] = $lang;
                 }
                 $datatype = librdf_node_get_literal_value_datatype_uri($node);
                 if ($datatype) {
                     $object['datatype'] = librdf_uri_to_string($datatype);
                 }
             } else {
                 throw new EasyRdf_Exception("Unsupported type: " . $object['type']);
             }
         }
     }
     return $object;
 }
Ejemplo n.º 3
0
Archivo: Node.php Proyecto: bakulf/raop
 /**
  * Return the datattype URI or NULL if this literal has no datatype.
  *
  * @return  string      The datatype URI
  * @access  public
  */
 public function getDatatype()
 {
     $uri = librdf_node_get_literal_value_datatype_uri($this->node);
     if ($uri !== NULL) {
         return librdf_uri_to_string($uri);
     } else {
         return NULL;
     }
 }
Ejemplo n.º 4
0
 function _node($node)
 {
     $r = array();
     if (librdf_node_is_resource($node)) {
         $r['type'] = 'uri';
         $r['value'] = librdf_uri_to_string(librdf_node_get_uri($node));
     } elseif (librdf_node_is_literal($node)) {
         $r['type'] = 'literal';
         $r['value'] = librdf_node_get_literal_value($node);
         $dt = librdf_node_get_literal_value_datatype_uri($node);
         if ($dt) {
             $r['datatype'] = librdf_uri_to_string($dt);
         }
     } elseif (librdf_node_is_blank($node)) {
         $r['type'] = 'bnode';
         $r['value'] = librdf_node_get_blank_identifier($node);
     }
     return $r;
 }
Ejemplo n.º 5
0
 /**
  * @return string
  */
 public function getUri()
 {
     return librdf_uri_to_string(librdf_node_get_uri($this->redlandNode));
 }
Ejemplo n.º 6
0
Archivo: URI.php Proyecto: bakulf/raop
 /**
  * Return the string representation of the URI.
  *
  * @return  string      The URI string
  * @access  public
  */
 public function __toString()
 {
     return librdf_uri_to_string($this->uri);
 }