commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Madisetti, Sumesh " <sumesh.madise...@citi.com>
Subject RE: Digester1.8 and recursive tag types
Date Tue, 21 Aug 2007 12:20:01 GMT
Fixing the digester rules as below fixes the problem. Just did not pay
careful attention
to the documentation that says digester only support *a/a/a/b and not
a/*a/... - should be
no wildcards in the middle.

Thanks
Sumesh

<digester-rules>
	<pattern value="*/list">
		<object-create-rule classname="java.util.ArrayList"/>
		<pattern value="person">
			<object-create-rule classname="TestDig"/>
			<set-next-rule methodname="add"/>
		</pattern>
		<pattern value="list">
			<object-create-rule
classname="java.util.ArrayList"/>
			<pattern value="person">
				<object-create-rule
classname="TestDig"/>
				<set-next-rule methodname="add"/>
			</pattern>
			<set-next-rule methodname="add"/>
		</pattern>	

	</pattern>	
</digester-rules> 

-----Original Message-----
From: simon [mailto:simon.kitching@chello.at] 
Sent: Friday, August 10, 2007 3:54 AM
To: Jakarta Commons Users List
Subject: Re: Digester1.8 and recursive tag types

On Thu, 2007-08-09 at 17:51 -0400, Madisetti, Sumesh wrote:
> Hi,
> 
> I am having trouble parsing recursive tags with digester version 1.8.
> 
> With the digester def below, I am not able to get to any of the inner 
> list elements such as person.name=bar3.
> 
> Any help appreciated.
> 
> Thanks
> Sumesh
> 
> Xml -
> =====
> <list>
> 	<person><name>foo</name></person>
> 	<person><name>bar</name></person>
> 	<list>
> 		<person><name>foo2</name></person>
> 		<person><name>bar2</name></person>
> 		<list>
> 			<person><name>bar3</name></person>
> 		</list>
> 	</list>
> 	<person><name>zap</name></person>
> 	<list></list>
> </list>	
> 
> 
> Digester
> ========
> <digester-rules>
> 	<pattern value="*/list">
> 		<object-create-rule classname="java.util.ArrayList"/>
> 		<pattern value="person">
> 			<object-create-rule classname="TestDig"/>
> 			<set-next-rule methodname="add"/>
> 		</pattern>
> 	</pattern>	
> </digester-rules>

That looks ok to me (though presumably you also have a rule to set the
name attribute for a person which you haven't shown).

I suggest turning on debug-level logging for category
org.apache.commons.digester, which will show what rules are firing and
when.

By "cannot get to person.name=bar3", I presume you mean that no
corresponding java object has been created during the parse. What
objects *do* get created?

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message