----- Original Message -----
I am currently developing a new Smalltalk Wiki implementation
) and I am planning to use
SIXX to store my large tree-structures to xml. It seems to me the
perfect solution, because it can handle circular references and it
But how do I prevent SIXX from saving the binary data again, without
hardcoding the other i-vars? How do I archive the loading of the binary
I feel it is best to explain in code. So I attached the sample.
The sample is Squeak file-in format but you can read it by text editor.
Basically, in #sixxContentOn:indent:context:,
you can delegate the writing process to some of the children (inst-vars)
by using #sixxOn:name:indent:context:.
| id newLevel fileStr |
"Write ID to XML instead of binary data"
newLevel := level + 1.
id := self generateID.
id sixxOn: aStream name: 'resourceID' indent: newLevel context: dictionary.
"Write some other inst vars (optional)"
self name sixxOn: aStream name: 'name' indent: newLevel context:
"Dump actual data to file"
[fileStr := FileStream forceNewFileNamed: id.
fileStr nextPutAll: binaryData asArray printString. "just a sample - you
should use binary mode"]
ensure: [fileStr close.]
For the reading, you can override #sixxInstVarNamed:put:
instVarName = 'resourceID' ifTrue: [ | fileStr |
[fileStr := FileStream readOnlyFileNamed: aValue.
self binaryData: (Array readFrom: fileStr contents) asByteArray]
ensure: [fileStr close.].
instVarName = 'name' ifTrue: [^self name: aValue].
There are other "hook" methods in SIXX for the more efficient
But I think the sample code fits your purpose.
I hope it helps. Please feel free to ask me, if you have some questions.
I'm looking forward to SmallWiki!
[:masashi | ^umezawa]