Hiya,

I've got a couple of troubles marshalling a pair of maps on an object. 

The first one I'm not sure whether to call a bug or not. What I wanted to do
was something like

<server>
        <persistent>
                <item>.....
                <item>.....
        </persistent>
        <initialState>
                <item>.....
                <item>.....
        </initialState>
</server>

(where persistent and initialState are my maps) so in an extract from my
mapping file I id:

<field name="persistent" collection="map">
        <bind-xml name="item" node="element" location="persistent">
                ... MapItem class stuff
        </bind-xml>                                     
</field>
<field name="initialState" collection="map">
        <bind-xml name="item" node="element" location="initialState">
                ... MapItem class stuff
        </bind-xml>                                     
</field>

Now what happens if I unmarshall this is that everything that is in the
initialState item actually goes into persistent. Now like I say I'm not sure
whether this is a bug (i.e. this should work). If it is not supposed to work
then perhaps an error message if you do this would be in order (like when
you define a field twice)

-----------------------------------------------------

Ok, the other issue is with the items themselves. The maps map Strings to
Objects and these can be primitives or complex types. These complex types
are also defined in the mapping. A sample mapping I currently have is

<class name="org.wiffle.server.Spod">
        <map-to xml="spod"/>
        <field name="a">
                <bind-xml name="aaa" node="text"/>
        </field>        
        <field name="b">
                <bind-xml name="bbb" node="attribute"/>
        </field>        
</class>

<class name="org.wiffle.server.persist.PersistentEntity">
        <field name="persistent" collection="map">
                <bind-xml name="item" node="element" location="persistent">
                        <class name="org.exolab.castor.mapping.MapItem">
                                <field name="key" type="java.lang.String">
                                        <bind-xml name="key"
node="attribute"/>
                                </field>
                                <field name="value" >
                                        <bind-xml name="value"
node="element"/>
                                </field>
                        </class>
                </bind-xml>                                     
        </field>
        ...
</class>

Now when I marshal an object out I get (snippet)

<persistent>
        <item key="spod">
                <value bbb="43" xsi:type="spod">some text</value>
        </item>
        <item key="hi,integer">
                <value xsi:type="java:java.lang.Integer">5</value>
        </item>
        <item key="hello">
                <value xsi:type="java:java.lang.String">world</value>
        </item>
</persistent>

What I would like is for the name of the value elements underneath to
actually represent the type, so I added the attribute
auto-naming="deriveByClass" to the bind for 'value'. This marshals fine,
producing...

<persistent>
        <item key="spod">
                <spod bbb="43">some text</spod>
        </item>
        <item key="hi,integer">
                <integer xsi:type="java:java.lang.Integer">5</integer>
        </item>
        <item key="hello">
                <string xsi:type="java:java.lang.String">world</string>
        </item>
</persistent>

But unmarshalling is a problem, giving me the error:
unable find FieldDescriptor for 'x' in ClassDescriptor of map-item
where x is spod, integer or string.

Ideally as well I'd like to drop the xsi:types on the primitives as well.
The reason I'd like to do these changes is that for a while the only way to
talk to this thing will be via xml and I'd like to see it as simple as
possible!

Cheers
Ian



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to