Generix XML marshaller

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Generix XML marshaller

Charles A. Monteiro-2
Is SIXX the only generic XML marshaller available?

I see that there has not been any activity for a while apparently. Maybe  
it is stable though. I just want something that I can pretty much just do:

        anObject storeAsXmlString "saving"
        aString asObjectFromXml "reading"

        etc ...

tia,

--
Charles A. Monteiro

Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

Magnus Jakt
Charles A. Monteiro wrote:
> Is SIXX the only generic XML marshaller available?
>
> I see that there has not been any activity for a while apparently.
> Maybe  it is stable though. I just want something that I can pretty much
> just do:
>
>     anObject storeAsXmlString "saving"
>     aString asObjectFromXml "reading"

You might want to have a look at this (found in the public repository):

http://www.cincomsmalltalk.com/CincomSmalltalkWiki/XML+Configuration+Files

Seems to work fairly well for objects that are not too complex.

/Magnus

>     etc ...
>
> tia,
>

--
Magnus Jakt
email: [hidden email]
web: http://magnus.jakt.org.uk
phone: +49 231 86 28 759

       
       
               
___________________________________________________________
Win tickets to the 2006 FIFA World Cup Germany with Yahoo! Messenger. http://advision.webevents.yahoo.com/fifaworldcup_uk/


Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

Charles A. Monteiro-2
yes, I don't believe it can handle recreation of object references

On Fri, 28 Apr 2006 12:16:40 -0400, Magnus Jakt <[hidden email]> wrote:

> Charles A. Monteiro wrote:
>> Is SIXX the only generic XML marshaller available?
>>  I see that there has not been any activity for a while apparently.  
>> Maybe  it is stable though. I just want something that I can pretty  
>> much just do:
>>      anObject storeAsXmlString "saving"
>>     aString asObjectFromXml "reading"
>
> You might want to have a look at this (found in the public repository):
>
> http://www.cincomsmalltalk.com/CincomSmalltalkWiki/XML+Configuration+Files
>
> Seems to work fairly well for objects that are not too complex.
>
> /Magnus
>
>>     etc ...
>>  tia,
>>
>



--
Charles A. Monteiro

Reply | Threaded
Open this post in threaded view
|

R: Generix XML marshaller

Giorgio Ferraris
Hi, Charles,

I don't know if this can help. I have a "generic xml marshaler" I built long
before the xml stuff come up on the dialects.
I'ts pretty easy, and based to an open surce Dolphin parser (SAX type) that
was available long time ago.
I don't know what do you mean exactly for generic, so I'll try to explain
what I do (I use it for sending object between different smalltalk images,
of different dialect, in particular is the medium I use for communicate
between my VSE gui for HOP, my O/R mapping, and the VW image, but I used it
on dolphin too, lon ago)

Prerequisite: the classes should be defined on both images (images can be
different language, as said before).

There is a method in object :

asXmlString

    | stream |
    stream := WriteStream on: (String new: 30).
    self beforeXmlConversion.
    self addXmlStringTo: stream.
    self afterXmlRebuilt.
    ^stream contents.

This is the marshaling method.

This method has two hooks:
beforeXmlConversion and afterXmlRebuilt.

You can reimplement it if you need. The meaning is: if I have to send an
object, and this object has computed (derived) state, I usually clear this
state (reducing the amount of bytes, amount that is already big enough) on
before XMlConversion, and rebuild the state on afterXmlRebuild.

As you can guess, there is a corrsponding method for getting back the
object, this time in string:

objectFromXmlString

    | anObject |
        anObject := XmlElevenApplication new
            parse: (ReadStream on: self);
            getObject.
    anObject afterXmlRebuilt.
    ^anObject.

And this method, obviously, call afterXmlRebuild for giving you the real
object with all of the rebuilt data.

I manage object references when rebuilding the obgiect on the unmarshaling
phase ( I remember that, when I developed it, I was surprise that on the web
and on the magazines, no one, never in java, was talking about recreating
references, but it was so many years ago...
My implementation is not standard in any way , but it works. For what I
know, there should be some standard for references, but I never followed it,
my system worked for my job, and this was enough)
Another non standard feature I remember is that I had to choose I format for
sending Data, and so I use my, that is not the one XML support ( I send Data
as DD/MM/YYYY).
I have some doubth about time stamp, probably I don't have support for this
(never used).

There is also no documentation, and few tests (I was starting at that time
using SUnit heavily)

There are also no assurance about the correct functionality of this stuff
:)

If, after all of this words, you are still interested, I have no problems to
sending you the parcels an helping you a bit to having it running on your
machine.
I have it running on a 7.3.1

If you look at it and think it could be usefull, I can load it on public
store for other people to use (if someone is interested)

Remember, it don't use the XML stuff on VW and I don't know if it's fast...,
and I don't use namespace, because I have to support it on other smalltalk
dialects (notably VSE)

Ciao

Giorgio

-----Messaggio originale-----
Da: Charles A. Monteiro [mailto:[hidden email]]
Inviato: venerdì 28 aprile 2006 20.08
A: Magnus Jakt
Cc: [hidden email]
Oggetto: Re: Generix XML marshaller

yes, I don't believe it can handle recreation of object references

On Fri, 28 Apr 2006 12:16:40 -0400, Magnus Jakt <[hidden email]> wrote:

