[jdom-interest] Re: First impressions and some suggestions

Jason Hunter jhunter at collab.net
Fri Jun 9 13:51:10 PDT 2000


> Or how about this case:
> 
> <name><first>Alex</first><last>Chaffee</last></name>
> 
> Should JDOM insert extra white space between "Alex" and "Chaffee"
> because that's what most people would initially expect?  

Elliotte, you're losing me here.  The code is this.

String first = name.getChild("first").getContent();
String last = name.getChild("last").getContent();

The question is does

<name>
  <first>
     Alex
  </first>
  <last>
    Chaffee
  </last>
<name>

behave the same, or not, for the common case of calling getContent().  I
think it should because that's what developers expect, and
getContent(true) can work for those relatively rare cases where you want
the whitespace.  In fact, it would take something on the order of an
atom bomb to move me from my position after this week at JavaOne.  I've
heard in presentations, "Now, what's confusing about DOM is that there's
this whitespace around the text that you don't expect" and I've
conferred with Allen Holub whose design opinions I respect, and he
clearly preferred getContent() not returning surrounding whitespace.  I
also checked with Simon St.Laurent, and he's signed off as well.

We are still fully spec compliant.  We just have two calls, one that
returns surrounding whitespace and one that doesn't.  The one that
doesn't is less typing because it's more common.  After all, the spec
says, "Such white space is typically not intended for inclusion in the
delivered version of the document" and this is a Java-based document
object model.

-jh-



More information about the jdom-interest mailing list