I'm also interested in knowing related to this. I tried the castor tool to
generate the mapping file and code generator.
<foo>
<bar>
<left></left>
<left></left>
<left></left>
<right></right>
<right></right>
<right></right>
</bar>
</foo>
For this, it creates classes left and right are type of bar. It doesn't work
for some reason.
But if I change the structure as follows, then I can get it properly.
<foo>
<bar>
<lbar>
<left></left>
<left></left>
<left></left>
</lbar>
<rbar>
<right></right>
<right></right>
<right></right>
</rbar>
</bar>
</foo>
Can someone explain me, Is there a way to get the mapping for the first
version, without changing the XML.
-Ben.
-----Original Message-----
From: Dan Marcus [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 05, 2003 5:28 PM
To: [EMAIL PROTECTED]
Subject: [castor-dev] need help wrapping elements
Hi-
I've just started using Castor and am excited about its potential, but I've
run
into a problem. I would like to map two fields to a single wrapper element.
I
tried using the 'location' attribute of bind-xml, but it yielded two wrapper
elements. The example below, I hope, will make this clearer. Is it possible
to nest multiple elements within a single wrapper element?
Thanks,
Dan Marcus
Given a bean like this:
public class Foo {
private int barLeft;
private int barRight;
public int getBarLeft(){
return barLeft;
}
public int getBarRight(){
return barRight;
}
}
I would like to create xml like this:
<foo>
<bar>
<left/> <!-- Note left and right are both within a single
bar-->
<right/>
</bar>
</foo>
Unfortunately, using the mapping below, it looks like this:
<foo>
<!-- Note the 2 bar elements! -->
<bar>
<left>0</left>
<bar>
<bar>
<right>5</right>
<bar>
</foo>
Here's the mapping:
<class name="Foo">
<map-to xml="foo"/>
<field name "barLeft" type="integer">
<bind-xml name="left" location="bar" node="element"/>
</field>
<field name "barLeft" type="integer">
<bind-xml name="right" location="bar" node="element"/>
</field>
</class>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev