OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   SAX Proposal: new AttributesBuilder interface

[ Lists Home | Date Index | Thread Index ]
  • From: James Strachan <james@metastuff.com>
  • To: xml-dev@lists.xml.org
  • Date: Wed, 08 Nov 2000 12:48:32 +0000

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@metastuff.com <mailto:james@metastuff.com> 
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.




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS