stevenh@70: package org.qmul.eecs.c4dm.sia; stevenh@70: stevenh@70: import java.io.File; stevenh@70: import java.io.FileNotFoundException; stevenh@70: import java.io.FileOutputStream; stevenh@70: stevenh@70: import org.apache.jena.web.DatasetGraphAccessorHTTP; stevenh@70: import org.mindswap.pellet.jena.PelletReasonerFactory; stevenh@70: import org.qmul.eecs.c4dm.sparql.utilities.SparqlWrapperMethods; stevenh@70: stevenh@70: import com.hp.hpl.jena.ontology.OntModel; stevenh@70: import com.hp.hpl.jena.ontology.OntModelSpec; stevenh@70: import com.hp.hpl.jena.query.Dataset; stevenh@70: import com.hp.hpl.jena.query.DatasetAccessor; stevenh@70: import com.hp.hpl.jena.query.DatasetAccessorFactory; stevenh@70: import com.hp.hpl.jena.query.QuerySolution; stevenh@70: import com.hp.hpl.jena.query.ResultSet; stevenh@70: import com.hp.hpl.jena.rdf.model.Model; stevenh@70: import com.hp.hpl.jena.rdf.model.ModelFactory; stevenh@70: import com.hp.hpl.jena.tdb.TDBFactory; stevenh@70: import com.hp.hpl.jena.update.UpdateAction; stevenh@70: stevenh@70: /** stevenh@70: * @author stevenh stevenh@70: * Utility class which converts an N3 file to RDF/XML stevenh@70: */ stevenh@70: public class N3ToRdf { stevenh@70: stevenh@70: // Ontology N3 file stevenh@70: private static final String n3ontology = "file:src/rdf/siaTestDatapointOntology.n3"; stevenh@70: // private static final String n3ontology = "file:src/rdf/midiModel.n3"; stevenh@70: stevenh@70: // The RDF output file stevenh@70: private static final String rdfFileName = "/Volumes/USB_DISK/mercurial/SiaSesame/ontology/siaTestDatapointOntology"; stevenh@70: stevenh@70: /** stevenh@70: * @param args stevenh@70: */ stevenh@70: public static void main(String[] args) { stevenh@70: stevenh@70: // Create an ontology model stevenh@70: OntModel ontModel = ModelFactory stevenh@70: .createOntologyModel(); stevenh@70: stevenh@70: // Read the ontology and data from the file into the ontology model stevenh@70: ontModel.read(n3ontology, "N3"); stevenh@70: stevenh@70: // Write the model to a file stevenh@70: File outFileRdf = new File(rdfFileName + ".rdf"); stevenh@70: FileOutputStream outFileOutputStreamRdf; stevenh@70: stevenh@70: // RDF/XML version stevenh@70: try { stevenh@70: outFileOutputStreamRdf = new FileOutputStream(outFileRdf); stevenh@70: ontModel.writeAll(outFileOutputStreamRdf, "RDF/XML", null); stevenh@70: } catch (FileNotFoundException e) { stevenh@70: System.out.println("Unable to write to file: " stevenh@70: + outFileRdf.getAbsolutePath()); stevenh@70: e.printStackTrace(); stevenh@70: System.exit(1); stevenh@70: } stevenh@70: stevenh@70: System.out.println("Model written to file: " stevenh@70: + outFileRdf.getAbsolutePath()); stevenh@70: stevenh@70: } stevenh@70: stevenh@70: }