Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert rdf to xml

I need to convert RDF files in XML, through a process in C#. Is this possible?


What I need is a process or command that can convert one or more Oracle report (. Rdf) to XML, for example:

We start example.rdf and need a process that transforms example.rdf in an XML file (example.xml) containing the same information as the rdf file.

I searched and found rwconverter.exe Oracle http://download.oracle.com/docs/html/B10314_01/pbr_cla.htm#634712. I've also been seeing rdf2xml http://www.semwebtech.org/rdf2xml/, but not if it's the right way.

Thank you so much

like image 520
Oliver Avatar asked Sep 05 '25 03:09

Oliver


1 Answers

Your question is unclear but I'll give you a quick example using the open source API dotNetRDF that I'm a developer on to just convert between RDF serializations. If this was not what you meant then you need to expand your question to explain what you want to do as others have already commented.

Simplest way to convert between one RDF serialization and another:

Graph g = new Graph();
g.LoadFromFile("input.ttl");
g.SaveToFile("output.rdf");

The above example would take in input.ttl and attempt to read it as Turtle (does auto-format detection based on file extension) and then attempt to save it as RDF/XML (again does auto-format detection based on file extension).

If your file extensions were not standard you can specify the reader and writer explicitly e.g.

Graph g = new Graph();
g.LoadFromFile("input.temp", new RdfJsonParser());
g.SaveToFile("output.temp", new NTriplesWriter());

That example will read the input file as RDF/JSON and output is as NTriples.

If you are only wanting to do conversion and have large input data to convert there are more memory efficient ways of doing this as the above examples require loading the entire input into memory first. If the input is too big you may hit an OutOfMemoryException in trying to run the above (if your file is several hundred megabytes then the above method is likely to run into this problem).

If you're interested in seeing the alternative conversion method please comment and I can add examples of leveraging the pure streaming conversion APIs but the code is a bit less obvious than these examples.

like image 146
RobV Avatar answered Sep 08 '25 00:09

RobV