> Charles A. Monteiro wrote:
>> Is SIXX the only generic XML marshaller available?
>>  I see that there has not been any activity for a while apparently.  
>> Maybe  it is stable though. I just want something that I can pretty  
>> much just do:
>>      anObject storeAsXmlString "saving"
>>     aString asObjectFromXml "reading"
>
> You might want to have a look at this (found in the public repository):
>
> http://www.cincomsmalltalk.com/CincomSmalltalkWiki/XML+Configuration+Files
>
> Seems to work fairly well for objects that are not too complex.
>
> /Magnus
>
>>     etc ...
>>  tia,
>>
>



--
Charles A. Monteiro


Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

stéphane ducasse-2
In reply to this post by Magnus Jakt

On 28 avr. 06, at 18:16, Magnus Jakt wrote:

> Charles A. Monteiro wrote:
>> Is SIXX the only generic XML marshaller available?
>> I see that there has not been any activity for a while apparently.  
>> Maybe  it is stable though. I just want something that I can  
>> pretty much just do:
>>     anObject storeAsXmlString "saving"
>>     aString asObjectFromXml "reading"
>
> You might want to have a look at this (found in the public  
> repository):
>
> http://www.cincomsmalltalk.com/CincomSmalltalkWiki/XML+Configuration 
> +Files
>
> Seems to work fairly well for objects that are not too complex.

Which means?
Does it handle references between objects?

Stef

>
> /Magnus
>
>>     etc ...
>> tia,
>
> --
> Magnus Jakt
> email: [hidden email]
> web: http://magnus.jakt.org.uk
> phone: +49 231 86 28 759
>
>
>
>
> ___________________________________________________________ Win  
> tickets to the 2006 FIFA World Cup Germany with Yahoo! Messenger.  
> http://advision.webevents.yahoo.com/fifaworldcup_uk/
>

Reply | Threaded
Open this post in threaded view
|

Re: R: Generix XML marshaller

stéphane ducasse-2
In reply to this post by Giorgio Ferraris
Ideally I would like to be able to specify what are the iv (or not  
derived fields) that should be serialized,
then depending on their type (date, text)...the serializer should  
serialize them.

I was planning to start doing something based on magritte or MOF so  
that I could describe
my object and get them serialized.

Can you explain a bit more your solution?

Stef


On 28 avr. 06, at 23:29, Giorgio Ferraris wrote:

> Hi, Charles,
>
> I don't know if this can help. I have a "generic xml marshaler" I  
> built long
> before the xml stuff come up on the dialects.
> I'ts pretty easy, and based to an open surce Dolphin parser (SAX  
> type) that
> was available long time ago.
> I don't know what do you mean exactly for generic, so I'll try to  
> explain
> what I do (I use it for sending object between different smalltalk  
> images,
> of different dialect, in particular is the medium I use for  
> communicate
> between my VSE gui for HOP, my O/R mapping, and the VW image, but I  
> used it
> on dolphin too, lon ago)
>
> Prerequisite: the classes should be defined on both images (images  
> can be
> different language, as said before).
>
> There is a method in object :
>
> asXmlString
>
>     | stream |
>     stream := WriteStream on: (String new: 30).
>     self beforeXmlConversion.
>     self addXmlStringTo: stream.
>     self afterXmlRebuilt.
>     ^stream contents.
>
> This is the marshaling method.
>
> This method has two hooks:
> beforeXmlConversion and afterXmlRebuilt.
>
> You can reimplement it if you need. The meaning is: if I have to  
> send an
> object, and this object has computed (derived) state, I usually  
> clear this
> state (reducing the amount of bytes, amount that is already big  
> enough) on
> before XMlConversion, and rebuild the state on afterXmlRebuild.
>
> As you can guess, there is a corrsponding method for getting back the
> object, this time in string:
>
> objectFromXmlString
>
>     | anObject |
> anObject := XmlElevenApplication new
>             parse: (ReadStream on: self);
>             getObject.
>     anObject afterXmlRebuilt.
>     ^anObject.
>
> And this method, obviously, call afterXmlRebuild for giving you the  
> real
> object with all of the rebuilt data.
>
> I manage object references when rebuilding the obgiect on the  
> unmarshaling
> phase ( I remember that, when I developed it, I was surprise that  
> on the web
> and on the magazines, no one, never in java, was talking about  
> recreating
> references, but it was so many years ago...
> My implementation is not standard in any way , but it works. For  
> what I
> know, there should be some standard for references, but I never  
> followed it,
> my system worked for my job, and this was enough)
> Another non standard feature I remember is that I had to choose I  
> format for
> sending Data, and so I use my, that is not the one XML support ( I  
> send Data
> as DD/MM/YYYY).
> I have some doubth about time stamp, probably I don't have support  
> for this
> (never used).
>
> There is also no documentation, and few tests (I was starting at  
> that time
> using SUnit heavily)
>
> There are also no assurance about the correct functionality of this  
> stuff
> :)
>
> If, after all of this words, you are still interested, I have no  
> problems to
> sending you the parcels an helping you a bit to having it running  
> on your
> machine.
> I have it running on a 7.3.1
>
> If you look at it and think it could be usefull, I can load it on  
> public
> store for other people to use (if someone is interested)
>
> Remember, it don't use the XML stuff on VW and I don't know if it's  
> fast...,
> and I don't use namespace, because I have to support it on other  
> smalltalk
> dialects (notably VSE)
>
> Ciao
>
> Giorgio
>
> -----Messaggio originale-----
> Da: Charles A. Monteiro [mailto:[hidden email]]
> Inviato: venerdì 28 aprile 2006 20.08
> A: Magnus Jakt
> Cc: [hidden email]
> Oggetto: Re: Generix XML marshaller
>
> yes, I don't believe it can handle recreation of object references
>
> On Fri, 28 Apr 2006 12:16:40 -0400, Magnus Jakt  
> <[hidden email]> wrote:
>
>> Charles A. Monteiro wrote:
>>> Is SIXX the only generic XML marshaller available?
>>>  I see that there has not been any activity for a while apparently.
>>> Maybe  it is stable though. I just want something that I can pretty
>>> much just do:
>>>      anObject storeAsXmlString "saving"
>>>     aString asObjectFromXml "reading"
>>
>> You might want to have a look at this (found in the public  
>> repository):
>>
>> http://www.cincomsmalltalk.com/CincomSmalltalkWiki/XML 
>> +Configuration+Files
>>
>> Seems to work fairly well for objects that are not too complex.
>>
>> /Magnus
>>
>>>     etc ...
>>>  tia,
>>>
>>
>
>
>
> --
> Charles A. Monteiro
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

