Skip to Content.
Sympa Menu

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

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: peter murray-rust <pm286 AT cam.ac.uk>
  • To: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] Empty text elements
  • Date: Sat, 03 Sep 2005 11:06:39 +0100

If I set the value of Text nodes to null, the value is actually set to an empty String ("").
String s = null;
Text t = new Text(s);
assertNotNull("nullValue", t.getValue());
assertEquals("nullValue", "", t.getValue());
t.setValue("b");
assertEquals("nonEmptyString", "b", t.getValue());
t.setValue(s);
assertNotNull("nullValue", t.getValue());
assertEquals("nullValue", "", t.getValue());
however copying a null Text node throws a NPE
t = new Text((Text)null);

The documentation does not comment on null strings and neither routine throws an exception. If all the above is expected, could it be mentioned in the documentation.

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

P.



Peter Murray-Rust
Unilever Centre for Molecular Sciences Informatics
University of Cambridge,
Lensfield Road, Cambridge CB2 1EW, UK
+44-1223-763069




Archive powered by MHonArc 2.6.24.

Top of Page