Пример #1
0
 /**
  * Parse an RDF document into an EasyRdf_Graph
  *
  * @param object EasyRdf_Graph $graph   the graph to load the data into
  * @param string               $data    the RDF document data
  * @param string               $format  the format of the input data
  * @param string               $baseUri the base URI of the data being parsed
  * @return integer             The number of triples added to the graph
  */
 public function parse($graph, $data, $format, $baseUri)
 {
     parent::checkParseParams($graph, $data, $format, $baseUri);
     $json = EasyRdf_Utils::execCommandPipe($this->rapperCmd, array('--quiet', '--input', $format, '--output', 'json', '--ignore-errors', '--input-uri', $baseUri, '--output-uri', '-', '-'), $data);
     // Parse in the JSON
     return parent::parse($graph, $json, 'json', $baseUri);
 }
 /**
  * Serialise an EasyRdf_Graph to the RDF format of choice.
  *
  * @param object EasyRdf_Graph $graph   An EasyRdf_Graph object.
  * @param string  $format               The name of the format to convert to.
  * @return string                       The RDF in the new desired format.
  */
 public function serialise($graph, $format)
 {
     parent::checkSerialiseParams($graph, $format);
     $ntriples = parent::serialise($graph, 'ntriples');
     // Hack to produce more concise RDF/XML
     if ($format == 'rdfxml') {
         $format = 'rdfxml-abbrev';
     }
     return EasyRdf_Utils::execCommandPipe($this->_rapperCmd, array('--quiet', '--input', 'ntriples', '--output', $format, '-', 'unknown://'), $ntriples);
 }
Пример #3
0
 /**
  * Internal function to render a graph into an image
  *
  * @ignore
  */
 public function renderImage($graph, $format = 'png')
 {
     $dot = $this->serialiseDot($graph);
     return EasyRdf_Utils::execCommandPipe($this->dotCommand, array("-T{$format}"), $dot);
 }
 public function testExecCommandPipeNotFound()
 {
     $this->setExpectedException('EasyRdf_Exception', 'Error while executing command no_such_command');
     $output = EasyRdf_Utils::execCommandPipe('no_such_command');
 }