mdesalvo/RDFSharp

How to ouput rdf to a ttl file in an appropriate order from graph

koroce opened this issue · 1 comments

Hello,

I added some triples in a graph and call its toFile mothod with param "Turtle".

However, the order of triples in ttl file seems not suitable.

How can I output in correct order, e.g. the rdf:type located at the front

Thanks

`

foreach(var i in Industries)
{
graph.AddTriple(new RDFTriple(new RDFResource(s + Util.ParseStr(i.Name)),
new RDFResource(rdf + "type"),
new RDFResource(s + "indus")));
graph.AddTriple(new RDFTriple(new RDFResource(s + Util.ParseStr(i.Name)),
new RDFResource(s + i.SampleSizeSmall.Key),
new RDFTypedLiteral(i.SampleSizeSmall.Value.ToString(), RDFModelEnums.RDFDatatypes.XSD_INTEGER)));
graph.AddTriple(new RDFTriple(new RDFResource(s + Util.ParseStr(i.Name)),
new RDFResource(s + i.SampleSizeLarge.Key),
new RDFTypedLiteral(i.SampleSizeLarge.Value.ToString(), RDFModelEnums.RDFDatatypes.XSD_INTEGER)));
}

`

Here is the rdfs
s:AllIndustries s:sampleSizeOfLargeCompany "7181"^^xsd:integer;
s:sampleSizeOfSmallCompany "10442"^^xsd:integer;
a s:indus.

s:ArtsEntertainmentAndRecreation s:sampleSizeOfLargeCompany "303"^^xsd:integer;
s:sampleSizeOfSmallCompany "415"^^xsd:integer;
a s:indus.

s:Construction s:sampleSizeOfLargeCompany "312"^^xsd:integer;
s:sampleSizeOfSmallCompany "722"^^xsd:integer;
a s:indus.

s:Education s:sampleSizeOfLargeCompany "457"^^xsd:integer;
s:sampleSizeOfSmallCompany "303"^^xsd:integer;
a s:indus.

s:indus a owl:Class.

Hi,
Turtle emits the triples ordered by subject and then by predicate using their full Uris (not the shortened ones, like "s:" or "a", which are calculated later at printing). I can't see in your example the full Uri being shortened as "s:", anyway this means that it comes before http://www.w3.org/1999/02/22-rdf-syntax-ns#type (which is the full Uri of the "a" syntactical shortcut).

Regards,
Marco