Skip to Content.
Sympa Menu

xom-interest - RE: [XOM-interest] Element.add()

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: "Michael McEniry" <mmceniry AT itsc.uah.edu>, "XOM-interest" <XOM-interest AT lists.ibiblio.org>
  • Subject: RE: [XOM-interest] Element.add()
  • Date: Thu, 19 Sep 2002 13:40:05 -0400

At 11:55 AM -0500 9/19/02, Michael McEniry wrote:
Is it confusing that Element is playing multiple container roles?
- Attribute map (map-like set?)
- namespace set (set-like map?)
- Element list
- Node/TreeNode

This may be confusing, but if it is that's because XML is confusing here. I'm not going to fix that.

The method names should consistently identify the role and
function. For example, Element-as-Attribute-map should have
addAttribute, removeAttribute, and getAttribute.

Yes, that does seem to be what people like, so that is probably what it will become. Fortunately, modern refactoring tools make these sorts of changes very easy to implement. :-)

Why does Element have both "Attribute getAttribute(String name)"
and "String readAttribute(String name)"?


The former returns an Attribute object. The latter returns an attribute value. Originally, I just used getAttribute().getValue() but that's asking for NullPointerExceptions.

This is the second or third time I've had to answer this question, so maybe "readAttribute" is not the best name. Should it just be "getAttributeValue()" perhaps? Longer to type, but maybe more obvious.
--

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo AT metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
| http://www.cafeconleche.org/books/xian2/ |
| http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+




Archive powered by MHonArc 2.6.24.

Top of Page