Moving objects... (serialization)
Marcel Weiher
marcel at system.de
Mon Jul 26 18:14:35 UTC 1999
Hi,
the answer is XML. What was your question again? :-)
I've been looking at cross-platform serialization for a while now
and seriously believe that XML is the way to go here. XML coding is
simple, standardized, self-describing, human readable, etc. Standard
XML mechanisms can be used to describe object-references, even to
objects not within the same file and can even express the difference
between fetching the target of such a reference immediately or via
proxy if referenced (SqueakPages?).
One of the implications of XML as a serialization format is that you
do not need to have the actual objects in order to understand,
display, modify a serialized representation. As a matter of fact,
purely syntactical tools such as XSL or even grep and vi can be used
to search or transform such formats. The serialization format can
also be close enough to standard XML-based formats that
conversion/encoding is a trivial extension to serialization.
Of course, I also see a couple of drawbacks, one is that the format
is pretty verbose, and the other is that it can't handle raw binary
data without quoting. WAP, a compact binary format for XML might
actually address both of these issues, and for plain XML, you can
either go with external entities (move the binary data into a
separate file) or bite the bullet and quote the data.
I've also been thinking about an object/value representation that
works without byte-encoding everything (useful for inter-language
calling within the same address space).
> From: "Peter Smet" <peter.smet at flinders.edu.au>
> The achilles heel of all this stuff seems to lie with the
serialization. For
> example, I can send a serialized object or class across the net
with BOSS,
> but it will collapse in Squeak, Dolphin, and even more so in
Java. There
> are JVM's spread all across the net, but we cannot talk to the
objects in
> them, since the serialized objects are not compatible with
Smalltalk. Does
> ANSI say anything about serialization across Smalltalks? Could
serialization
> be improved by MetaObject Protocol extensions? I am thinking that all
> serialized objects could contain some serialized meta-information
that could
> be instantiated into a MetaObject (across all languages). The
MetaObject
> would then aid in reconstructing the state and behaviour of the 'dead'
> serialized object (sorry, just rambling).
Here's some sample output from an XML-serializer I just wrote (in
Objective-C) last weekend. I manually cut out some data, so it
probably doesn't nest properly any longer.
<object id=1d9f30 class=MPWAdTemplate>
<epsTemplate> <!-- instance variable named 'epsTemplate' --!>
<object id=31e478 class=MPWEPSFile> <!-- first reference is
coded inline --!>
<dsc> <!-- instance var of
MPWEPSFile object in 'epsTemplate' var --!>
<object id=31ada8 class=NSMutableArray>
<count valuetype='i'>41</count>
<arrayelement>
<object id=31ae30 class=MPWDSCComment>
<name>%!PS-Adobe-</name>
<value>2.0 EPSF-1.2</value>
</object>
</arrayelement>
<arrayelement>
<object id=31aef0 class=MPWDSCComment>
<name>%%Creator:</name>
<value>QuarkXPress(R) 4.03</value>
</object>
</arrayelement>
<!-- array elements omitted --!>
<arrayelement>
<object id=31d090 class=MPWSubData>
<myData>
<object id=31cfa0 class=MPWSubData>
<myData>
<object id=31b2c8 class=NSData>
<data length=392143/></object> <!--
actual data omitted for now --!>
</myData>
<offset valuetype='i'>0</offset>
<myLength valuetype='I'>392143</myLength>
</object>
</myData>
<offset valuetype='i'>168</offset>
<myLength valuetype='I'>33</myLength>
</object>
</arrayelement>
<arrayelement>
<object id=31a2f8 class=MPWSubData>
<myData idref=31cfa0/> <!--
reference to previous MPWSubData --!>
<offset valuetype='i'>364</offset>
<myLength valuetype='I'>58</myLength>
</object>
</arrayelement>
<arrayelement>
<object id=31a388 class=MPWSubData>
<myData idref=31cfa0/>
<offset valuetype='i'>162124</offset>
<myLength valuetype='I'>1</myLength>
</object>
</arrayelement>
<arrayelement>
<object id=31dd88 class=MPWDSCEmbeddedFile>
<name>%%BeginDocument:</name>
<value>kurt:Desktop Folder:-> W 10:AudiBW_S.eps</value>
<unnamed_1>
<object id=31abf0 class=MPWEPSFile>
<dsc>
<object id=31d968 class=NSMutableArray>
<count valuetype='i'>30</count>
<arrayelement>
<object id=31ddf8 class=MPWDSCComment>
<name>%!PS-Adobe-</name>
<value>2.0 EPSF-1.2</value>
</object>
</arrayelement>
<!-- lots of stuff omitted --!>
</object>
</arrayelement>
<arrayelement>
<object id=31e758 class=MPWDSCComment>
<name>%%EndDocument</name>
<value></value>
</object>
</arrayelement>
<arrayelement>
<object id=31d720 class=MPWSubData>
<myData idref=31cfa0/>
<offset valuetype='i'>296029</offset>
<myLength valuetype='I'>183</myLength>
</object>
</arrayelement>
<!-- again, lots of stuff omitted --!>
</dsc>
<subObjects>
<object id=31cb30 class=NSMutableArray>
<count valuetype='i'>4</count>
<arrayelement idref=31abf0/>
<arrayelement idref=323388/>
<arrayelement idref=3236d0/>
<arrayelement idref=323a18/>
</object>
</subObjects>
</object>
</epsTemplate>
<slots>
<object id=323de0 class=NSMutableArray>
<count valuetype='i'>4</count>
<arrayelement>
<object id=323e98 class=MPWRectSlot>
<original idref=31abf0/>
<rect valuetype='{?={?=ff}{?=ff}}'>{{1764, 1984}, {284,
176}}</rect>
<name>AudiBW_S</name>
<active valuetype='c'>1</active>
</object>
</arrayelement>
<!-- similar array elements omitted --!>
</object>
</slots>
<replacements>
<object id=306a8 class=NSMutableArray>
<count valuetype='i'>2</count>
<arrayelement>
<!-- array elements omitted --!>
</arrayelement>
</object>
</replacements>
</object>
More information about the Squeak-dev
mailing list
|