You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Éderson Marcos Ferreira <ed...@gmail.com> on 2006/01/28 20:32:18 UTC
Working with several Lists
Hi,
I've been using Betwixt to convert xml file in JavaBeans. But I've
found some problems.
I have 4 classes: Config, Arrow, Tip and ElementB. In accordance with
the XML file below, inside of element 'elementA' I may have several
'arrow' elements and inside of element 'arrow' I may have several
'tip' elements, and after 'elementA' I have an 'elementB'. This works
almost perfectly, because Config class, used in the registerBeanClass
(reader.registerBeanClass(new InputSource(dotBetwixtDocument),
Config.class)), is constructed with the elements 'arrow'(which is a
List in Config class) and 'elementB', but for the element 'tip'(which
is a List in Arrow class) doesn't work. The attribute 'tip' in the
class Arrow is empty.
What it happens?
Thank's very much.
Ederson Ferreira
My XML file follows the structure below:
<config>
<elementA>
<arrow att1="X" att2="Y" att3="Z">
<tip att4="W" att5="true" att6="false" />
<tip att4="U" att5="false" att6="true" />
</arrow>
<arrow att1="K" att2="L" att3="M">
<tip att4="R" att5="true" att6="false" />
<tip att4="S" att5="false" att6="true" />
</arrow>
</elementA>
<elementB att7="Q" />
<config>
My .betwixt document, inside application:
<?xml version='1.0' encoding='UTF-8' ?>
<info primitiveTypes='attribute'>
<element name='config'>
<element name='elementA'>
<element name='arrow'
class='com.emf.tests.Arrow'
property='arrowa'>
<attribute name='att1' property='att1'/>
<attribute name='att2' property='att2'/>
<attribute name='att3' property='att3'/>
<element name='tip'
class='com.emf.tests.Tip'
property='tips'>
<attribute name='att4' property='att4'/>
<attribute name='att5' property='att5'/>
<attribute name='att6' property='att6'/>
</element>
</element>
</element>
<element name='elementB'
class='com.emf.tests.ElementB'
property='elementB'>
<attribute name='att7' property='att7'/>
</element>
<addDefaults/>
</element>
</info>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: Working with several Lists
Posted by Martin van den Bemt <ml...@mvdb.net>.
Each bean needs a seperate .betwixt file and you have put several classes in one betwixt file..
See http://jakarta.apache.org/commons/betwixt/guide/start.html#.betwixt files for more information..
Mvgr,
Martin
Éderson Marcos Ferreira wrote:
> Hi,
>
> I've been using Betwixt to convert xml file in JavaBeans. But I've
> found some problems.
> I have 4 classes: Config, Arrow, Tip and ElementB. In accordance with
> the XML file below, inside of element 'elementA' I may have several
> 'arrow' elements and inside of element 'arrow' I may have several
> 'tip' elements, and after 'elementA' I have an 'elementB'. This works
> almost perfectly, because Config class, used in the registerBeanClass
> (reader.registerBeanClass(new InputSource(dotBetwixtDocument),
> Config.class)), is constructed with the elements 'arrow'(which is a
> List in Config class) and 'elementB', but for the element 'tip'(which
> is a List in Arrow class) doesn't work. The attribute 'tip' in the
> class Arrow is empty.
>
> What it happens?
> Thank's very much.
> Ederson Ferreira
>
> My XML file follows the structure below:
> <config>
> <elementA>
> <arrow att1="X" att2="Y" att3="Z">
> <tip att4="W" att5="true" att6="false" />
> <tip att4="U" att5="false" att6="true" />
> </arrow>
>
> <arrow att1="K" att2="L" att3="M">
> <tip att4="R" att5="true" att6="false" />
> <tip att4="S" att5="false" att6="true" />
> </arrow>
> </elementA>
> <elementB att7="Q" />
> <config>
>
> My .betwixt document, inside application:
> <?xml version='1.0' encoding='UTF-8' ?>
> <info primitiveTypes='attribute'>
> <element name='config'>
>
> <element name='elementA'>
> <element name='arrow'
> class='com.emf.tests.Arrow'
> property='arrowa'>
> <attribute name='att1' property='att1'/>
> <attribute name='att2' property='att2'/>
> <attribute name='att3' property='att3'/>
>
> <element name='tip'
> class='com.emf.tests.Tip'
> property='tips'>
> <attribute name='att4' property='att4'/>
> <attribute name='att5' property='att5'/>
> <attribute name='att6' property='att6'/>
> </element>
>
> </element>
> </element>
>
> <element name='elementB'
> class='com.emf.tests.ElementB'
> property='elementB'>
> <attribute name='att7' property='att7'/>
> </element>
>
> <addDefaults/>
> </element>
> </info>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org