[jdom-interest] Merging text nodes

Bradley S. Huffman hip at a.cs.okstate.edu
Sat Feb 16 17:43:28 PST 2002


Elliotte Rusty Harold writes:

> DOM3 is beginning to add methods to *normalize* documents and 
> elements. In brief this means that all CDATA section nodes are 
> converted to text nodes and all adjacent text nodes are combined. 
> Thus each text node contains the maximum possible contiguous run of 
> text.
> 
> In JDOM we are mostly doing this automatically. That is, the Element 
> class notices if one Text node is added immediately after another and 
> if so merges them. However, there are a few holes in the process. For 
> instance, if two text nodes are separated by an Element node which is 
> then deleted, the newly adjacent text nodes are not merged. Is this 
> something that's worth fixing?

Just looked at ContentList and it should be fairly easy to do, come
to think of it the merge should probably be taken out of Element and
moved to ContentList so Text, CDATA adds are consistent.

I like consistent behaviour, +1 for me.

Brad



More information about the jdom-interest mailing list