How to draw a RDF graph

Submitted by admin on Tue, 02/11/2014 - 13:28

Here, a simple XML example inferred from image number 1 (taken from http://www.rdfabout.com/intro/).

<code>
<?xml version="1.0"?>

<rdf:RDF xmlns="http://www.w3.org/2002/07/owl#&quot;
xml:base="http://www.w3.org/2002/07/owl&quot;
xmlns:ex="http://www.example.org/&quot;
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#&quot;
xmlns:owl="http://www.w3.org/2002/07/owl#&quot;
xmlns:xsd="http://www.w3.org/2001/XMLSchema#&quot;
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;

<!--defining entities-->

<rdf:Description rdf:about="vincent_donofrio"></rdf:Description>
<rdf:Description rdf:about="law_order_criminal_intent"></rdf:Description>
<rdf:Description rdf:about="the_thirteenth"></rdf:Description>
<rdf:Description rdf:about="sex_and_the_city"></rdf:Description>
<rdf:Description rdf:about="chris_noth"></rdf:Description>
<rdf:Description rdf:about="the_thirteenth_floor"></rdf:Description>
<rdf:Description rdf:about="the_matrix"></rdf:Description>

<!-- first branch -->

<rdf:Description rdf:about="vincent_donofrio">
<ex:has_name> Vicent Donofrio</ex:has_name>
<ex:starred_in rdf:resource="law_order_criminal_intent"></ex:starred_in>
</rdf:Description>

<rdf:Description rdf:about="law_order_criminal_intent">
<ex:is_a rdf:resource="tv_show"></ex:is_a>
</rdf:Description>

<rdf:Description rdf:about="sex_and_the_city">
<ex:is_a rdf:resource="tv_show"></ex:is_a>
</rdf:Description>

<rdf:Description rdf:about="chris_noth">
<ex:starred_in rdf:resource="law_order_criminal_intent"></ex:starred_in>
<ex:starred_in rdf:resource="sex_and_the_city"></ex:starred_in>
</rdf:Description>

<!--second branch -->

<rdf:Description rdf:about="vincent_donofrio">
<ex:starred_in rdf:resource="the_thirteenth_floor">
</ex:starred_in>
</rdf:Description>

<rdf:Description rdf:about="the_thirteenth_floor">
<ex:released_in>1999</ex:released_in>
<ex:is_a>movie</ex:is_a>
</rdf:Description>

<rdf:Description rdf:about="the_matrix">
<ex:released>1999</ex:released>
<ex:is_a>movie</ex:is_a>
</rdf:Description>

<rdf:Description rdf:about="the_thirteenth_floor">
<ex:similar_plot_as rdf:resource="the_matrix"></ex:similar_plot_as>
</rdf:Description>

</rdf:RDF>

</code>

The same version under NT

<code>
<http://www.w3.org/2002/07/vincent_donofrio&gt; <http://www.example.org/starred_in&gt; <http://www.w3.org/2002/07/law_order_criminal_intent&gt; .
<http://www.w3.org/2002/07/the_thirteenth_floor&gt; <http://www.example.org/is_a&gt; "movie" .
<http://www.w3.org/2002/07/law_order_criminal_intent&gt; <http://www.example.org/is_a&gt; <http://www.w3.org/2002/07/tv_show&gt; .
<http://www.w3.org/2002/07/vincent_donofrio&gt; <http://www.example.org/starred_in&gt; <http://www.w3.org/2002/07/the_thirteenth_floor&gt; .
<http://www.w3.org/2002/07/chris_noth&gt; <http://www.example.org/starred_in&gt; <http://www.w3.org/2002/07/law_order_criminal_intent&gt; .
<http://www.w3.org/2002/07/the_thirteenth_floor&gt; <http://www.example.org/similar_plot_as&gt; <http://www.w3.org/2002/07/the_matrix&gt; .
<http://www.w3.org/2002/07/sex_and_the_city&gt; <http://www.example.org/is_a&gt; <http://www.w3.org/2002/07/tv_show&gt; .
<http://www.w3.org/2002/07/the_matrix&gt; <http://www.example.org/is_a&gt; "movie" .
<http://www.w3.org/2002/07/chris_noth&gt; <http://www.example.org/starred_in&gt; <http://www.w3.org/2002/07/sex_and_the_city&gt; .
<http://www.w3.org/2002/07/the_thirteenth_floor&gt; <http://www.example.org/released_in&gt; "1999" .
<http://www.w3.org/2002/07/the_matrix&gt; <http://www.example.org/released&gt; "1999" .
<http://www.w3.org/2002/07/vincent_donofrio&gt; <http://www.example.org/has_name&gt; " Vicent Donofrio" .
</code>

Well, if you run XML code in a tool like W3C RDF Validator

http://www.w3.org/RDF/Validator/

you will see something like image number 2

References

http://rdf-translator.appspot.com/

Etiquetas
Imagen