Hmmm, extending the bind-xml attribute to understand someting like
 
                <bind-xml name="preference/comMedia" node="element"/>
 
isn't a bad idea, actually.
I wouldn't consider it uncommon that the object structure differs from the XML structure
and writing a special FieldHandler for this wouldn't be necessary then.
I'm sorry I don't have the resources to implement this...

Heiko Erhardt
skynamics AG
www.skynamics.com

-----Original Message-----
From: Mike Thompson [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 14, 2002 4:01 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Unmarshalling when xml structure and java stucture are different

Looks like you need to implement a FieldHandler.  Check the archives.  You'll have to create a class used only for marshalling the "preferences" into and outof your Formulaire class.  You'll also have to redo your mapping.xml.
    --m
 
 
-----Original Message-----
From: dev [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 14, 2002 4:38 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Unmarshalling when xml structure and java stucture are different


Hi,

I am trying to unmarshall a xml that has a structure different from the java objects structure. Below are samples of what i mean.

Indeed, I'd like a mapping file like this (but of course it doesn't work)
<class name="Formulaire">
        <map-to xml="Formulaire"/>
....
        <field name="ComMedia" type="java.lang.String">
                <bind-xml name="preference/comMedia" node="element"/>
        </field>
        <field name=
"ComLanguage" type="java.lang.String">
                <bind-xml name="preference/comLanguage" node="element"/>
        </field>
....
</class>

This is the object I want:

public class Formulaire {

private String surname;
private String firstName;
private String address;
private String comMedia;
private String comLanguage;

public void setSurname(String surname){
this.surname=surname;
}
public String getSurname(){
return surname;
}
....
}

This is an extract of the XML I have to unmarshall:

<formulaire
<surname>
MIS</surname>
<firstName>
LILY</firstName>
<address>
35 RUE DES BEAUX ARTS 75001 PARIS perso</address>
<preference>
        <comMedia>
PAPER</comMedia>
        <comLanguage>
FR</comLanguage>
</preference>
</xsdFideS:applicationInfo>

In fact, I don't want to create new object for each subTree of the xml. I want to "flaten" the objet structure.
I don't want an object Preference with the field comMedia and comLanguage. I want this fields part of the Formulaire object.

Is it possible?
Thanks
Cedric
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev

Reply via email to