SAX: Parser Factory class

Andrew n marshall (amarshal@usc.edu)
Thu, 16 Apr 1998 07:48:19 -0700


This is a multi-part message in MIME format.

------=_NextPart_000_0005_01BD690C.05BC4330
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

While it is great that there are so many SAX parsers available, the thing that
bothers me is that my application has to know what Parser to load in just to
use SAX. And this means that even is a SAX parser is available on the users
machine, they may still have to download the one I use to to run my
application.

If there is already a solution for this, then please let me know.

David Megginson had mentioned the sax.parser property as a possible solution,
but I would like to see the following my general solution:

public class org.sax.ParserFactory() {
/* static methods */
// Registers a SAX driver
public static void addParserFactory();
// Retrieves all registered SAX drivers
public static ParserFactory[] getParserFactorys();
// Conveince method to return a parser
// from the first registered driver
public static Parser createDefaultParser();
/* Instance Methods */
// Returns a new Parser
public Parser createParser();
// Various identifying methods
// Subject to change for what appropriate method
abstract public String getDriverName();
abstract public long getDriverVersion();
abstract public long getSAXVersion();
}
If the above was implemented, then the following piece of code in the
ParserFactory implementation could automatically register the SAX Driver.

static {
org.sax.ParserFactory.addParserFactory( new MyParserFactory() );
}

I think this is a relative clean and forward compatible way to handle SAX
Drivers. And simplifies life for SAX based application programmers. I
realize it is a bit heavy weight since it require that the Factory be an
abstract class instead of an interface, but I think the benefit is worth it.

Any thoughts?

Andrew n marshall
student - artist - programmer
http://www.media-electronica.com/anm-bin/anm
"Everyone a mentor, Everyone a pupil"

------=_NextPart_000_0005_01BD690C.05BC4330
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">

While=20 it is great that there are so many SAX parsers available, the thing that = bothers=20 me is that my application has to know what Parser to load in just to use = SAX.  And  this means that even is a SAX parser is available = on the=20 users machine, they may still have to download the one I use to to run = my=20 application.
 
If=20 there is already a solution for this, then please let me=20 know.
 
David=20 Megginson had mentioned the sax.parser property as a possible solution, = but I=20 would like to see the following my general solution:
 
public class =
org.sax.ParserFactory() {
   =
/* static methods */
   =
// Registers a SAX driver
   public static void =
addParserFactory();
   // Retrieves all =
registered SAX drivers
   public static =
ParserFactory[] getParserFactorys();
   // Conveince =
method to return a parser
   =
// from the first registered driver
   public static Parser =
createDefaultParser();
   =
/* Instance Methods */
   // Returns a new =
Parser
   public Parser =
createParser();
   =
// Various identifying methods
   =
// Subject to change for what appropriate =
method
   =
abstract public String =
getDriverName();
   =
abstract public long =
getDriverVersion();
   =
abstract public long =
getSAXVersion();
}

If the=20 above was implemented, then the following piece of code in the = ParserFactory=20 implementation could automatically register the SAX = Driver.

   static {
    =
  org.sax.ParserFactory.addParserFactory( new MyParserFactory() =
);
   =
}

 

I think this is a relative clean = and forward=20 compatible way to handle SAX Drivers.  And simplifies life for SAX = based=20 application programmers.  I realize it is a bit heavy weight since = it=20 require that the Factory be an abstract class instead of an interface, = but I=20 think the benefit is worth it.

Any thoughts?

 

Andrew n = marshall
 =20 student - artist - programmer
    http://www.media-electronica.com/anm-bin/anm
  &nb= sp;   "Everyone=20 a mentor, Everyone a pupil"

 
------=_NextPart_000_0005_01BD690C.05BC4330-- xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ To (un)subscribe, mailto:majordomo@ic.ac.uk the following message; (un)subscribe xml-dev To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)