stéphane ducasse-2
In reply to this post by Charles A. Monteiro-2
Did you look at SRP?

We used Sixx for the first version of Smallwiki but now I would  
prefer to have a textual representation of the objects and not a Boss
with xml tag around.

Stef
On 28 avr. 06, at 18:59, Charles A. Monteiro wrote:

> Is SIXX the only generic XML marshaller available?
>
> I see that there has not been any activity for a while apparently.  
> Maybe it is stable though. I just want something that I can pretty  
> much just do:
>
> anObject storeAsXmlString "saving"
> aString asObjectFromXml "reading"
>
> etc ...
>
> tia,
>
> --
> Charles A. Monteiro
>

Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

Nicolas Cellier-3
Le Samedi 29 Avril 2006 11:42, stéphane ducasse a écrit :

> Did you look at SRP?
>
> We used Sixx for the first version of Smallwiki but now I would
> prefer to have a textual representation of the objects and not a Boss
> with xml tag around.
>
> Stef
>
> On 28 avr. 06, at 18:59, Charles A. Monteiro wrote:
> > Is SIXX the only generic XML marshaller available?
> >
> > I see that there has not been any activity for a while apparently.
> > Maybe it is stable though. I just want something that I can pretty
> > much just do:
> >
> >  anObject storeAsXmlString "saving"
> >  aString asObjectFromXml "reading"
> >
> >  etc ...
> >
> > tia,
> >
> > --
> > Charles A. Monteiro

In my opinion, these xml are not that readable.
General solution i implemented is to have some Smalltalk code written to
reconstruct the objects, and rely on our nice class-message passing
mechanism.

Simple objects (literals, 1@2, ColorValue blue, etc...) are stored with simple
Smalltalk message, the storeOn: way.
Complex objects are stored using environnement variables (aTextEditor1 :=
TextEditor new.), with some kind of IdentityDictionary service, the cycles
are easily stored and retrieved.
I have a class achieving that kind of service, based on using the ProgramNode
to write well formatted code.

Well known constant objects can naturally be saved with a reference (ClassName
constantMessage), instead of putting a copy.
Code is split in small chunks because Smalltalk would not compile a 200kByte
method, this is also more efficient.

This solution is very interesting if you have Smalltalk-only application,
because passing a few messages, you can have complex object tree
reconstructed.
You also expose only the public interface, not the implementation-dependent
internal variables.
You only have to write a few storeOn: like methods in your app strategic
classes.
This lead to really readable code, and can be used for other purposes (like
Transcripting user actions on an interface into Smalltalk code).

Message passing is also a superior solution to handle versionning.
Handling compatibility messages of a public interface is easier than the BOSS
versionning for example.

So the two essentials services to be used are:
- class variables and (public interface) message passing
- environment variables to handle cycles gracefully

If xml can handle that in a neutral syntax, i say OK.

But if you have no foreign app, then why bother ?
Smalltalk is far superior in readability...

If anyone is interested, i will publish the code.

Nicolas

Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

Cesar Rabak
nicolas cellier escreveu:
> Le Samedi 29 Avril 2006 11:42, stéphane ducasse a écrit :
[snipped]

>
> But if you have no foreign app, then why bother ?
> Smalltalk is far superior in readability...
>
> If anyone is interested, i will publish the code.
>
Nicolas,

I'm interested.

--
Cesar Rabak
GNU/Linux User 52247.
Get counted: http://counter.li.org/

Reply | Threaded
Open this post in threaded view
|

R: R: Generix XML marshaller

Giorgio Ferraris
In reply to this post by stéphane ducasse-2

Hi, Stephan,

 

I don't use an external metamodel for serializing, and almost everything is done thru reflection.

On  the Object>>asXmlString method before described, the workhorse is addXmlStringTo: aStream, here is it:

 

