If SAX is supposed to be abstract and extensible, then it needs a
substantial rework. Something like this would be much more extensible:
interface DocumentHandler {
void startElement(StartElementEvent event);
void endElement(EndElementEvent event);
void characters(CharactersEvent event);
//...
}
Simplicity was the main design goal of SAX.
Why do we get abstraction and extensibility for attributes but for
nothing else?
> Also, this makes iteration easy but
> finding attributes by name very hard.
>
> An AttributeMap interface should be used, but:
>
> 1) It should provide a standard iterator interface (this is the only
> reasonable way to iterate over a map).
This has all the inefficiencies that I listed for Enumeration.
Requiring an object to be allocated on each start-tag is really not a
good idea (it makes a measurable difference to performance in Java).
Something like this:
interface AttributeList {
int length(); // or maybe size
String getValue(int i); // or maybe valueAt
String getName(int i); // or maybe nameAt
String get(String name);
}
would be significantly more efficient.
At the very least provide an isEmpty() so that I don't have to do the
allocation in the common case there are no attributes.
James