What is a good RDF library for .net?

kitsune picture kitsune · Oct 27, 2008 · Viewed 13.3k times · Source

I'm looking for a library that can deal with RDF and OWL data.

So far I have found:

  • semweb (no owl support for all I know)
  • rowlex (more of a 'browser' application)

Your recommendations:

Answer

Mr. Lame picture Mr. Lame · Feb 13, 2009

ROWLEX is actually very cool (uses SemWeb internally). It is not just a browser app but rather an SDK written in C#. If you use ROWLEX, you do not directly interact with the tripples of RDF anymore (though you can), but gives an object oriented look&feel. There are two main usage scenarios:

  1. Business class first: You have your .NET business classes. You declaratively add attributes to your classes similarly as you do with XML serialization attributes. After this, ROWLEX can extract the ontology corresponding your business classes and/or can serialize your business objects into RDF.
  2. Ontology first: You have your ontology(s) and ROWLEX generates .NET classes for you that you can use to build/browse RDF documents. The great thing is that these autogenerated classes are far better then the typical results of codegenerators. They are comfortable to use and mimic the multiple inheritence feature of OWL by providing implicit and explicit cast operators to cover the entire inheritence graph.

The typical usage is the Ontology first approach. For example, let us say that your ontology describes the following multiple inheritence scenario:

Car isSubClassOf Vehicle

Car isSubClassOf CompanyAsset

Using ROWLEX, you will get .NET classes for Car, Vehicle, and CompanyAsset. The following C# code will compile without any problem:

    RdfDocument rdfDoc = new RdfDocument();
    Car car = new Car("myCarUri", rdfDoc);
    Vehicle vehicle = car; // implicit casting
    CompanyAsset companyAsset = car; // implicit casting 
    vehicle.WheelCount = 4;
    companyAsset.MonetaryValue = 15000;
    Console.WriteLine(rdfDoc.ToN3());

This would print:

myCarUri typeOf Car 
myCarUri WheelCount 4 
myCarUri MonetaryValue 15000

The "car" business object is represented inside the RdfDocument as triples. The autogenerated C#/VB classes behave as a views. You can have several C# views - each of a completely different type - on the same business object. When you interact with these views, you actually modifying the RdfDocument.