addXmlStringTo: aStream

    "resolver mantains object translated, for avoiding recursive call

    (some object on the tree can matain reference with some other object

    on the same tree, causing infinite recursion"

 

    | resolver |

 

    resolver := XmlObjectResolver new.

    resolver add: self.

    aStream nextPutAll:( self xmlClassName,self xmlParameters) asXmlTag.

    self addXmlElementsTo: aStream resolver: resolver.

    aStream nextPutAll: self xmlClassName asXmlEndTag.

    ^resolver

 

There is a special implementation for Nil:

 

addXmlStringTo: aStream

            "resolver mantains object translated, for avoiding recursive call

            (some object on the tree can matain reference with some other object

            on the same tree, causing infinite recursion"

 

            | resolver |

 

            resolver := XmlObjectResolver new.

            aStream nextPutAll:( self xmlClassName,self xmlParameters) asXmlTag.

            aStream nextPutAll: 'nil'.

            aStream nextPutAll: self xmlClassName asXmlEndTag. 

            ^resolver

 

 

 

 

xmlClasName is just a method for getting the class name (I work on different dialect)

xmlParameters answer an empty string, but in the case of the collection, it answer the collection size as a parameter.

 

 

addXmlElementsTo:... does the rest of the job:

 

Object>>addXmlElementsTo: aStream resolver: aResolver

 

  | ivindex value |

 

 

  self xmlIsPrimitive

      ifTrue: [aStream nextPutAll: self xmlAsString.

          "aStream cr."

          ^self ].

  ivindex := self xmlIvarIndex.

  ivindex isEmpty

    ifTrue: [ self xmlIsPrimitive

      ifTrue: [aStream nextPutAll: self xmlAsString]

      ifFalse: [aStream skip: -1.

            aStream nextPutAll: '>']].

  ivindex associationsDo: [:each |

    value := self instVarAt: (each value).

    aStream cr.

    value addXmlStringTo: aStream xmlSetter: (each key asString) resolver: aResolver].

  aStream cr.

 

 

Defining that a class is primitive (self xmlIsPrimitive answer true) allow customization of the rendering, so, for example, for Date, I have:

 

Date>>xmlAsString

 

"^self printFormat: #(2 1 3 $/ 1 1 )."

            | aStream |

            aStream := WriteStream on: (String new: 16).

            self

                        printOn: aStream

                        inFormat: 'ddMMyyyy'

                        twoDigitYear: false

                        dateSeparator: '/'.

            ^aStream contents

 

For string:

String>>xmlAsString

 

            ^self replaceCharacters: #($& $" $< $> $') withStrings: #('&amp;' '&quot;' '&lt;' '&gt;' '&apos;').

 

xmlIvarndex answer instance variables in a platform independent way.

 

Some examples:

 

173.23 asXmlString  '<Float>173.23</Float>'

Core.Date today  asXmlString  '<Date>30/04/2006</Date>'

 

TimeStamp today asXmlString  '<TimeStamp>

<seconds CLASS="Integer" VALUE="0"/>

<nanos CLASS="Integer" VALUE="0"/>

<offset CLASS="Duration">

<seconds CLASS="Integer" VALUE="7200"/>

<nanos CLASS="Integer" VALUE="0"/>

</offset>

<jdn CLASS="Integer" VALUE="2453856"/>

</TimeStamp>'

 

 

Like you can see, I have no particular formatter for timestamp, so I have bak a verbose representation of its internal state. For moving between dialect I should have to put a standard form of representation for timestamp.

 

Here is a collection holding the same 3 elements, plus 2 instance of the same timestamp, for showing how references are managed.

 

 

 

timestamp := TimeStamp today.

collection := OrderedCollection new.

collection add: 173.23.

collection add: Core.Date today.

collection add: TimeStamp today.

collection add: timestamp.

collection add: timestamp.

 

collection asXmlString  '<OrderedCollection SIZE="5">

<add CLASS="Float" VALUE="173.23"/>

<add CLASS="Date" VALUE="30/04/2006"/>

<add CLASS="TimeStamp">

<seconds CLASS="Integer" VALUE="0"/>

<jdn CLASS="Integer" VALUE="2453856"/>

<offset CLASS="Duration">

<seconds CLASS="Integer" VALUE="7200"/>

<nanos CLASS="Integer" VALUE="0"/>

</offset>

<nanos CLASS="Integer" VALUE="0"/>

</add>

<add CLASS="TimeStamp">

<seconds CLASS="Integer" VALUE="0"/>

<jdn CLASS="Integer" VALUE="2453856"/>

<offset CLASS="Duration" XMLVARREF="3"/>

<nanos CLASS="Integer" VALUE="0"/>

</add>

<add CLASS="TimeStamp" XMLVARREF="4"/>

</OrderedCollection>'

 

 

 

 

 

Hope this can help.

 

I had to look at the code, because this is some infrastructure living in my images from at least 7 years, with no modifications done. I forgot everything about it!!!!

The only thing I can say more is that it works (at least for what I need), and it allow me to send complex object between VW and VSE or Dolphin (I don’t use the dolphin stuff on v5).

 

Ciao

 

Giorgio

 

 

 

 

 

 

-----Messaggio originale-----
Da: stéphane ducasse [mailto:[hidden email]]
Inviato: sabato 29 aprile 2006 11.42
A: Giorgio Ferraris
Cc: [hidden email]; 'Charles A. Monteiro'
Oggetto: Re: R: Generix XML marshaller

 

Ideally I would like to be able to specify what are the iv (or not 

derived fields) that should be serialized,

then depending on their type (date, text)...the serializer should 

serialize them.

 

I was planning to start doing something based on magritte or MOF so 

that I could describe

my object and get them serialized.

 

 

 

Can you explain a bit more your solution?

 

Stef

 

 

On 28 avr. 06, at 23:29, Giorgio Ferraris wrote:

 

> Hi, Charles,

> 

> I don't know if this can help. I have a "generic xml marshaler" I 

> built long

> before the xml stuff come up on the dialects.

> I'ts pretty easy, and based to an open surce Dolphin parser (SAX 

> type) that

> was available long time ago.

> I don't know what do you mean exactly for generic, so I'll try to 

> explain

> what I do (I use it for sending object between different smalltalk 

> images,

> of different dialect, in particular is the medium I use for 

> communicate

> between my VSE gui for HOP, my O/R mapping, and the VW image, but I 

> used it

> on dolphin too, lon ago)

> 

> Prerequisite: the classes should be defined on both images (images 

> can be

> different language, as said before).

> 

> There is a method in object :

> 

> asXmlString

> 

>     | stream |

>     stream := WriteStream on: (String new: 30).

>     self beforeXmlConversion.

>     self addXmlStringTo: stream.

>     self afterXmlRebuilt.

>     ^stream contents.

> 

> This is the marshaling method.

> 

> This method has two hooks:

> beforeXmlConversion and afterXmlRebuilt.

> 

> You can reimplement it if you need. The meaning is: if I have to 

> send an

> object, and this object has computed (derived) state, I usually 

> clear this

> state (reducing the amount of bytes, amount that is already big 

> enough) on

> before XMlConversion, and rebuild the state on afterXmlRebuild.

> 

> As you can guess, there is a corrsponding method for getting back the

> object, this time in string:

> 

> objectFromXmlString

> 

>     | anObject |

>     anObject := XmlElevenApplication new

>             parse: (ReadStream on: self);

>             getObject.

>     anObject afterXmlRebuilt.

>     ^anObject.

> 

> And this method, obviously, call afterXmlRebuild for giving you the 

> real

> object with all of the rebuilt data.

> 

> I manage object references when rebuilding the obgiect on the 

> unmarshaling

> phase ( I remember that, when I developed it, I was surprise that 

> on the web

> and on the magazines, no one, never in java, was talking about 

> recreating

> references, but it was so many years ago...

> My implementation is not standard in any way , but it works. For 

> what I

> know, there should be some standard for references, but I never 

> followed it,

> my system worked for my job, and this was enough)

> Another non standard feature I remember is that I had to choose I 

> format for

> sending Data, and so I use my, that is not the one XML support ( I 

> send Data

> as DD/MM/YYYY).

> I have some doubth about time stamp, probably I don't have support 

> for this

> (never used).

> 

> There is also no documentation, and few tests (I was starting at 

> that time

> using SUnit heavily)

> 

> There are also no assurance about the correct functionality of this  

> stuff

> :)

