Search in sources :

Example 1 with SPARQLBooleanXMLWriter

use of org.openrdf.query.resultio.sparqlxml.SPARQLBooleanXMLWriter in project gocd by gocd.

the class SesameGraph method renderSPARQLResultsAsXML.

public void renderSPARQLResultsAsXML(String sparql, OutputStream stream) {
    try {
        Query query = conn.prepareQuery(QueryLanguage.SPARQL, sparql);
        contextualize(query);
        if (query instanceof TupleQuery) {
            renderTupleQuery(query, new SPARQLResultsXMLWriter(stream));
        } else {
            renderBooleanQuery(query, new SPARQLBooleanXMLWriter(stream));
        }
        stream.flush();
    } catch (UnsupportedSPARQLStatementException e) {
        throw e;
    } catch (Exception e) {
        throw new ShineRuntimeException("Could not render sparql results as XML: <<" + sparql + ">>", e);
    }
}
Also used : SPARQLResultsXMLWriter(org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLWriter) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) SailQuery(org.openrdf.repository.sail.SailQuery) Query(org.openrdf.query.Query) TupleQuery(org.openrdf.query.TupleQuery) BooleanQuery(org.openrdf.query.BooleanQuery) UnsupportedSPARQLStatementException(com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException) SPARQLBooleanXMLWriter(org.openrdf.query.resultio.sparqlxml.SPARQLBooleanXMLWriter) TupleQuery(org.openrdf.query.TupleQuery) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) RepositoryException(org.openrdf.repository.RepositoryException) TupleQueryResultHandlerException(org.openrdf.query.TupleQueryResultHandlerException) MoreThanOneResultFoundException(com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException) MalformedSPARQLException(com.thoughtworks.studios.shine.semweb.MalformedSPARQLException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) OpenRDFException(org.openrdf.OpenRDFException) NoSuchElementException(java.util.NoSuchElementException) MalformedQueryException(org.openrdf.query.MalformedQueryException) RDFHandlerException(org.openrdf.rio.RDFHandlerException) IOException(java.io.IOException) UnsupportedSPARQLStatementException(com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException)

Aggregations

ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)1 MalformedSPARQLException (com.thoughtworks.studios.shine.semweb.MalformedSPARQLException)1 MoreThanOneResultFoundException (com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException)1 UnsupportedSPARQLStatementException (com.thoughtworks.studios.shine.semweb.UnsupportedSPARQLStatementException)1 IOException (java.io.IOException)1 NoSuchElementException (java.util.NoSuchElementException)1 OpenRDFException (org.openrdf.OpenRDFException)1 BooleanQuery (org.openrdf.query.BooleanQuery)1 MalformedQueryException (org.openrdf.query.MalformedQueryException)1 Query (org.openrdf.query.Query)1 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)1 TupleQuery (org.openrdf.query.TupleQuery)1 TupleQueryResultHandlerException (org.openrdf.query.TupleQueryResultHandlerException)1 SPARQLBooleanXMLWriter (org.openrdf.query.resultio.sparqlxml.SPARQLBooleanXMLWriter)1 SPARQLResultsXMLWriter (org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLWriter)1 RepositoryException (org.openrdf.repository.RepositoryException)1 SailQuery (org.openrdf.repository.sail.SailQuery)1 RDFHandlerException (org.openrdf.rio.RDFHandlerException)1