protected function EasyRdf_Parser_Redland::nodeToArray

Convert a node into an associate array @ignore

1 call to EasyRdf_Parser_Redland::nodeToArray()
EasyRdf_Parser_Redland::parse in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Redland.php
Parse an RDF document into an EasyRdf_Graph

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Redland.php, line 124

Class

EasyRdf_Parser_Redland
Class to parse RDF using Redland (librdf) C library.

Code

protected function nodeToArray($node) {
  $object = array();
  $object['type'] = EasyRdf_Parser_Redland::nodeTypeString($node);
  if ($object['type'] == 'uri') {
    $object['value'] = EasyRdf_Parser_Redland::nodeUriString($node);
  }
  elseif ($object['type'] == 'bnode') {
    $object['value'] = '_:' . librdf_node_get_blank_identifier($node);
  }
  elseif ($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;
}