[jdom-interest] Strange Element.addContent(index,Content) problem

Bradley S. Huffman hip at cs.okstate.edu
Mon Mar 22 07:18:33 PST 2004


Ah hah! Mixed content, it just happens to be whitespace :-)
All the newlines and whitespace between element tags is a Text node.  So the
first Description element would have a index of 3, not 1, in the full content
list (there's a Text node consisting of whitespace before and one after
the Communication tag).

Brad

Kai Woerner writes:

> JDom version is b10, elmt's children are too many to be posted here ;), 
> but part of it looks like this (CorpusData being elmt):
> 
> <CorpusData>
>   <Communication Id="IDCommunication001" Name="20000">
>    <Description>
>     <Key Name="DArt">Wegauskunft</Key>
>     <Key Name="DProjekt">shik</Key>
>    </Description>
>    <Setting>
>     <Description>
>      <Key Name="Angaben zur konstellation">madagassische Informantin, 
> ein Mann und eine Frau</Key>
>     </Description>
>    </Setting>
>    <Recording Id="IDRecording001"/>
>    <Location>
>     <City>Hamburg</City>
>     <Country>Germany</Country>
>     <Period>
>      <PeriodStart>1997-11-23T16:30:00</PeriodStart>
>      <PeriodExact>true</PeriodExact>
>      <PeriodDuration>PT00H00M56S</PeriodDuration>
>     </Period>
>    </Location>
>    <Language>
>     <LanguageCode>GER DE</LanguageCode>
>    </Language>
>   </Communication>
> 
> (repeat "Communication"-Elements in similar matter about 450 times, then 
> followed by similar Elements called "Speaker")
> 
> Kai Wörner
> 
> 
> 
> 
> 
> Bradley S. Huffman wrote:
> 
> > Hmmm, print out elmt's children and see what's there.  What version of jdom
> ?
> > 
> > Brad
> > 
> > Kai Woerner writes:
> > 
> > 
> >>
> >>Bradley S. Huffman wrote:
> >>
> >>
> >>>Use getContent instead of getChildren. getChildren gives a list of *only*
> >>>the element children.
> >>
> >>But the element elmt does only contain element children - no mixed 
> >>content whatsoever.
> >>
> >>Kai Wörner
> >>
> >>
> >>
> >>>Brad
> >>>
> >>>Kai Woerner writes:
> >>>
> >>>
> >>>
> >>>>I'm experiencing a very odd problem with 
> >>>>Element.addContent(index,Content). This is an altered snipplet from the 
> >>>>code I have:
> >>>>
> >>>>elmt.addContent(440, newComm);
> >>>>System.out.println("@inserted at:"+elmt.getChildren().indexOf(newComm));
> >>>>
> >>>>(elmt being a legal element in a jdom-tree, newComm being a new Element)
> >>>>
> >>>>- this would output "inserted  at: 220".
> >>>>
> >>>>Of course the code is a bit longer and more complicated, but these two 
> >>>>lines are exactly like in my code and the result is alwayy the same:
> >>>>elmt.addContent(200, newComm) would result in 100.
> >>>>
> >>>>Anybody having experienced something like that?
> >>>>
> >>>>Thanks,
> >>>>
> >>>>Kai Wörner
> >>>>
> >>>>_______________________________________________
> >>>>To control your jdom-interest membership:
> >>>>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@your
> ho
> >>
> >>st
> >>
> >>>>.com
> >>>
> >>>
> > _______________________________________________
> > To control your jdom-interest membership:
> > http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourho
> st.com
> > 



More information about the jdom-interest mailing list