Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.RDFWriter


    }

    private void write (Model parsed, Model expected)
    {
      // This is temporary, until the plumbing with Jena gets released (or ARQ depends on the jena-core SNAPSHOT). See: JENA-135
      RDFWriter writer = new JenaWriterRdfJson() ;
        System.out.println("---- Parsed");
        // parsed.write(System.out, "RDF/JSON") ;
        writer.write(parsed, System.out, baseIRI) ;
        System.out.println("---- Expected");
        // expected.write(System.out, "RDF/JSON") ;
        writer.write(expected, System.out, baseIRI) ;
        System.out.println("--------");
    }
View Full Code Here


                contentType = WebContent.contentTypeTextPlain ;
                charset = WebContent.charsetUTF8 ;
            }
           
            Lang lang = FusekiLib.langFromContentType(ts.getMediaType()) ;
            RDFWriter rdfw = FusekiLib.chooseWriter(lang) ;
                
            if ( rdfw instanceof RDFXMLWriterI )
                rdfw.setProperty("showXmlDeclaration", "true") ;
           
    //        // Write locally to check it's possible.
    //        // Time/space tradeoff.
    //        try {
    //            OutputStream out = new NullOutputStream() ;
    //            rdfw.write(model, out, null) ;
    //            IO.flush(out) ;
    //        } catch (JenaException ex)
    //        {
    //            SPARQL_ServletBase.errorOccurred(ex) ;
    //        }
           
            // Managed to write it locally
            try {
                ResponseResultSet.setHttpResponse(request, response, contentType, charset) ;
                response.setStatus(HttpSC.OK_200) ;
                rdfw.write(model, response.getOutputStream(), null) ;
                response.getOutputStream().flush() ;
            }
            catch (Exception ex) { SPARQL_ServletBase.errorOccurred(ex) ; }
        }
View Full Code Here

        if ( outputFormat.equals(ResultsFormat.FMT_RDF_XML) || outputFormat.equals(ResultsFormat.FMT_RDF_N3)
             || outputFormat.equals(ResultsFormat.FMT_RDF_TTL) ) {
            Model m = ResultSetFormatter.toModel(results) ;
            m.setNsPrefixes(prologue.getPrefixMapping()) ;
            RDFWriter rdfw = m.getWriter("TURTLE") ;
            m.setNsPrefix("rs", ResultSetGraphVocab.getURI()) ;
            rdfw.write(m, System.out, null) ;
            done = true ;
        }

        if ( outputFormat.equals(ResultsFormat.FMT_RS_XML) ) {
            ResultSetFormatter.outputAsXML(System.out, results) ;
View Full Code Here

             outputFormat.equals(ResultsFormat.FMT_RDF_N3) ||
             outputFormat.equals(ResultsFormat.FMT_RDF_TTL) )
        {
            Model m = ResultSetFormatter.toModel(results) ;
            m.setNsPrefixes(prologue.getPrefixMapping()) ;
            RDFWriter rdfw = m.getWriter("TURTLE") ;
            m.setNsPrefix("rs", ResultSetGraphVocab.getURI()) ;
            rdfw.write(m, System.out, null) ;
            done = true ;
        }

        if ( outputFormat.equals(ResultsFormat.FMT_RS_XML) )
        {
View Full Code Here

    @Override public abstract Lang getLang() ;

    @Override
    public void write(Writer out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
    {
        RDFWriter w = create() ;
        w.write(ModelFactory.createModelForGraph(graph), out, baseURI) ;
    }
View Full Code Here

    }

    @Override
    public void write(OutputStream out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
    {
        RDFWriter w = create() ;
        w.write(ModelFactory.createModelForGraph(graph), out, baseURI) ;
    }
View Full Code Here

  public void serialize(OutputStream serializedGraph, TripleCollection tc,
      String formatIdentifier) {
    String jenaFormat = getJenaFormat(formatIdentifier);
    com.hp.hpl.jena.graph.Graph graph = new JenaGraph(tc);
    Model model = ModelFactory.createModelForGraph(graph);
    RDFWriter writer = model.getWriter(jenaFormat);
    if ("RDF/XML".equals(jenaFormat)) {
      //jena complains about some URIs that aren't truely bad
      //see: http://tech.groups.yahoo.com/group/jena-dev/message/38313
      writer.setProperty("allowBadURIs", Boolean.TRUE);
    }
    writer.write(model, serializedGraph, "");
  }
View Full Code Here

      if ( false ) {
        model.write(out, "RDF/XML-ABBREV", base);
      }
      else {
        // TODO When model is OntModel, the following generates a bunch of stuff
        RDFWriter writer = model.getWriter("RDF/XML-ABBREV");
        writer.setProperty("showXmlDeclaration", "true");
        writer.setProperty("relativeURIs", "same-document,relative");
        writer.setProperty("tab", "4");
        if ( xmlbase != null ) {
          writer.setProperty("xmlbase", xmlbase);
        }

        writer.write(model, out, namespace);
      }
    }
    finally {
      IOUtils.closeQuietly(out);
    }
View Full Code Here

    }
   
    FileOutputStream out = new FileOutputStream(file);
   
    try {
      RDFWriter writer = model.getWriter("RDF/XML-ABBREV");
      writer.setProperty("showXmlDeclaration", "true");
      writer.setProperty("relativeURIs", "same-document,relative");
      writer.setProperty("tab", "4");
      if ( xmlbase != null ) {
        // NOTE about namespace for xmlbase, see ChangeLog.txt 2010-08-04
//        writer.setProperty("xmlbase", xmlbase);
        writer.setProperty("xmlbase", namespace);
      }

      writer.write(model, out, namespace);
    }
    finally {
      IOUtils.closeQuietly(out);
    }
  }
View Full Code Here

    return concept;
  }

  private void _saveNewOntology() {

    RDFWriter writer = model.getWriter("RDF/XML-ABBREV");
    writer.setProperty("showXmlDeclaration", "true");
    writer.setProperty("relativeURIs", "same-document,relative");
    writer.setProperty("xmlbase", namespace);
    try {
      FileOutputStream fo = new FileOutputStream(outputFile);
      // model.setNsPrefix("",NS);
      // model.write(fo,"RDF/XML-ABBREV");

      writer.write(model, fo, null);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.RDFWriter

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.