RDF Export, malformed file?

Nov 23, 2013 at 10:26 PM
I'm unable to export a valid RDF document with BrightstarDB. My knowledge of the RDF format is still a bit basic, but I have a feeling something is wrong here, or I'm using the wrong methods.
Client.StartExport(StoreName, "test.rdf", null);
System.Threading.Thread.Sleep(5000); //Wait for export to finish

//Attempt load with DotnetRDF
 IGraph g = new Graph();
VDS.RDF.Parsing.FileLoader.Load(g, "test/import/test.rdf");
Error: Unable to Parse this RDF/XML since System.Xml was unable to parse the document, see Inner Exception for details of the XML exception that occurred

Similarly, I am unable to import the documents into any graph viewer.

Is RDF export currently supported, or am I doing something wrong? Thank you.

Nov 23, 2013 at 10:32 PM
Hi Mark,

Are you sure the export completed ? Client.StartExport returns an IJobInfo instance that you need to use in calls to GetJobInfo() until the status is JobCompleted or JobCompletedWithErrors. If you try to read the exported file before the export job completed then you are likely to get an invalid XML file that will fail to parse.

If that isn't the problem, can you send through the complete stack trace including the inner exception, it might give a pointer as to what is wrong with the file.



Nov 23, 2013 at 10:41 PM
Even after waiting awhile with a long Thread.Sleep time, the job indicates that it is not finished, but the file does get written to disk.


Here is the export output, which is consistent every time I run it:
Nov 23, 2013 at 10:44 PM
Here is some additional exception information:

Inner exception:

{"Name cannot begin with the '/' character, hexadecimal value 0x2F. Line 1, position 7."}

at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32& colonPos)
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at VDS.RDF.Parsing.Events.RdfXml.StreamingEventGenerator.GetNextEvent()
at VDS.RDF.Parsing.Events.StreamingEventQueue`1.Dequeue()
at VDS.RDF.Parsing.RdfXmlParser.ProcessEventQueue(RdfXmlParserContext context)
at VDS.RDF.Parsing.RdfXmlParser.Parse(RdfXmlParserContext context)
at VDS.RDF.Parsing.RdfXmlParser.Load(IRdfHandler handler, TextReader input)
Nov 23, 2013 at 10:54 PM
Hi Mark,

Its obviously getting late because I missed this the first time...the export file is an N-Triples file, not an RDF/XML file. If you name your export file as test.nt and import that file then it should parse in dotNetRDF (the dotNetRDF import code you are using bases the format selection on file extension).



Marked as answer by Nuzz604 on 12/18/2013 at 1:12 AM
Nov 23, 2013 at 10:55 PM
Thank you very much. I suspected it was something like that but didn't know how to proceed. I was wondering if there was a way to export directly to RDF, or if there is a way to convert the format to RDF/XML? Thank you.
Nov 23, 2013 at 11:02 PM
NTriples is RDF, its just not an XML form of RDF, its a really simple line-oriented form that is dead easy to parse and to write. There isn't a way to select the export format right now. That feels like a bit of an oversight so I think I'll try and fix that for the next release. In the meanwhile you can always use dotNetRDF to do the conversion for you - either through code (once you have the IGraph instance you can write it out again in RDF/XML format - see https://bitbucket.org/dotnetrdf/dotnetrdf/wiki/UserGuide/Writing%20RDF), or the dotNetRDF tools includes an rdfConvert command-line tool that will do the job too.