Пример #1
0
 /**
  * Load statements from a URI using a {@link LibRDF_Parser}.
  *
  * @param   LibRDF_Parser   $parser The parser with which to parse the URI's contents
  * @param   string          $uri    The URI with the contents to load
  * @param   string          $base_uri   The base URI to use for relative URIs if different from $uri
  * @return  void
  * @throws  LibRDF_Error    If unable to parse the URI contents
  * @access  public
  */
 public function loadStatementsFromURI(LibRDF_Parser $parser, $uri, $base_uri = NULL)
 {
     if ($uri instanceof LibRDF_URINode) {
         $uri = new LibRDF_URI(substr($uri, 1, -1));
     } else {
         $uri = new LibRDF_URI($uri);
     }
     if ($base_uri) {
         $base_uri = new LibRDF_URI($base_uri);
     }
     $ret = librdf_parser_parse_into_model($parser->getParser(), $uri->getURI(), $base_uri ? $base_uri->getURI() : $base_uri, $this->model);
     if ($ret) {
         throw new LibRDF_Error("Unable to parse URI into model");
     }
 }
Пример #2
0
 public function testGetNamespacePrelude()
 {
     $this->assertType('string', MwRdf::getNamespacePrelude());
     $parser = new LibRDF_Parser('turtle');
     $i = $parser->parseString(MwRdf::getNamespacePrelude());
     $this->assertTrue($i instanceof LibRDF_StreamIterator, get_class($i));
     // this should be a completely empty result, we're just proving it
     // can be parsed
     $this->assertNull($i->current());
     $this->assertNull($i->next());
 }