Search code examples
rdfowlprotege

Command line options/tools to convert OWL/XML to RDF/XML


I had written a script which exports a relational database to an OWL/XML file, although I now need the data in RDF/XML format instead. Does anyone know of a command line tool or simple way to do this (convert the OWL synax to RDF)? I'd like to avoid rewriting the script.

I know the University of Manchester has an online syntax converter, but this isn't useful as I need something which can be used offline (and perhaps as part of an automated process). Protege can open OWL files and save them as RDFs, but I can't seem to find info about command line options to do this within it.

Any help is appreciated.


Solution

  • I'm not aware of a command line tool but if you're willing to write a little Java you can use OWL API (the same api Protege uses) to write your own convertor to any supported syntax.

    The code looks like this:

    OWLOntologyManager m = OWLManager.createOWLOntologyManager();
    OWLOntology o = m.loadOntologyFromOntologyDocument(inputFile);
    OutputStream out=new FileOutputStream("your output file name");
    m.saveOntology(o, new RDFXMLDocumentFormat(), out);
    out.close();
    

    Tutorials and documentation available here