/** * Returns the Statement-Data in sparql-Format. * * @param StatementIterator $statements List of statements to format as SPARQL string. * @param string $graphUri Use if each statement is a triple and to use another graph as * the default. * @return string, part of query */ protected function sparqlFormat(StatementIterator $statements, Node $graph = null) { return SparqlUtils::statementIteratorToSparqlFormat($statements, $graph); }
public function testStatementIteratorToSparqlFormatTripleAndQuad() { $triple = new StatementImpl(new NamedNodeImpl('http://saft/test/s1'), new NamedNodeImpl('http://saft/test/p1'), new LiteralImpl("42")); $quad = new StatementImpl(new NamedNodeImpl('http://saft/test/s1'), new NamedNodeImpl('http://saft/test/p1'), new LiteralImpl("42"), $this->testGraph); $this->assertEquals('<http://saft/test/s1> <http://saft/test/p1> "42"^^<http://www.w3.org/2001/XMLSchema#string> . ' . 'Graph <http://localhost/Saft/TestGraph/> {<http://saft/test/s1> <http://saft/test/p1> ' . '"42"^^<http://www.w3.org/2001/XMLSchema#string> . }', trim(SparqlUtils::statementIteratorToSparqlFormat(array($triple, $quad)))); }