org.xml.sax.AttributeMap

Antony Blakey antony at n-space.com.au
Wed Feb 25 02:24:42 GMT 1998


Don Park wrote:
> How about replacing the five with following method and three constants?
> 
> public static final int NAME = 0;
> public static final int PUBLIC_ID = 1;
> public static final int SYSTEM_ID = 2;
> 
> public abstract String[] getDataInfo (int index);
> 
> Since AttributeList is valid only within startElement method, you can reuse
> a single string array rather allocate a new one per getEntityInfo method.
> If the method returns null, then it is attribute has no info.
> 
> If you haven't guessed by now, the constants above are used to index into
> the returned array.  Implementations should take steps to make sure the size
> of the returned array is 3 and stuff null for NAME if it is not a notation.

Why would you not simply return a strongly typed data item (ignoring the
names)

public abstract DataInfo getDataInfo(int index);

public interface EntityInfo {
  public String getName();
  public String getPublicID();
  Public String getSystemID();
}

As far as reuse of values is concerned however, I think this is a very
bad idea: startElement defines a new context, so reusing the parameters
to that call is workable, however reusing the result from the
getDataInfo call is a different kettle of fish. It would be better (if
you are so concerned) to keep a pool that you return so that they are
not reused within the context of a startElement call. This may seem like
more work on the part of the parser implementor, but you shouldn't push
this complexity onto the users of the parser when you can safely hide it
within the parser. The parser writer can make the effort for
efficiencies sake.

+----------------------------------+
|          Antony Blakey           |
|         N-Space Pty Ltd          |
|    Java - CORBA - SGML - XML     |
|   mailto:antony at n-space.com.au   |
|     http://www.n-space.com.au    |
+----------------------------------+

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list