Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Empty text elements

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: peter murray-rust <pm286 AT cam.ac.uk>
  • Cc: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Empty text elements
  • Date: Sun, 04 Sep 2005 06:24:47 -0400

peter murray-rust wrote:
If I set the value of Text nodes to null, the value is actually set to an empty String ("").

I worried about this a great deal in the early days. There's no perfect solution here. The issue is that XML has no real understanding of null. Thus almost everywhere in the model part of XOM, null is treated the same as the empty string. You're right. I should document what's going on better though.

Hmm, it occurs to me now that it might have made sense to disallow text nodes with no content; i.e. throw an exception when setting the value of a text node to either null or the empty string. There's a lot of icky code in the XOM internals to handle the case of text nodes with empty content that could have been avoided. However, changing it now would probably have unintended consequences, and I suspect it's too late to change that now. :-(

On a related note, is there a convenience method for removing text Nodes with zero-length strings?

No. There isn't.

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim




Archive powered by MHonArc 2.6.24.

Top of Page