[redland-dev] setting parser feature through ruby api

Eyal Oren eyal.oren at deri.org
Fri Dec 8 12:08:27 UTC 2006


On 12/08/06/12/06 00:10 -0800, Dave Beckett wrote:
>> Calling model.to_string('ntriples'), which should have worked according
>> to the docs [1] didn't actually work.
>
>The example.rb example script for ruby contains:
>
>size=model.to_string(name="ntriples",
>base_uri=Redland::Uri.new("http://example.org/base#")).length()
maybe my installation is messed up, but I get "undefined method `to_string' 
for #<Redland::Model:0xb7118444>", when trying model.to_string.
same problem when running your example.rb. 

But I got it to work with a serialiser:	triples = 
Redland::Serializer.ntriples.model_to_string(nil, model), so everything is 
fine for me.

Now for enabling the scanning feature, I'm trying the following:
model = Redland::Model.new
parser = Redland::Parser.new('rdfxml')
scan = Redland::Uri.new('http://feature.librdf.org/raptor-scanForRDF') 
enable = Redland::Literal.new('1')
parser.feature = (scan, enable)

but that's not valid Ruby

Also tried
Redland::librdf_parser_set_feature(parser, scan.uri, enable.node)
but that doesn't work (argument 1 of type 'librdf_parser *' (TypeError))
and Redland::librdf_parser_set_feature(parser.parser, scan.uri, 
enable.node) doesnt work either.

So how do I pass the feature to the parser exactly? And how do I enable 
guessing parsing: I know the command line switch, but how do I pass it over 
the Ruby API?
	
By the way, rapper is really cool, thanks for the great and fast parser!

 -eyal


More information about the redland-dev mailing list