[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] SAX Proposal: new AttributesBuilder interface
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|