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

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


  public void serialize(Model model, Resource[] mainResources,
      String baseURL, Locale[] acceptedLocales,
      UnavailableLocalisationHandler handler, String encoding,
      boolean forceShow, OutputStream out) throws SerializeException, IOException,
      LanguageUnavailableException {
      RDFWriter w = model.getWriter("N3");
      w.setProperty("usePropertySymbols", "false");
      w.setProperty("useTripleQuotedStrings", "false");
      w.setProperty("useDoubles", "false");
      w.write(model, out, baseURL);
   
  }
View Full Code Here


    }
  }
 
  private class RDFXMLWriter implements ModelWriter {
    public void write(Model model, HttpServletResponse response) throws IOException {
      RDFWriter writer = model.getWriter("RDF/XML-ABBREV");
      writer.setProperty("showXmlDeclaration", "true");
      // From Joseki -- workaround for the j.cook.up bug.
      writer.setProperty("blockRules", "propertyAttr");
      writer.write(model,
          new OutputStreamWriter(response.getOutputStream(), "utf-8"), null);
    }
View Full Code Here

     

      Model d2rqModel = loader.getModelD2RQ();

      try {
        RDFWriter writer = d2rqModel.getWriter(format.toUpperCase());
        if (format.equals("RDF/XML") || format.equals("RDF/XML-ABBREV")) {
          writer.setProperty("showXmlDeclaration", "true");
          if (loader.getResourceBaseURI() != null) {
            writer.setProperty("xmlbase", loader.getResourceBaseURI());
          }
        }
        writer.write(d2rqModel, new OutputStreamWriter(out, "utf-8"), loader.getResourceBaseURI());
      } catch (NoWriterForLangException ex) {
        throw new D2RQException("Unknown format '" + format + "'", D2RQException.STARTUP_UNKNOWN_FORMAT);
      } catch (UnsupportedEncodingException ex) {
        throw new RuntimeException("Can't happen -- utf-8 is always supported");
      }
View Full Code Here

    resp.setContentType("application/rdf+xml");
    resp.setCharacterEncoding("UTF-8");
    final PrintWriter out = resp.getWriter();
    SdbUtil.runWrap(ds, storeDesc, model, new SdbQuery() {
      public void exec(Model sdbModel) {
        RDFWriter w = sdbModel.getWriter();
        w.setProperty("allowBadURIs", true);
        w.write(sdbModel, out, null);
      }
    });
    out.flush();
  }
View Full Code Here

    if (showProgress)
      System.out.println("Beginning " + test);
    Random random = new Random(seed);

        RDFReader rdfRdr = m1.getReader( rwLang );
    RDFWriter rdfWtr = m1.getWriter( rwLang );

    setWriterOptionsAndHandlers( wopName, wopVal, rdfRdr, rdfWtr );
    for (int variationIndex = 0; variationIndex < variationMax; variationIndex++)
      testVariation( filebase, random, rdfRdr, rdfWtr );
    if (showProgress)
View Full Code Here

    {
            Model model = createMemModel();
            FileManager.get().readModel(model, filename );
           
            StringWriter sw = new StringWriter();
            RDFWriter w =  model.getWriter(writerName) ;
            if ( propertyName != null )
                w.setProperty(propertyName, propertyValue) ;
            w.write(model, sw, null) ;
           
            try { sw.close(); } catch (IOException ex) {}

            Model model2 = createMemModel();
            model2.read( new StringReader( sw.toString() ), filename );
View Full Code Here

        else {
            bos = new ByteArrayOutputStream();
            sw = new OutputStreamWriter(bos, encoding);
        }
        Properties p = (Properties) System.getProperties().clone();
        RDFWriter writer = m.getWriter(lang);
        code.modify( m, writer );
        writer.write( m, sw, base );
        sw.close();

        String contents;
        if (encoding == null)
            contents = sw.toString();
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

      super("save results");
    }
    @Override
        public void runTest()  throws IOException {
      if (logging) {     
        RDFWriter w = testResults.getWriter("RDF/XML-ABBREV");
        w.setProperty("xmlbase",BASE_RESULTS_URI );
        OutputStream out;
        try {
        out = new FileOutputStream("/tmp/rdf-results.rdf");
        }
        catch (Exception e){
          out = System.out;
        }
        w.write(testResults,out,BASE_RESULTS_URI);
        out.close();
      }
    }
View Full Code Here

    @Test public void ntriples0()
    {
        Model m = ModelFactory.createDefaultModel() ;
        m.getGraph().add(t1) ;
        OutputStream out = new ByteArrayOutputStream() ;
        RDFWriter w = new JenaWriterNTriples2() ;
        w.write(m, out, null) ;
    }
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.