[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] AttributeMap (was Re: Announcement: SAX 1998-01-12 Draft)
James Clark wrote: >AttributeMap seems way too complicated. > >I don't think using Enumeration to get all the attributes is a good >idea. JDK 1.2 replaces Enumeration by Iterator. The method names in >Enumeration are a real disaster in the context of XML: nextElement >returns the name of the next attribute! This is not going to be an >efficient way to get at all the attributes (which is a common >application need). To get at all the attributes, I have first to create >an Enumeration (an unnecessary allocation). Then for each attribute >name: I have to make two non-final method calls (nextElement and >hasMoreElements); I then have a cast (which must be checked) from Object >to String; I then have to look the attribute up using getValue. Compare >this to the simple interface I suggested: > >void startElement(String elementName, String[] attributeNames, String[] >attributeValues, int nAttributes) I agree that the AttributeMap is too complicated. On the other hand, your alternate proposal seems questionable. Passing three parameters to the event handler may be simple, but this eliminates any abstraction, which makes it hard to extend the interface cleanly. 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). 2) It should deliver attributes values as strings (the current getValue) only. All of the "is" methods seem *way* out of scope for SAX. We decided we didn't want DOM building capability (or a similar level of functionality), so why is this information necessary? This spec very accurately represents a consensus of the various points discussed on the list, but I don't remember any discussion about getting additional information about the attribute beyond the value. Did I miss something? IMHO, the following perfectly sufficient for the time being: public Iterator getIterator (); public String getValue (String attributeName); We might want to consider making the map from a string to an Attribute object: public Attribute getAttribute (String attributeName); The Attribute interface would contain only: public String getName (); public String getValue (); This would make extensibility easier in moving towards an advanced version of SAX with DOM-building power. Matthew xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i... Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ To (un)subscribe, mailto:majordomo@i... the following message; (un)subscribe xml-dev To subscribe to the digests, mailto:majordomo@i... the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@i...)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|