In that case, this won't be possible out of the box. Having said that, is the 
element you are creating a top-level element ? If not, in other words, if it is 
contained in some containing class, you might be able to create a custom 
FiedlHandler and work out the actual object instance yourself.

Werner

________________________________________
Von: O'Toole, Joe [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 10. April 2007 10:22
An: '[email protected]'
Betreff: RE: [castor-user] Castor Binding Query

Unfortunately I cannot change the xml as you have below. In my situation, where 
you have the <ACCOUNT type="CURRENT"> element, I have to create an element 
where the name of the element is set at runtime based on the value of 
accountType attribute in the account class. 
 
Hence, the genertated XML may look like.
 
<CURRENT | DEPOSIT | SAVINGS | etc>    
        <ACCOUNTNAME>Joe</ACCOUNTNAME> 
        <ACCOUNTBALANCE>12.12</ACCOUNTBALANCE> 
</CURRENT> 
Joe
-----Original Message-----
From: Developer Dude [mailto:[EMAIL PROTECTED] 
Sent: 06 April 2007 17:37
To: [email protected]
Subject: RE: [castor-user] Castor Binding Query
You could not do this instead?
 
<ACCOUNT type="CURRENT">    //The name of this element comes from the value of 
the accountType attr., hence it could be 1 of 15 different names
        <ACCOUNTNAME>Joe</ACCOUNTNAME> 
        <ACCOUNTBALANCE>12.12</ACCOUNTBALANCE> 
</ACCOUNT > 
Do you mean that you actually want the XML to unmarshall to a different class depending on one of the 15 different values
 for a string variable in your class?
 
I am not getting it.

________________________________________
From: O'Toole, Joe [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 06, 2007 8:54 AM
To: '[email protected]'
Subject: [castor-user] Castor Binding Query
I have the following object: 
Class Account{ 
        String accountType; 
        String accountName; 
        String accountBalance;  
        etc.    
} 
The accountType attribute can have 1 of 15 possible values, e.g. "CURRENT", 
"DEPOSIT" etc. 

My query is, with castor we define the mapping of the attribute to the xml tag 
at compilation time. This does not work so good in the class above as the 
desired XML needs to look like:
<CURRENT>    //The name of this element comes from the value of the accountType 
attr., hence it could be 1 of 15 different names
        <ACCOUNTNAME>Joe</ACCOUNTNAME> 
        <ACCOUNTBALANCE>12.12</ACCOUNTBALANCE> 
</CURRENT> 
In other words the element <CURRENT> that is created gets created at run time 
based on the value of the accountType attribute. I don't think I can achieve 
this with Castor but I was wondering if anyone out there knew of any other way 
of achieving this rather than creating my own marshalling component.
Thanks 

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to