protected function getNodeForRedlandNode($redlandNode) { if (librdf_node_is_literal($redlandNode)) { return new Literal($redlandNode); } elseif (librdf_node_is_resource($redlandNode)) { return new NamedNode($redlandNode); } elseif (librdf_node_is_blank($redlandNode)) { return new BlankNode($redlandNode); } }
/** * Create a new blank node with an optional identifier. * * @param mixed $nodeId The nodeId value or librdf_node resource * @return void * @throws LibRDF_Error If unable to create a new node * @access public */ public function __construct($nodeId = NULL) { if ($nodeId !== NULL) { if (is_resource($nodeId)) { if (librdf_node_is_blank($nodeId)) { $this->node = $nodeId; } else { throw new LibRDF_Error("Resource argument not a valid" . " librdf_node blank node"); } } else { $this->node = librdf_new_node_from_blank_identifier(librdf_php_get_world(), $nodeId); } } else { $this->node = librdf_new_node(librdf_php_get_world()); } if (!$this->node) { throw new LibRDF_Error("Unable to create new blank node"); } }
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; }