[jdom-interest] getText() and getAttributeValue()

Jon Baer jonbaer at digitalanywhere.com
Thu Feb 14 13:34:26 PST 2002

This might sound like a dumb question, but what would occur with XML that doesn't
validate it's DTD in which case default attribute values are omitted.  In the case of
pulling say a <foo/> where attribute bar="1" by default according to the DTD/XSD
(like the case of the XHTML example from before), in which case
getAttributeValue("bar") would yield null vs. "1".

- Jon

Jason Hunter wrote:

> > Why would any method of any class in any API that returns String want to
> > return null instead of empty string?
> I think Phil said it best.  At the relatively low-level of JDOM, more
> information is better.
> As a second argument, we need
> Attribute Element.getAttribute(String)
> to return null if the attribute doesn't exist.  We're not going to
> return a NO_ATTRIBUTE constant or anything fancy.  So for consistency,
> we should have getAttributeValue(String) return null also.  The "value"
> method is a convenience on top of the former.
> > If one were REALLY concerned with making sure the
> > programmer was aware of his error, getAttributeValue() would have been
> > written to throw a java.util.NoSuchElementException or such a long time ago.
> How ironic!  It was!  We changed to null after a vote.
> -jh-
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

More information about the jdom-interest mailing list