[jdom-interest] setText() to replace children?

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Jul 11 07:50:53 PDT 2001

At 9:04 AM -0500 7/11/01, Brett McLaughlin wrote:
>> I certainly don't think that setText(...) should be recursive,
>> so for symmetry, getText() should not be either.
>> But, there is obviously a call from some folks to have a recursive-esque
>> getText() functionality.
>> So, maybe a getXPathText(), or a getText(boolean recurse).
>So far, this has seemed like the most sane decision. Current operations
>remain unchanged, while the ability to do things like Bob and Elliotte have
>described seem perfectly simple.  Thoughts?

No. -1. The  reason I suggested the change was not to add this functionality to JDOM. It's because what I suggested is the most natural, least surprising thing for getText() to do in the face of mixed content. Adding a new method to do this would make the API more complicated and still not fix the fundamental problem that the getText() method simply does not work with some very common XML patterns.

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|              http://www.ibiblio.org/xml/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      | 
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |

More information about the jdom-interest mailing list