> 

> If, after all of this words, you are still interested, I have no 

> problems to

> sending you the parcels an helping you a bit to having it running 

> on your

> machine.

> I have it running on a 7.3.1

> 

> If you look at it and think it could be usefull, I can load it on 

> public

> store for other people to use (if someone is interested)

> 

> Remember, it don't use the XML stuff on VW and I don't know if it's 

> fast...,

> and I don't use namespace, because I have to support it on other 

> smalltalk

> dialects (notably VSE)

> 

> Ciao

Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

Alan Knight-2
In reply to this post by stéphane ducasse-2
I don't really know what Generic (or even Generix) means in this context. Depending what you want, you might do radically different things. If your only requirement is that it be XML, without regard to any internals, then just take the storeString and file it out as VW source code. Or you could fairly easily implement "BOXX" by taking an existing serializing and sticking angle brackets in for its delimiters, giving you literally what Stef is talking about. If you want more internal structure to the objects, then what you want might start to depend a lot on what you need that internal structure for. I would think that a really generic one
  <instvar name = "foo">storeStringOfInstanceOrElseAnEncodedReferenceToAnotherObject</instvar>
would be pretty trivial to build.  Or you could use XML Schema. etc. etc.

At 05:42 AM 29/04/2006, stéphane ducasse wrote:

>Did you look at SRP?
>
>We used Sixx for the first version of Smallwiki but now I would  
>prefer to have a textual representation of the objects and not a Boss
>with xml tag around.
>
>Stef
>On 28 avr. 06, at 18:59, Charles A. Monteiro wrote:
>
>>Is SIXX the only generic XML marshaller available?
>>
>>I see that there has not been any activity for a while apparently.  
>>Maybe it is stable though. I just want something that I can pretty  
>>much just do:
>>
>>        anObject storeAsXmlString "saving"
>>        aString asObjectFromXml "reading"
>>
>>        etc ...
>>
>>tia,
>>
>>--
>>Charles A. Monteiro

--
Alan Knight [|], Cincom Smalltalk Development
[hidden email]
[hidden email]
http://www.cincom.com/smalltalk

"The Static Typing Philosophy: Make it fast. Make it right. Make it run." - Niall Ross

Reply | Threaded
Open this post in threaded view
|

Re: R: Generix XML marshaller

Charles A. Monteiro-2
In reply to this post by Giorgio Ferraris
it might be interesting to have an alternative to SIXX, by generic I mean  
that the user does not have to do anything much like Boss except for the  
caveat that there are just some types of objects that are not meant to be  
serialized i.e. as Java would put it your "transients"

-Charles

On Fri, 28 Apr 2006 17:29:40 -0400, Giorgio Ferraris  
<[hidden email]> wrote:

