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

RE: A Proposal for Refactoring SAX

  • From: Miles Sabin <msabin@c...>
  • To: "'xml-dev@i...'" <xml-dev@i...>
  • Date: Wed, 26 May 1999 14:37:37 +0100

sax parser stream
[Note: resend. xml-dev@m... seems to be
 a bit touchy at the mo']

Andy Clark wrote,
> Miles Sabin wrote,
> > I think we need a bit more detail, because, on the
> > face of it your proposal *completely* breaks both
> > forwards and backwards compatibility with SAX1.
>
> That's pretty much the question that we have to 
> answer: do we completely break the compatibility with 
> the old APIs to design the new SAX right; or do we 
> limit the growth of SAX because of the legacy issue?

Well, in its favour, your proposal would allow for
adapter classes (SAX1->SAX2 and SAX2->SAX1) which
lessens the impact somewhat.

In line with the new naming scheme we would probably
want to introduce some new system properties,

  org.xml.parser.stream  Name of stream parser class
  org.xml.parser.dom     Name of dom parser class

Consequently we could provide a SAX1 to SAX2 parser
adapter as follows. A SAX2 client app that wants
to interoperate with a SAX1 parser could define
org.xml.parser.stream as, eg.

  org.xml.parser.compat.SAX1Adapter

and org.xml.sax.parser as,

  com.foo.sax.LegacyParser

SAX1Adapter could be defined as thus,

  public class SAX1Adapter
    implements org.xml.parser.stream.Parser
  {
    private org.xml.sax.Parser itsAdaptee;

    public SAX1Adapter()
    {
      itsAdaptee = org.xml.sax.helpers.
        ParserFactory.makeParser();
    }

    // SAX2 parser methods forwarded to contained
    // SAX1 parser. Note there'd need to be
    // some juggling of argument types (because
    // they'll have shifted packages too) but
    // nothing particularly difficult.
  }

The SAX1 ParserFactory would resolve the SAX1 Parser
implementation via the old SAX1 system property.

Going in the opposite direction a SAX1 client app that
wants to use a SAX2 parser could set org.xml.sax.parser
to,

  org.xml.parser.compat.SAX2Adapter

and org.xml.parser.stream.parser as,

  com.foo.sax.NewParser

We then define SAX2Adapter similarly,

  public class SAX2Adapter
    implements org.xml.sax.Parser
  {
    private org.xml.parser.stream.Parser itsAdaptee;

    public SAX2Adapter()
    {
      itsAdaptee = org.xml.parser.stream.helpers.
        ParserFactory.makeParser();
    }

    // SAX1 parser methods forwarded to contained
    // SAX2 parser. Note there'd need to be
    // some juggling of argument types (because
    // they'll have shifted packages too) but
    // nothing particularly difficult.
  }

Incidently, I'm quite keen on the DOM parser stuff.
That'd ease some of the problems that the DOMs
current lack of a portable way of creating Documents
causes.

> I like your refactorization better! :) It's still
> clean and separated for everyone to have a standard
> way of doing things.

That ain't refactoring (not in my book anyway) I just
changed a few of the names ;-)

Cheers,


Miles

-- 
Miles Sabin                          Cromwell Media
Internet Systems Architect           5/6 Glenthorne Mews
+44 (0)181 410 2230                  London, W6 0LJ
msabin@c...           England

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/ and on CD-ROM/ISBN 981-02-3594-1
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.