Package org.openrdf.query.resultio.sparqlxml

Examples of org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLWriter


                            {
                                PrintWriter out = new PrintWriter( outputStream );
                                out.println( "<?xml version='1.0' encoding='UTF-8'?>" );
                                out.println( "<?xml-stylesheet type=\"text/xsl\" href=\"query/sparqlhtml.xsl\"?>" );
                                out.flush();
                                TupleQueryResultWriter qrWriter = new SPARQLResultsXMLWriter( new XMLWriter( outputStream )
                                {
                                    @Override
                                    public void startDocument()
                                        throws IOException
                                    {
                                        // Ignore
                                    }
                                } );
                                QueryResultUtil.report( queryResult, qrWriter );
                            }
                            catch( Exception e )
                            {
                                throw new IOException( e );
                            }
                            finally
                            {
                                try
                                {
                                    conn.close();
                                }
                                catch( RepositoryException e )
                                {
                                    // Ignore
                                }
                            }
                        }
                    };
                }
                else if( variant.getMediaType().equals( MediaType.APPLICATION_RDF_XML ) )
                {
                    return new OutputRepresentation( MediaType.APPLICATION_XML )
                    {
                        @Override
                        public void write( OutputStream outputStream )
                            throws IOException
                        {
                            try
                            {
                                TupleQueryResultWriter qrWriter = new SPARQLResultsXMLWriter( new XMLWriter( outputStream ) );
                                QueryResultUtil.report( queryResult, qrWriter );
                            }
                            catch( Exception e )
                            {
                                throw new IOException( e );
View Full Code Here


      Query q = conn.prepareQuery(QueryLanguage.SPARQL, query);
     
      if (q instanceof TupleQuery) {
        /* <code>SELECT</code> form */
        response.setContentType("application/sparql-results+xml");
        SPARQLResultsXMLWriter sparqlWriter = new SPARQLResultsXMLWriter(outputStream);
        ((TupleQuery) q).evaluate(sparqlWriter);
      }
      else if (q instanceof GraphQuery) {
        /* <code>CONSTRUCT</code> and <code>DESCRIBE</code> forms */
        response.setContentType("application/rdf+xml");
 
View Full Code Here

    private Templates stylesheet;

    public SPARQLResultsHTMLWriterXSL(OutputStream out) {
        this.out = out;
        this.xmlOut = new ByteArrayOutputStream();
        this.writer = new SPARQLResultsXMLWriter(xmlOut);
        Source s_stylesheet = new StreamSource(SPARQLResultsHTMLWriterXSL.class.getResourceAsStream("style.xsl"));
        try {
            stylesheet = TransformerFactory.newInstance().newTemplates(s_stylesheet);
        } catch (TransformerConfigurationException e) {
            log.error("could not compile stylesheet for rendering SPARQL results; result display not available!");
View Full Code Here

    private Templates stylesheet;

    public SPARQLResultsHTMLWriterXSL(OutputStream out) {
        this.out = out;
        this.xmlOut = new ByteArrayOutputStream();
        this.xmlWriter = new SPARQLResultsXMLWriter(xmlOut);
        Source s_stylesheet = new StreamSource(SPARQLResultsHTMLWriterXSL.class.getResourceAsStream("style.xsl"));
        try {
            stylesheet = TransformerFactory.newInstance().newTemplates(s_stylesheet);
        } catch (TransformerConfigurationException e) {
            log.error("could not compile stylesheet for rendering SPARQL results; result display not available!");
View Full Code Here

    private TupleQueryResultWriter getTupleResultWriter(String format, OutputStream os) {
        //build outputwriter
        final TupleQueryResultWriter out;
        if(format == null) {
            out = new SPARQLResultsXMLWriter(os);
        } else if(parseSubType(format).equals("html")) {
            out = new SPARQLResultsHTMLWriter(os, templatingService);
        } else if(parseSubType(format).equals("json")) {
            out = new SPARQLResultsJSONWriter(os);
        } else if(parseSubType(format).equals("xml")) {
            out = new SPARQLResultsXMLWriter(os);
        } else if(parseSubType(format).equals("csv")) {
            out = new SPARQLResultsCSVWriter(os);
        } else throw new InvalidArgumentException("could not produce format "+format);
        return out;
    }
View Full Code Here

    private TupleQueryResultWriter getTupleResultWriter(String format, OutputStream os) {
        //build outputwriter
        final TupleQueryResultWriter out;
        if(format == null) {
            out = new SPARQLResultsXMLWriter(os);
        } else if(SparqlWritersHelper.parseSubType(format).equals("html")) {
            out = new SPARQLResultsHTMLWriter(os, templatingService);
        } else if(SparqlWritersHelper.parseSubType(format).equals("json")) {
            out = new SPARQLResultsJSONWriter(os);
        } else if(SparqlWritersHelper.parseSubType(format).equals("xml")) {
            out = new SPARQLResultsXMLWriter(os);
        } else if(SparqlWritersHelper.parseSubType(format).equals("csv")) {
            out = new SPARQLResultsCSVWriter(os);
        } else throw new InvalidArgumentException("could not produce format "+format);
        return out;
    }
View Full Code Here

TOP

Related Classes of org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.