Hi Chris
 
When you have XML like this
 
<pizza>
    <topping>cheese</topping>
    <topping>ham</topping>
</pizza>
 
Then when this gets parsed you'll have
 
Element (pizza)
    Text ("/n  ")
    Element(topping)
    Text ("/n  ")
    Element(topping)
    Text ("/n")
   
So in other worlds all the whitespace between elements is preserved in the XML object structure. This is important in data-centric XML applications such as editing hand-formatted XML documents and so forth. For data-centric applications this whitespace is usually irrelevant - indeed its often useful to trim it.
 
So there's a SAXReader option to allow whitespace to be trimmed via
 
SAXReader reader = new SAXReader();
reader.setStripWhitespaceText(true);
 
Also you may find that because of parser buffer issues, a block of text can sometimes be split across several text nodes. To solve this you can ensure that adjacent text nodes are merged via this
 
reader.setMergeAdjacentText(true);
 
All of the above may help you get an XML tree that matches your mental model of what you think it should be.

James
----- Original Message -----
Sent: Tuesday, March 19, 2002 10:53 PM
Subject: [dom4j-user] elementData, excess content?

I've been working on a JTree based component that allows moving around nodes with a popup menu and such.  I've run into quite a bit of weird behaviour when trying to get a move function to work though.  I use Forte for editing, so I've been watching the variables in the debugger as my program runs and it came to my attention that in any object with elementData every element in it is alternated with a DefaultTextElement.  This seems extra strange seeing as all of the DefaultTextElement's in there just contain empty strings!  This really throws off my index arrangement the way that I'm doing things, I can change and make it work anyways if I want though.  I'm just really curious as to why there are DefaultTextElements stuck between every DefaultElement?
 
 
Chris Golden
_______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to