commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ederson Marcos Ferreira <ederso...@gmail.com>
Subject Betwixt: Working with chain lists
Date Tue, 31 Jan 2006 15:48:47 GMT
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 classes have to follow a
hierarchy and the classes can't be separate. The attribute 'tip' in
the
class Arrow is empty. In the end the Config class should be constructed
following the structure below:

Config class
	private ElementB elementB; (it's OK!!!)
	private List arrows; (which should be populated with instances of
Arrow - it's OK!!!)

	public Config() {
		this.arrows = new ArrayList();
	}

	public List getArrows() {
		return this.arrows;
	}

	public void addArrow(Arrow arrow) {
		this.arrows.add(arrow);
	}

Arrow class
	private String att1; (it's OK!!!)
	private String att2; (it's OK!!!)
	private String att3; (it's OK!!!)
	private List tips; (which should be populated with instances of Tip -
but doesn't work!!! - this is the point, it's empty)

	public Arrow() {
		this.arrows = new ArrayList();
	}

	public List getTips() {
		return this.tips;
	}

	public void addTip(Tip tip) {
		this.tips.add(tip);
	}
	

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='arrows'>
			   <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


Mime
View raw message