[redland] Fwd: example librdf wrapping
James Michael DuPont
mdupont777 at yahoo.com
Mon Dec 9 01:03:38 GMT 2002
Dear Redland users,
I have converted the php example into a debian package,
Had to take the goodies out of the Makefile.am,
it did not fit into the debian framework. Got the whole thing linking
and installing fine.
had to add this to the ini file
/etc/php4/cgi/php.ini
extension=libphp4-redland.so
to make it load.
Now I just have a question about the files, and then we are on our way.
mike
--- James Michael DuPont <mdupont777 at yahoo.com> wrote:
> From James Michael DuPont Sun Dec 8 23:54:06 2002
> Received: from [80.128.233.116] by web13301.mail.yahoo.com via HTTP;
> Sun, 08 Dec 2002 23:54:06 PST
> Date: Sun, 8 Dec 2002 23:54:06 -0800 (PST)
> From: James Michael DuPont <mdupont777 at yahoo.com>
> Subject: example librdf wrapping
> To: swig-dev at cs.uchicago.edu
> MIME-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Content-Length: 1132
>
> Dear all,
>
> I have here an example php4 debian plugin for php4/swig
>
http://introspector.sourceforge.net/debian/incoming/php4-redland_0.1.dsc
>
> based on the Redland/swig php. works great
>
> Only problem is with filehandles :
> the code generated is this
> if(SWIG_ConvertPtr(*args[1-argbase], (void **) &arg2,
> SWIGTYPE_p_FILE) < 0) {
> zend_error(E_ERROR, "Type error in argument %d of
> librdf_serializer_serialize_model. Expected %s", 2-argbase,
> SWIGTYPE_p_FILE->name);
> }
>
> I call it like this:
> $fp = fopen("./output.rdf", "w");
> librdf_serializer_serialize_model($pserializer, $fp, NULL,
> $pmodel);
> librdf_free_serializer($pserializer);
>
> It does not like the parameter :
> Fatal error: Type error in argument 2 of
> librdf_serializer_serialize_model. Expected _p_FILE in
>
/mnt/hda4/development/development2/redland-cvs/redland/librdf/php4-redland-0.1/test_redland.php
> on line.
>
> here is the example code
> #! /usr/bin/php4 -f
> <?
> $y = phpinfo();
>
> global $REDLAND_LOADED__;
> if ($REDLAND_LOADED__) return;
> $REDLAND_LOADED__ = true;
>
> /* if our extension has not been loaded, do what we can */
> /*
> not needed,added to the ini file
> /etc/php4/cgi/php.ini
> extension=libphp4-redland.so
>
> if (!extension_loaded("libphp4-redland")) {
> if (!dl("libphp4-redland.so")) return;
> }
> */
>
>
> $x = librdf_new_world();
> librdf_world_open($x);
> $storage=librdf_new_storage($x,
> "hashes", "test",
> "new='yes',hash-type='bdb',dir='.'");
> $pmodel=librdf_new_model($x, $storage, NULL);
>
>
>
> $pobject= librdf_new_node_from_literal($x,
> "test", 0,0);
> $ppredicate= librdf_new_node_from_literal($x,
> "doit",0, 0);
> $psubject= librdf_new_node_from_literal($x,
> "id-1",0, 0);
>
> $pstatement=librdf_new_statement($x);
>
> librdf_statement_set_subject($pstatement,$psubject); // the current
> object
> librdf_statement_set_predicate($pstatement,$ppredicate); // the uri
> passed
> librdf_statement_set_object($pstatement,$pobject); // the
> object passed
>
> $uri =librdf_new_uri($x,"file:./test.n3");
>
> librdf_model_add_statement($pmodel, $pstatement); // book'
> em
>
> $pserializer=librdf_new_serializer($x, "ntriples", NULL, $uri);
>
> $fp = fopen("./output.rdf", "w");
> librdf_serializer_serialize_model($pserializer, $fp, NULL,
> $pmodel);
> librdf_free_serializer($pserializer);
>
> ?>
=====
James Michael DuPont
http://introspector.sourceforge.net/
More information about the redland-dev
mailing list