> Hi, Charles,
>
> I don't know if this can help. I have a "generic xml marshaler" I built  
> long
> before the xml stuff come up on the dialects.
> I'ts pretty easy, and based to an open surce Dolphin parser (SAX type)  
> that
> was available long time ago.
> I don't know what do you mean exactly for generic, so I'll try to explain
> what I do (I use it for sending object between different smalltalk  
> images,
> of different dialect, in particular is the medium I use for communicate
> between my VSE gui for HOP, my O/R mapping, and the VW image, but I used  
> it
> on dolphin too, lon ago)
>
> Prerequisite: the classes should be defined on both images (images can be
> different language, as said before).
>
> There is a method in object :
>
> asXmlString
>
>     | stream |
>     stream := WriteStream on: (String new: 30).
>     self beforeXmlConversion.
>     self addXmlStringTo: stream.
>     self afterXmlRebuilt.
>     ^stream contents.
>
> This is the marshaling method.
>
> This method has two hooks:
> beforeXmlConversion and afterXmlRebuilt.
>
> You can reimplement it if you need. The meaning is: if I have to send an
> object, and this object has computed (derived) state, I usually clear  
> this
> state (reducing the amount of bytes, amount that is already big enough)  
> on
> before XMlConversion, and rebuild the state on afterXmlRebuild.
>
> As you can guess, there is a corrsponding method for getting back the
> object, this time in string:
>
> objectFromXmlString
>
>     | anObject |
> anObject := XmlElevenApplication new
>             parse: (ReadStream on: self);
>             getObject.
>     anObject afterXmlRebuilt.
>     ^anObject.
>
> And this method, obviously, call afterXmlRebuild for giving you the real
> object with all of the rebuilt data.
>
> I manage object references when rebuilding the obgiect on the  
> unmarshaling
> phase ( I remember that, when I developed it, I was surprise that on the  
> web
> and on the magazines, no one, never in java, was talking about recreating
> references, but it was so many years ago...
> My implementation is not standard in any way , but it works. For what I
> know, there should be some standard for references, but I never followed  
> it,
> my system worked for my job, and this was enough)
> Another non standard feature I remember is that I had to choose I format  
> for
> sending Data, and so I use my, that is not the one XML support ( I send  
> Data
> as DD/MM/YYYY).
> I have some doubth about time stamp, probably I don't have support for  
> this
> (never used).
>
> There is also no documentation, and few tests (I was starting at that  
> time
> using SUnit heavily)
>
> There are also no assurance about the correct functionality of this stuff
> :)
>
> If, after all of this words, you are still interested, I have no  
> problems to
> sending you the parcels an helping you a bit to having it running on your
> machine.
> I have it running on a 7.3.1
>
> If you look at it and think it could be usefull, I can load it on public
> store for other people to use (if someone is interested)
>
> Remember, it don't use the XML stuff on VW and I don't know if it's  
> fast...,
> and I don't use namespace, because I have to support it on other  
> smalltalk
> dialects (notably VSE)
>
> Ciao
>
> Giorgio
>
> -----Messaggio originale-----
> Da: Charles A. Monteiro [mailto:[hidden email]]
> Inviato: venerdì 28 aprile 2006 20.08
> A: Magnus Jakt
> Cc: [hidden email]
> Oggetto: Re: Generix XML marshaller
>
> yes, I don't believe it can handle recreation of object references
>
> On Fri, 28 Apr 2006 12:16:40 -0400, Magnus Jakt <[hidden email]>  
> wrote:
>
>> Charles A. Monteiro wrote:
>>> Is SIXX the only generic XML marshaller available?
>>>  I see that there has not been any activity for a while apparently.
>>> Maybe  it is stable though. I just want something that I can pretty
>>> much just do:
>>>      anObject storeAsXmlString "saving"
>>>     aString asObjectFromXml "reading"
>>
>> You might want to have a look at this (found in the public repository):
>>
>> http://www.cincomsmalltalk.com/CincomSmalltalkWiki/XML+Configuration+Files
>>
>> Seems to work fairly well for objects that are not too complex.
>>
>> /Magnus
>>
>>>     etc ...
>>>  tia,
>>>
>>
>
>
>



--
Charles A. Monteiro

Reply | Threaded
Open this post in threaded view
|

Re: R: Generix XML marshaller

Charles A. Monteiro-2
In reply to this post by stéphane ducasse-2
Also, I believe I saw something in SIXX one could "hook" but it has been  
awhil3e.

On Sat, 29 Apr 2006 05:41:39 -0400, stéphane ducasse  
<[hidden email]> wrote:

