Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Are the Attributes and Namespaces classes necessary?

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: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] Are the Attributes and Namespaces classes necessary?
  • Date: Wed, 25 Sep 2002 10:07:56 -0400

It's occurred to me that we could further simplify XOM by removing the Attributes and Namespaces classes from the public API. Instead we would add the following four methods to Element:

public final Attribute getAttribute(int i)
public final int getAttributeCount()
public final String getNamespacePrefix(int i)
public final int getNamespaceDeclarationCount()

This would be a net reduction of three methods and two classes from the API. (We'd add four new methods to Element, remove two existing methods from Element, remove the three methods from Namespaces, and the two methods from Attributes)

Advantages (besides reduced complexity):

1. The attributes and namespaces requested would always be live

2. The API for attributes and namespace declarations is much more consistent with that for child nodes.

Disadvantages:

1. The Element class is two methods more complex.

2. Taking a persistent snapshot of attributes or namespaces, would require a little more work on the part of the client programmer. (How common is this use-case anyway?) At some point, I do foresee adding a generic NodeList class that might be able to be used for this purpose.

The more I look at this, the more I like it. Thoughts? Comments?

I'd also like to explore if it might also be possible to remove the Elements class. However, that's a lot trickier because the getChildElements() methods are more useful in practice, and because of the filters via name and namespace. Removing Elements might not result in a net reduction in complexity.

--
Elliotte





Archive powered by MHonArc 2.6.24.

Top of Page