Example #1
0
 public function valid()
 {
     if (librdf_stream_end($this->stream)) {
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Return whether the stream is still valid.
  *
  * @return  boolean     Whether the stream is still valid
  * @access  public
  */
 public function valid()
 {
     if ($this->isvalid and !librdf_stream_end($this->stream)) {
         return true;
     } else {
         return false;
     }
 }
Example #3
0
 function to_jsonld_string()
 {
     $r = array();
     $stream = librdf_model_as_stream($this->_model);
     while (!librdf_stream_end($stream)) {
         $elt = $this->_statement(librdf_stream_get_object($stream));
         $d = new \stdClass();
         $d->{'@subject'} = $elt[0]['value'];
         if ($elt[2]['type'] == 'literal') {
             if (isset($elt[2]['datatype'])) {
                 $d->{$elt[1]['value']} = (object) array('@literal' => $elt[2]['value'], '@datatype' => $elt[2]['datatype']);
             } else {
                 $d->{$elt[1]['value']} = $elt[2]['value'];
             }
         } else {
             $d->{$elt[1]['value']} = (object) array('@iri' => $elt[2]['value']);
         }
         $r[] = $d;
         librdf_stream_next($stream);
     }
     librdf_free_stream($stream);
     return str_replace('\\/', '/', json_encode(jsonld_normalize($r)));
 }