[redland-dev] parse "ntriple" string into model error

Dave Beckett dave at dajobe.org
Mon Jun 19 05:00:53 BST 2006


Wang GuiLing wrote:
> I want to parse a ntriple file into Redland model in .net platform using
> redland dotnet binding API like this. But It doesn't work.  I don't know
> why?
> 
> As for the "rdfxml" file, it can work.
> 
> How can I parse ntriple string into a Redland model?
> 
> Thank you in advance!
>
> String lang = null;
> schemaFileName = "dc.nt";
> Redland.Storage storage = new Storage("memory", "test", null);
> Redland.Model model = new Model(storage);
> StreamReader sr = File.OpenText(schemaFileName);
> String s = sr.ReadToEnd();            
> if (schemaFileName.EndsWith(".nt"))
>       lang = "ntriples";
> else if (schemaFileName.EndsWith(".rdf"))
>       lang = "rdfxml";
> else if (schemaFileName.EndsWith(".ttl"))
>      lang = "turtle";                       
> Redland.Uri baseuri = new Redland.Uri("http://xx/xx#");
> Redland.Parser parser = new Parser(lang);          
> parser.ParseStringIntoModel(s, baseuri, model);

Looks like there was a bug in the single-argument Parser() constructor,
so Parser(lang) always gets the wrong answer.  You should be able to use:
   Parser(lang, null, null)
in the released software to get the "ntriples" or any other parser.

I've commited a fix to SVN csharp file Parser.cs to make the single
argument form work in:
 http://svn.librdf.org/view/bindings/trunk/csharp/Parser.cs?rev=10985&view=log

Dave






More information about the redland-dev mailing list