Create an ontology graph using dotNetRDF

88 Views Asked by At

I need to create an ontology graph using the "dotNetRDF". Exported to RDF, it should look like this:

<?xml version="1.0"?>
<rdf:RDF
    xmlns:ct="https://standards.iso.org/iso/21597/-1/ed-1/en/Container#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns="https://standards.iso.org/iso/21597/-1/ed-1/en/AnnexA/usecase1a/requirements/index#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
  xml:base="https://standards.iso.org/iso/21597/-1/ed-1/en/AnnexA/usecase1a/requirements/index">
  <owl:Ontology rdf:about="">
    <owl:imports rdf:resource="https://standards.iso.org/iso/21597/-1/ed-1/en/Container"/>
  </owl:Ontology>
  <ct:ContainerDescription rdf:ID="id9db6bd96-db11-464a-a01a-82221016fbe6">
    <ct:createdBy>
      <ct:Person rdf:ID="id0b80ea4e-eba1-481f-bc97-309c0de355b9">
        <ct:creationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2018-05-28T14:13:28.167</ct:creationDate>
        <ct:name>Nomen Nescio</ct:name>
        <ct:description>Works at S.A.</ct:description>
        <ct:createdBy rdf:resource="#id0b80ea4e-eba1-481f-bc97-309c0de355b9"/>
      </ct:Person>
    </ct:createdBy>
    <ct:containsDocument>
      <ct:InternalDocument rdf:ID="id9f01cef7-8939-4ee4-ac88-27d49df430c3">
        <ct:versionID>1</ct:versionID>
        <ct:filename>48D-100.ifc</ct:filename>
        <ct:requested rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</ct:requested>
        <ct:description>An IFC/BIM model of viaduct Asset 48D-100</ct:description>
        <ct:creationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2018-05-28T14:13:28.167</ct:creationDate>
        <ct:name>48D-100.IFC</ct:name>
        <ct:versionDescription>first version</ct:versionDescription>
        <ct:createdBy rdf:resource="#id0b80ea4e-eba1-481f-bc97-309c0de355b9"/>
        <ct:filetype>ifc</ct:filetype>
      </ct:InternalDocument>
    </ct:containsDocument>
    <ct:description>icdd showcase 1a:  Requirements container</ct:description>
    <ct:conformanceIndicator>ICDD-Part1-Container</ct:conformanceIndicator>
    <ct:versionID>1</ct:versionID>
  </ct:ContainerDescription>
</rdf:RDF>

This is the index file of an ICDD container. Sure I could create it as simple xml, but "dotNetRdf" can export graph to various formats lile RDF, OWL, etc. This is a big advantage. But I have no clue how to re-create such structure in c#. API documentation offers just a few lines of code which actually do not explain anything. I see classes like "OntologyGraph", or "OntologyHelper", but do not see how to use those for creating such graphs.

For instance, I'm trying this:

var o = new OntologyGraph();
var ontology = o.CreateOntologyClass(UriFactory.Create(OntologyHelper.OwlOntology));
RdfXmlWriter rdfxmlwriter = new RdfXmlWriter();
String data = VDS.RDF.Writing.StringWriter.Write(o, rdfxmlwriter);
Console.WriteLine(data);

As the result I expect a document with node "owl:Ontology", but the actual result is an empty document:

<?xml version="1.0" encoding="utf-16"?>
<!DOCTYPE rdf:RDF [
<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
<!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>
<!ENTITY owl 'http://www.w3.org/2002/07/owl#'>
]>
<rdf:RDF
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" 
xmlns:owl="http://www.w3.org/2002/07/owl#" 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />

I beg for some examples! Please show me how to create just a few different kinds of nodes from my example, and I'll do the rest.

Thanks in advance!

0

There are 0 best solutions below