> Ideally I would like to be able to specify what are the iv (or not  
> derived fields) that should be serialized,
> then depending on their type (date, text)...the serializer should  
> serialize them.
>
> I was planning to start doing something based on magritte or MOF so that  
> I could describe
> my object and get them serialized.
>
> Can you explain a bit more your solution?
>
> Stef
>
>
> On 28 avr. 06, at 23:29, Giorgio Ferraris wrote:
>
>> Hi, Charles,
>>
>> I don't know if this can help. I have a "generic xml marshaler" I built  
>> long
>> before the xml stuff come up on the dialects.
>> I'ts pretty easy, and based to an open surce Dolphin parser (SAX type)  
>> that
>> was available long time ago.
>> I don't know what do you mean exactly for generic, so I'll try to  
>> explain
>> what I do (I use it for sending object between different smalltalk  
>> images,
>> of different dialect, in particular is the medium I use for communicate
>> between my VSE gui for HOP, my O/R mapping, and the VW image, but I  
>> used it
>> on dolphin too, lon ago)
>>
>> Prerequisite: the classes should be defined on both images (images can  
>> be
>> different language, as said before).
>>
>> There is a method in object :
>>
>> asXmlString
>>
>>     | stream |
>>     stream := WriteStream on: (String new: 30).
>>     self beforeXmlConversion.
>>     self addXmlStringTo: stream.
>>     self afterXmlRebuilt.
>>     ^stream contents.
>>
>> This is the marshaling method.
>>
>> This method has two hooks:
>> beforeXmlConversion and afterXmlRebuilt.
>>
>> You can reimplement it if you need. The meaning is: if I have to send an
>> object, and this object has computed (derived) state, I usually clear  
>> this
>> state (reducing the amount of bytes, amount that is already big enough)  
>> on
>> before XMlConversion, and rebuild the state on afterXmlRebuild.
>>
>> As you can guess, there is a corrsponding method for getting back the
>> object, this time in string:
>>
>> objectFromXmlString
>>
>>     | anObject |
>> anObject := XmlElevenApplication new
>>             parse: (ReadStream on: self);
>>             getObject.
>>     anObject afterXmlRebuilt.
>>     ^anObject.
>>
>> And this method, obviously, call afterXmlRebuild for giving you the real
>> object with all of the rebuilt data.
>>
>> I manage object references when rebuilding the obgiect on the  
>> unmarshaling
>> phase ( I remember that, when I developed it, I was surprise that on  
>> the web
>> and on the magazines, no one, never in java, was talking about  
>> recreating
>> references, but it was so many years ago...
>> My implementation is not standard in any way , but it works. For what I
>> know, there should be some standard for references, but I never  
>> followed it,
>> my system worked for my job, and this was enough)
>> Another non standard feature I remember is that I had to choose I  
>> format for
>> sending Data, and so I use my, that is not the one XML support ( I send  
>> Data
>> as DD/MM/YYYY).
>> I have some doubth about time stamp, probably I don't have support for  
>> this
>> (never used).
>>
>> There is also no documentation, and few tests (I was starting at that  
>> time
>> using SUnit heavily)
>>
>> There are also no assurance about the correct functionality of this  
>> stuff
>> :)
>>
>> If, after all of this words, you are still interested, I have no  
>> problems to
>> sending you the parcels an helping you a bit to having it running on  
>> your
>> machine.
>> I have it running on a 7.3.1
>>
>> If you look at it and think it could be usefull, I can load it on public
>> store for other people to use (if someone is interested)
>>
>> Remember, it don't use the XML stuff on VW and I don't know if it's  
>> fast...,
>> and I don't use namespace, because I have to support it on other  
>> smalltalk
>> dialects (notably VSE)
>>
>> Ciao
>>
>> Giorgio
>>
>> -----Messaggio originale-----
>> Da: Charles A. Monteiro [mailto:[hidden email]]
>> Inviato: venerdì 28 aprile 2006 20.08
>> A: Magnus Jakt
>> Cc: [hidden email]
>> Oggetto: Re: Generix XML marshaller
>>
>> yes, I don't believe it can handle recreation of object references
>>
>> On Fri, 28 Apr 2006 12:16:40 -0400, Magnus Jakt <[hidden email]>  
>> wrote:
>>
>>> Charles A. Monteiro wrote:
>>>> Is SIXX the only generic XML marshaller available?
>>>>  I see that there has not been any activity for a while apparently.
>>>> Maybe  it is stable though. I just want something that I can pretty
>>>> much just do:
>>>>      anObject storeAsXmlString "saving"
>>>>     aString asObjectFromXml "reading"
>>>
>>> You might want to have a look at this (found in the public repository):
>>>
>>> http://www.cincomsmalltalk.com/CincomSmalltalkWiki/XML 
>>> +Configuration+Files
>>>
>>> Seems to work fairly well for objects that are not too complex.
>>>
>>> /Magnus
>>>
>>>>     etc ...
>>>>  tia,
>>>>
>>>
>>
>>
>>
>> --Charles A. Monteiro
>>
>>
>>



--
Charles A. Monteiro

Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

Charles A. Monteiro-2
In reply to this post by stéphane ducasse-2
I played with SRP briefly, SRP is interesting and according to Paul  
Bowman, its developer, the marshalling/unmarshalling works and across  
dialects , not sure how many. In my case, I did want something human  
readable. SIXX will do it and handle object refereneces but it is  
naturally verbose. I have been playing with the XML Configuration stuff  
and it is fine for the less complex needs and also much lighter than SIXX.

-Charles

On Sat, 29 Apr 2006 05:42:43 -0400, stéphane ducasse  
<[hidden email]> wrote:

> Did you look at SRP?
>
> We used Sixx for the first version of Smallwiki but now I would prefer  
> to have a textual representation of the objects and not a Boss
> with xml tag around.
>
> Stef
> On 28 avr. 06, at 18:59, Charles A. Monteiro wrote:
>
>> Is SIXX the only generic XML marshaller available?
>>
>> I see that there has not been any activity for a while apparently.  
>> Maybe it is stable though. I just want something that I can pretty much  
>> just do:
>>
>> anObject storeAsXmlString "saving"
>> aString asObjectFromXml "reading"
>>
>> etc ...
>>
>> tia,
>>
>> --Charles A. Monteiro
>>



--
Charles A. Monteiro

Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

Charles A. Monteiro-2
In reply to this post by Alan Knight-2
see my previous post, perhaps "generic" is the wrong term. Maybe  
"transaparent" is better. In most cases I don't want to have to in anyway  
configure the marshaller. As Stef mentioned it would be nice on certain  
occassions for a type to provide a "serialzing spec" or a way of tagging  
what instVars aRe transient and exempt from serializing. This btw would  
also be a great thing to have for BOSS, maybe that capability is there  
now? Have not checked lately.

In anycase SIXX does all that I need but it is verbose. As a matter of  
fact , I had to built a StorageManager for the NYC Smalltalk SmallWiki  
based on Boss since the SIXX were somewhere in the order of 10x larger  
than their Boss counterparts.

-Charles



On Sun, 30 Apr 2006 13:59:50 -0400, Alan Knight <[hidden email]> wrote:

