0

I'm trying to create RDF/XML from below RDF graph. I understand the basic concepts, like Subject/Predicate/Object, Resource, Property, Value/Literal, and based on same, I created an RDF graph.

But I want to know how to translate (convert) the same graph into RDF/XML format? Is there any tool where I generate RDF graph and it will produce RDF/XML?

I'm using Jena, since I have familiarity with Java.

graph

unor
  • 92,415
  • 26
  • 211
  • 360
Viki
  • 107
  • 1
  • 8
  • It's not exactly clear what you're asking. Jena has an API for creating resources, triples, etc., and serializing the graph as RDF/XML. Did something not work about it? – Joshua Taylor Jun 20 '16 at 13:19
  • I was actually looking for some tool which takes graph as an input and generates it's RDF/XML. A tool where I can design/create the graph and it gives me graph's RDF/XML. – Viki Jun 21 '16 at 04:07
  • Note that *"Questions asking us to recommend or find a book, **tool**, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. [...]"* Tool recommendations also have the problem that answers tend to get outdated. What might be a good tool today might not even exist in a year or two from now. – Joshua Taylor Jun 21 '16 at 11:25
  • @JoshuaTaylor: Agreed. – Viki Jun 22 '16 at 04:00

2 Answers2

0

You didn't mention how you created the graph that you've shown an image of. If you're creating it programmatically, you can do the same using the Jena API: just create a model, create resources and add properties. The Javadocs for Jena are pretty thorough, and the Jena website has some tutorials.

In this case, however, I think the easiest course of action is to just write the graph using a human-readable-writable format like Turtle, and then to use Jena or another library to convert that to RDF/XML. In this case, you could write something like:

@prefix : <urn:ex:>

:JavaClass :belongsTo :Domain1, :Domain2, :DomainN ;
           :hasMethod :Method1, :Method2, :MethodN .

If you're programmatically generating that, you might use a less abbreviated form, like:

<urn:ex:JavaClass> <urn:ex:belongsTo> <urn:ex:Domain1> .
<urn:ex:JavaClass> <urn:ex:belongsTo> <urn:ex:Domain2> .
<urn:ex:JavaClass> <urn:ex:belongsTo> <urn:ex:DomainN> .
<urn:ex:JavaClass> <urn:ex:hasMethod> <urn:ex:Method1> .
<urn:ex:JavaClass> <urn:ex:hasMethod> <urn:ex:Method2> .
<urn:ex:JavaClass> <urn:ex:hasMethod> <urn:ex:MethodN> .

In either case, you can use any number of tools to convert that into RDF/XML. E.g., with the rdfcat command line utility that comes with Jena, you could just do:

$ rdfcat -out RDF/XML-ABBREV data.n3
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="urn:ex:">
  <rdf:Description rdf:about="urn:ex:JavaClass">
    <belongsTo rdf:resource="urn:ex:Domain1"/>
    <belongsTo rdf:resource="urn:ex:Domain2"/>
    <belongsTo rdf:resource="urn:ex:DomainN"/>
    <hasMethod rdf:resource="urn:ex:Method1"/>
    <hasMethod rdf:resource="urn:ex:Method2"/>
    <hasMethod rdf:resource="urn:ex:MethodN"/>
  </rdf:Description>
</rdf:RDF>
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Thank you Joshua for your reply. I created graph based on my concepts using Word. Actually, I was looking for some tool which allows the creation of graph (which I did in Word) and then gives (output) graph's RDF/XML. But your suggestions are equally Ok, to use Turtle (however, I'm not familiar with it). I've generated the required RDF/XML from Jena. Comments length do not allowing to copy RDF/XML here, therefore, I've uploaded at below URL. Please have a look and tell if this RDF/XML is confirming the graph I shared in first post. Many thanks! http://i65.tinypic.com/ta4f49.png – Viki Jun 21 '16 at 04:05
0

However, I didn't find any tool which generates RDF/XML against the given graph. But, I found the graph display on https://www.w3.org/RDF/Validator/ very much helpful. It takes RDF/XML as an input, validates it, and then generate graph and triples. In my case, I'm using JENA to create RDF/XML and then I use W3C Validator to view in graph format. This is equally helpful in my case.

Viki
  • 107
  • 1
  • 8