[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: SAX: towards a solution

  • From: James Clark <jjc@j...>
  • To: xml-dev Mailing List <xml-dev@i...>
  • Date: Sun, 04 Jan 1998 13:16:34 +0700

sax applet xml
David Megginson wrote:
> 
> James Clark writes:
> 
>  > I don't think using java.util.Dictionary is a good idea:
>  >
>  > 1. JDK 1.2 provides a new Map interface which replaces Dictionary.
>  >
>  > 2. java.util.Dictionary is an abstract base class not an interface.
>  >
>  > 3. java.util.dictionary is weakly typed: it doesn't enforce the
>  > requirement that keys be strings, and it requires values to be cast to
>  > strings.
>  >
>  > I think it would be much better to have an Attributes interface and also
>  > a convenience adapter class that provides a Dictionary implementation in
>  > terms of that interface.
> 
> I would like to avoid java.util.Map to keep SAX applet-friendly (it
> will be years before most browsers deployed support even 1.1).

I agree.  We should have an interface specifically for Attributes and
implementations of Map and Dictonary on top of that.

>  I
> agree that Dictionary is far less than ideal -- what do you imagine
> the attributes interface looking like?

/**
 * An XmlAttributeSet is a set of named attributes each
 * with a string value.
 * Both specified and defaulted values are included
 * and are not distinguished.
 * Implied attributes are not included.
 * The XML processor is free to modify the AttributeSet after the
 * application returns from startElement.
 * The application can use clone to make a copy of the AttributeSet
 * which will not be modified by the XML processor.
 */

public interface XmlAttributeSet extends Cloneable {
  /**
   * Return the value of the attribute with this name, or null is the
   * set does not include an attribute.
   */
  String get(String name);

  /**
   * Return the number of attributes in the set.
   */
  int getSize();

  /**
   * Get the name of the i-th attribute, where i is greater than or
   * equal to 0 and less than the number of attributes in the set.
   * The order of the attributes is not defined.
   */
  String getName(int i);

  /**
   * Get the value of the i-th attribute, where i is greater than or
   * equal to 0 and less than the number of attributes in the set.
   */
  String getValue(int i);
}

You could use an Iterator or Enumeration instead of
getSize/getName/getValue, but I think it would probably be more
complicated and less efficient.

James

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.