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

SAX Proposal: new AttributesBuilder interface

  • From: James Strachan <james@m...>
  • To: xml-dev@l...
  • Date: Wed, 08 Nov 2000 12:48:32 +0000

jdom add attribute
I hope this is the correct list for such things, forgive me if it isn't.
 
<motivation>
Right now a SAX parser uses its own internal data structure to implement the
SAX Attributes interface. Higher levels above SAX often want to use their
own data structure to store attribute information. For example to allow them
to be mutable. This often leads to unnecessary conversion from one data
structure to another.
 
A good example is JDOM ( http://www.jdom.org <http://www.jdom.org> ) which
takes the SAX Attriibutes object and builds its own List of Attribute
objects to represent its attribute information. This copying from an
Attributes instance to a different data structure is needless redundancy.
 
This proposal attempts to put in place a simple mechanism by which
"attribute data structure duplication" can be avoided.
</motivation>
 
<proposal>
Consider the following new interface.
 
public interface AttributesBuilder {
 
    /** creates an empty Attributes instance */
    public Attributes createAttributes();
 
    /** @return a possibly different Attributes instance
      * which has the new attribute added */
    public Attributes addAttribute ( Attributes attributes,
        String localName, 
        String namespacePrefix, 
        String namespaceURI, 
        String type, // e.g. CDATA 
        String value
    );
}
 
The above interface abstracts away the creation of a new Attributes
implementation and adding of individual attribute instances to it. Let us
also make a change to the XMLReader class then has a new method added to
it:-
 
public interface XMLReader {
    ...
    public void setAttributesBuilder( AttributesBuilder );
}
 
The implementation of XMLReader will come with a standard implementation of
AttributesBuilder. But this new interface and method allows users of the
XMLReader to override how to build an Attributes instance to use a more
applicable data structure.
So JDOM could build the List of Attribute instances it wants, providing it
implements the Attributes and AttributesBuilder interefaces correctly.
</proposal>
 
<implications>
The SAX API gets one new interface and one new method.
 
parser/XMLReader implementors need to implement the new
interface.</implications>
<implications>
 
<issues>
are the arguments for the AttributesBuilder.addAttribute() correct? Will
this new API cause problems for the parser writers?
</issues>
 
Thoughts?
 
 
J.
 
James Strachan
=============
email: james@m... <mailto:james@m...> 
web: http://www.metastuff.com <http://www.metastuff.com> 



If you are not the addressee of this confidential e-mail and any
attachments, please delete it and inform the sender; unauthorised
redistribution or publication is prohibited. Views expressed are those of
the author and do not necessarily represent those of Citria Limited.

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.