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

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


    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


    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

             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

     * @param ontologyURI
     *            URI of the ontology
     */
    public void saveOntology(Model ontology, String ontologyURI) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        RDFWriter rdfWriter = ontology.getWriter("RDF/XML");
        rdfWriter.setProperty("xmlbase", ontologyURI);
        rdfWriter.write(ontology, baos, ontologyURI);
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

        if (modelExists(ontologyURI)) {
            deleteModel(ontologyURI);
        }
View Full Code Here

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        if (mediaType.equals("application/rdf+xml")) {
            t.write(stream);
        } else if (mediaType.equals("application/turtle")) {
            // t.write(stream, "TURTLE");
            RDFWriter writer = t.getWriter("TURTLE");
            log.debug("Writer for TURTLE: {}", writer);
            writer.write(t, stream, null);
        } else if (mediaType.equals("text/turtle")) {
            t.write(stream, "TURTLE");
        } else if (mediaType.equals("text/plain")) {
            t.write(stream, "TURTLE");
        } else if (mediaType.equals("text/n3")) {
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

    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

            FileManager.get().readModel(model, filename );
           
            String contents = null ;
           
            try ( StringWriter sw = new StringWriter() ) {
                RDFWriter w =  model.getWriter(writerName) ;
                if ( propertyName != null )
                    w.setProperty(propertyName, propertyValue) ;
                w.write(model, sw, null) ;
                contents = sw.toString() ;
            } catch (IOException ex) { /* ignore : StringWriter */ }

            try ( StringReader sr = new StringReader( contents ) ) {
                Model model2 = createMemModel();
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

      super("save results");
    }
    @Override
        public void runTest()  throws IOException {
      if (logging) {     
          RDFWriter w = testResults.getWriter("RDF/XML-ABBREV");
          w.setProperty("xmlbase",BASE_RESULTS_URI );
          try ( OutputStream out = new FileOutputStream("/tmp/rdf-results.rdf") ) {
              w.write(testResults,out,BASE_RESULTS_URI);
          }
      }
    }
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.