[jdom-interest] setIgnoringElementContentWhitespace inoperant ?
Bradley S. Huffman
hip at a.cs.okstate.edu
Thu Dec 9 09:59:24 PST 2004
Ken Roberts writes:
> On Thu, 2004-12-09 at 06:38, Elliotte Harold wrote:
> > setIgnoringAllWhitespace() is the wrong name for this functionality. Do
> > you really want to throw away all white space?
> > Eveninrecordlikedocumentsthiscouldbeveryhardtoread. I think what you
> > really want to do is throw away all text nodes that consist of white
> > space exclusively, but retain all white space in text nodes that contain
> > any non-whitespace characters. The correct name for this method would
> > be setIgnoringBoundaryWhitespace(). The functionality proposed is fine.
> > I just want to make sure we get the name right.
> What something like this should do is convert an infinite amount of
> whitespace in a single instance into a single space. Not sure about
> "middle" text, but an equivalent of String.trim() would probably be OK
> anywhere if you choose this option. Keep in mind that it's an OPTION
> rather than a change in default behavior.
You have to be careful when trimming whitespace or something like
<p>This is a
could end up as
<p>This is a<i>test</i>sentence.</p>
which may or may not be what is really desired.
More information about the jdom-interest