protected function EasyRdf_Parser_Ntriples::parseNtriplesSubject

@ignore

1 call to EasyRdf_Parser_Ntriples::parseNtriplesSubject()
EasyRdf_Parser_Ntriples::parse in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Ntriples.php
Parse an N-Triples document into an EasyRdf_Graph

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Ntriples.php, line 106

Class

EasyRdf_Parser_Ntriples
A pure-php class to parse N-Triples with no dependancies.

Code

protected function parseNtriplesSubject($sub) {
  if (preg_match('/<([^<>]+)>/', $sub, $matches)) {
    return $this
      ->unescapeString($matches[1]);
  }
  elseif (preg_match('/_:([A-Za-z0-9]*)/', $sub, $matches)) {
    if (empty($matches[1])) {
      return $this->graph
        ->newBNodeId();
    }
    else {
      $nodeid = $this
        ->unescapeString($matches[1]);
      return $this
        ->remapBnode($nodeid);
    }
  }
  else {
    throw new EasyRdf_Exception("Failed to parse subject: {$sub}");
  }
}