[redland-dev] Serializing models

Jorge Santos jorge.jsf at gmail.com
Mon Aug 15 22:15:54 BST 2005


Hello, I'm looking into returning a string representing a rdf/xml
representation of a model using the Ruby bindings and I have found a
couple odd thins:

1.  There is no wrapper for the librdf_model_to_string () function.  I
wrote a simple wrapper for this:

    # return the model serialized
    # base_uri -  base URI to use in serializing
    # name -  the name of the serializer
    # mime_type -  the MIME type of the syntax
    # type_uri -  URI of the syntax
    def to_s(base_uri=nil,name="",mime_type="application/rdf+xml",type_uri=nil)
      serializer
      return Redland.librdf_model_to_string(self.model,base_uri,name,mime_type,type_uri)
    end

2.  What's with librdf_model_to_counted_string () anyway?  What's the
use of knowing the length of the string?

3.  The initialize function for Redland::Serializer starts like so:

    # Constructor - create a new Serializer object
    # name -  the serializer factory name
    # mime_type -  the MIME type of the syntax
    # uri -  URI of syntax
    def initialize(name="",mime_type="application/rdf+xml",uri=nil)

But  in model.rb you can read:

    # saves this model to the specified filename
    def save(filename)
      serializer = Serializer.new(filename)

So what's the deal with passing the serializer the filename?

4.  So what's the deal with having the Serializer, why aren't all its
functions in Model (as many of them seem to be)?

Well, that's all I can think now, cheers,
Jorge


More information about the redland-dev mailing list