[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)

  • From: "Matthew Gertner" <matthewg@p...>
  • To: "xml-dev Mailing List" <xml-dev@i...>
  • Date: Wed, 14 Jan 1998 14:49:58 +0100

xml get all attributes getattribute
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.