> I don't really know what Generic (or even Generix) means in this  
> context. Depending what you want, you might do radically different  
> things. If your only requirement is that it be XML, without regard to  
> any internals, then just take the storeString and file it out as VW  
> source code. Or you could fairly easily implement "BOXX" by taking an  
> existing serializing and sticking angle brackets in for its delimiters,  
> giving you literally what Stef is talking about. If you want more  
> internal structure to the objects, then what you want might start to  
> depend a lot on what you need that internal structure for. I would think  
> that a really generic one
>   <instvar name =  
> "foo">storeStringOfInstanceOrElseAnEncodedReferenceToAnotherObject</instvar>
> would be pretty trivial to build.  Or you could use XML Schema. etc. etc.
>
> At 05:42 AM 29/04/2006, stéphane ducasse wrote:
>> Did you look at SRP?
>>
>> We used Sixx for the first version of Smallwiki but now I would
>> prefer to have a textual representation of the objects and not a Boss
>> with xml tag around.
>>
>> Stef
>> On 28 avr. 06, at 18:59, Charles A. Monteiro wrote:
>>
>>> Is SIXX the only generic XML marshaller available?
>>>
>>> I see that there has not been any activity for a while apparently.
>>> Maybe it is stable though. I just want something that I can pretty
>>> much just do:
>>>
>>>        anObject storeAsXmlString "saving"
>>>        aString asObjectFromXml "reading"
>>>
>>>        etc ...
>>>
>>> tia,
>>>
>>> --
>>> Charles A. Monteiro
>
> --
> Alan Knight [|], Cincom Smalltalk Development
> [hidden email]
> [hidden email]
> http://www.cincom.com/smalltalk
>
> "The Static Typing Philosophy: Make it fast. Make it right. Make it  
> run." - Niall Ross



--
Charles A. Monteiro

Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

Charles A. Monteiro-2
In reply to this post by Nicolas Cellier-3
please do publish your goodie, thxs

On Sat, 29 Apr 2006 06:46:00 -0400, nicolas cellier <[hidden email]>  
wrote:

> Le Samedi 29 Avril 2006 11:42, stéphane ducasse a écrit :
>> Did you look at SRP?
>>
>> We used Sixx for the first version of Smallwiki but now I would
>> prefer to have a textual representation of the objects and not a Boss
>> with xml tag around.
>>
>> Stef
>>
>> On 28 avr. 06, at 18:59, Charles A. Monteiro wrote:
>> > Is SIXX the only generic XML marshaller available?
>> >
>> > I see that there has not been any activity for a while apparently.
>> > Maybe it is stable though. I just want something that I can pretty
>> > much just do:
>> >
>> >  anObject storeAsXmlString "saving"
>> >  aString asObjectFromXml "reading"
>> >
>> >  etc ...
>> >
>> > tia,
>> >
>> > --
>> > Charles A. Monteiro
>
> In my opinion, these xml are not that readable.
> General solution i implemented is to have some Smalltalk code written to
> reconstruct the objects, and rely on our nice class-message passing
> mechanism.
>
> Simple objects (literals, 1@2, ColorValue blue, etc...) are stored with  
> simple
> Smalltalk message, the storeOn: way.
> Complex objects are stored using environnement variables (aTextEditor1 :=
> TextEditor new.), with some kind of IdentityDictionary service, the  
> cycles
> are easily stored and retrieved.
> I have a class achieving that kind of service, based on using the  
> ProgramNode
> to write well formatted code.
>
> Well known constant objects can naturally be saved with a reference  
> (ClassName
> constantMessage), instead of putting a copy.
> Code is split in small chunks because Smalltalk would not compile a  
> 200kByte
> method, this is also more efficient.
>
> This solution is very interesting if you have Smalltalk-only application,
> because passing a few messages, you can have complex object tree
> reconstructed.
> You also expose only the public interface, not the  
> implementation-dependent
> internal variables.
> You only have to write a few storeOn: like methods in your app strategic
> classes.
> This lead to really readable code, and can be used for other purposes  
> (like
> Transcripting user actions on an interface into Smalltalk code).
>
> Message passing is also a superior solution to handle versionning.
> Handling compatibility messages of a public interface is easier than the  
> BOSS
> versionning for example.
>
> So the two essentials services to be used are:
> - class variables and (public interface) message passing
> - environment variables to handle cycles gracefully
>
> If xml can handle that in a neutral syntax, i say OK.
>
> But if you have no foreign app, then why bother ?
> Smalltalk is far superior in readability...
>
> If anyone is interested, i will publish the code.
>
> Nicolas



--
Charles A. Monteiro

Reply | Threaded
Open this post in threaded view
|

Re: Generix XML marshaller

Nicolas Cellier-3
Le Lundi 01 Mai 2006 16:38, Charles A. Monteiro a écrit :
> please do publish your goodie, thxs

Le Samedi 29 Avril 2006 16:28, Cesar Rabak a écrit :
> Nicolas,
>
> I'm interested.

OK, i spoke too much, and had to rewrite it...

it is named ProgramRebuilder at cincom public store.
See package comment.

I do not provide any environment compiler to re-read (i guess you can recycle
the workspace's one).
The thing is for sure very elementary and incomplete, but quite simple.
It would gain in readability with less chunks (using cascade as storeOn:), but
this way, default implementation should not encounter any byte code limit.

Oh, and i never used it with instVarAt: nor basicAt: in my apps, i did use
named instance variables of course, or more complex messages where relevant.
I had some genericity, and usually just had to define the list of messages.

Nicolas