XMLWriter question

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

XMLWriter question

Stéphane Ducasse
Hi guys

I have a question about XMLWriter. I have cards and group of cards.
Each class know how to serialize itself.

For card I have xmlOn: (one of my methods) that describes the card attributes

Card>>xmlOn: aWriter
        "write a description of the receiver properties as xml uing aWriter, an instance of XMLWriter"
       
        aWriter tag
                name: #card;
                with: [self xmlInstVarOn: aWriter]
       

Group>>xmlOn: aWriter
        "write a description of the receiver properties as xml uing aWriter, an instance of XMLWriter"
       
        | cardWriter |
        cardWriter := XMLWriter new.
        cards do: [:each | each xmlOn: cardWriter].
       
        aWriter tag
                name: #group;
                with: [
                        aWriter tag: #groupName with: self groupName.
                        aWriter tag: #cards with: [ aWriter raw:  cardWriter contents]]
       
       
And I'm not really happy. Because I would like to avoid to use raw: and instantiate a new writer.

I would like to know how I could use the write to pass the results of the iteration over cards
I wanted to write something like

        aWriter tag
                name: #group;
                with: [
                        aWriter tag: #groupName with: self groupName.
                        aWriter tag: #cards with: [self cards do: [:each | each xmlOn: aWriter]]








_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev