Next: , Previous: , Up: Top   [Contents][Index]

15 Serialization to (S)XML

The (webid-oidc serializable) module provides tools to have serialization to SXML and deserialization from XML.

Class: <plugin-class> (<class>) module-name direct-name

This metaclass permits to register plugins. module-name is the name of a module that defines the class, and direct-name is the class name without the surrounding angle brackets. Please note that all plugin classes should be surrounded by angle brackets.

Most GOOPS classes defined in this program are actually plugin classes.

Serialization works for each slot by serializing other plugin classes the normal way, and other values are simply represented as strings with display.

Deserialization works by loading the module containing the target class, collecting a value for each slot (a string for non-plugin-class-valued slots), and making an instance of that class with all collected values. The initialization function should accept strings values, for objects that are not of a plugin class.

Since most scheme data types written by display cannot be read in a meaningful way, you may add a #:->sxml slot option with a function taking the slot value and either returning a string that the initialization function can parse, or an SXML fragment. For instance, if a slot should contain an URI value, you would pass #:->sxml uri->string as options to the slot definition, and accept a string value in the initialization function, that you would convert to an URI with string->uri.

Sometimes slots contain functional data that cannot be serialized. In this case, pass #:->sxml 'ignore to avoid serialization.

function: read/xml port

Read the XML document at port and deserialize it.

function: ->sxml object

Convert object to an SXML fragment.

Next: , Previous: , Up: Top   [Contents][Index]