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