Example #1
0
 /**
  * Load statements using a {@link LibRDF_Parser}.
  *
  * If no $base_uri is given, the RDF namespace URI will be used as the
  * base for relative URIs.
  *
  * @param   LibRDF_Parser   $parser The parser with which to parse the string
  * @param   string          $string The string to parse
  * @param   string          $base_uri   The base URI to use for relative URIs in the string
  * @return  void
  * @throws  LibRDF_Error    If unable to parse the string
  * @access  public
  */
 public function loadStatementsFromString(LibRDF_Parser $parser, $string, $base_uri = NULL)
 {
     if ($base_uri) {
         $base_uri = new LibRDF_URI($base_uri);
     } else {
         $base_uri = new LibRDF_URI(RDF_BASE_URI);
     }
     $ret = librdf_parser_parse_string_into_model($parser->getParser(), $string, $base_uri->getURI(), $this->model);
     if ($ret) {
         throw new LibRDF_Error("Unable to parse string into model");
     }
 }
Example #2
0
 function append($content_type, $content, $base = null)
 {
     if ($content_type == 'json-ld') {
         return $this->append_jsonld($content);
     } elseif ($content_type == 'json' && raptor_version_decimal_get() < 20004) {
         return $this->append_array(json_decode($content, 1));
     }
     $base_uri = librdf_new_uri($this->_world, is_null($base) ? $this->_base : $base);
     $p = librdf_new_parser($this->_world, $content_type, null, null);
     $r = librdf_parser_parse_string_into_model($p, $content, $base_uri, $this->_model);
     librdf_free_parser($p);
     librdf_free_uri($base_uri);
     return $r == 0;
 }