[jdom-interest] Adding an element with unbounded maxOcc

Benjamin Kopic benjamin.kopic at panContext.com
Mon Dec 22 01:12:00 PST 2003


The code you have here seems fine. Here is the test that I tried earlier
and it passed:

public void testAddJDOMElements() throws Exception {
		String[] act = {"one", "two", "three", "four"};
		Element element= new Element("ActivitySummary");
		for (int j = 0; j <act.length; j++) {
			 Element element1= new Element("ActivityType").setText(act[j]);
			 element.addContent(element1);
		}
		
		List element1s = element.getChildren();
		assertEquals(4, element1s.size());
		
		for(int i=0; i<element1s.size(); i++) {
			 System.out.println(((Element) element1s.get(i)).getText());
		}
}

Could it be something you do when you retrieve the elements? When does
the problem manifest itself? Are you sure that "act" array is populated
correctly?

Best regards

Ben


On Wed, 2003-12-10 at 13:10, Moipone Mocoancoeng wrote:

> How do I create an element that has an unbounded maximum occurences.
> for examples I've created an element that I need to set text to an
> object that can be 1 0r more.When I do element.addContent only the
> first object is added to the one element and other object aren't
> added.
>  
>       Element element= new Element("ActivitySummary");
>       for (int j = 0; j <act.length; j++){
>          Element element1= new
> Element("ActivityType").setText(act[j]);
>           element.addContent(element1);
>         }
> Please Advise on how best can I resolve this problem.
> Best Regards
>  
> 
> 
> ______________________________________________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing

-- 
benjamin kopic
m: +44 (0)780 154 7643
t: +44 (0)20 7794 3090
e: benjamin.kopic at panContext.com
w: http://www.panContext.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20031222/0092242e/attachment.htm


More information about the jdom-interest mailing list