hide all comments

results

getting rid of XML

November 13, 2008 16:45:49 +0100 (CET)

We’ve used XML Methods in seaBreeze for a lot of stuff, most of all for the #windowSpec methods. The biggest problem with these methods were those awful hacks to the parser. I think those hacks are the main reason why seaBreeze couldn’t easily be ported to Squeak.

The last couple days I’ve worked on changing the XML representation to a more smalltalk like representation. The objects are now stored as literal arrays. It doesn’t look pretty but compared to XML it’s much simpler to work with.

The encoding and decoding is a bit different to the normal literal array approach though. In VisualWorks a class needs to implement #literalArrayEncoding or #decodeFromLiteralArray:. I wanted a more general solution and did the same that I did for the previous XML representation: simple literal array representation - slar. The idea is that an object just needs to return an array of symbols. These symbols can be used to access the required properties of the object. With this information the object is converted into a literal array and back.

The resulting literal arrays look a bit like lisp with hashes:

#( #slar 'SeaBreeze.SBSubmitButton'
    #( #positioning #( #slar 'SeaBreeze.SBPositioning'
            #( #positioningType #absolute )
            #( #layout #( #slar 'SeaBreeze.SBLayout'
                    #( #leftOffset 255 )
                    #( #topOffset 20 )
                 ) )
         ) )
    )

The #slar symbol at the beginning of the array tells the array that it has a complex object encoded via simple literal array representation. The string with the name of the class is the second object in the array. Starting with the third object there’s an array for each property of the encoded object. The first object of this subarray is the name of the property and the second object is the literal representing this property. If this object is no literal it is automatically converted.

Karsten

posted by Karsten Kusche