<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content='"MSHTML 4.72.2106.6"' name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=18061914-16041998><FONT color=#000000 face=Arial size=2>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.</FONT></SPAN></DIV>
<DIV><SPAN class=18061914-16041998><FONT color=#000000 face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=18061914-16041998><FONT color=#000000 face=Arial size=2>If
there is already a solution for this, then please let me
know.</FONT></SPAN></DIV>
<DIV><SPAN class=18061914-16041998><FONT color=#000000 face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=18061914-16041998><FONT color=#000000 face=Arial size=2>David
Megginson had mentioned the sax.parser property as a possible solution, but I
would like to see the following my general solution:</FONT></SPAN></DIV>
<DIV><SPAN class=18061914-16041998><FONT color=#000000 face=Arial
size=2></FONT></SPAN> </DIV><PRE><SPAN class=18061914-16041998><FONT size=1>public class org.sax.ParserFactory() {</SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT size=1></SPAN><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> /* static methods */</FONT></SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT size=1></SPAN><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> </FONT></SPAN>// Registers a SAX driver</FONT></PRE><PRE><SPAN class=18061914-16041998><FONT size=1> public static void addParserFactory();</SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT size=1></SPAN> // Retrieves all registered SAX drivers</FONT></PRE><PRE><SPAN class=18061914-16041998><FONT size=1> public static ParserFactory[] getParserFactorys();</SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1> </FONT></FONT></SPAN><FONT size=1>// Conveince method to return a parser</FONT></PRE><PRE><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> //</FONT></SPAN> from the first registered driver</FONT></PRE><PRE><SPAN class=18061914-16041998><FONT size=1> public static Parser createDefaultParser();</SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT size=1></SPAN><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> /* Instance Methods */</FONT></SPAN></FONT></PRE><PRE><FONT color=#000000 face="Courier New"><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1></FONT></FONT></SPAN><FONT size=1><SPAN class=18061914-16041998> // Returns a new Parser</SPAN></FONT></FONT><FONT size=1></FONT></PRE><PRE><FONT color=#000000 face="Courier New"><SPAN class=18061914-16041998><FONT size=1></FONT></SPAN></FONT><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> public Parser createParser();</FONT></SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1></FONT></FONT></SPAN><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> // Various identifying methods</FONT></SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1></FONT></FONT></SPAN><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> // Subject to change for what appropriate method</FONT></SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1></FONT></FONT></SPAN><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> abstract public String getDriverName();</FONT></SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1></FONT></FONT></SPAN><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> abstract public long getDriverVersion();</FONT></SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1></FONT></FONT></SPAN><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> abstract public long getSAXVersion();</FONT></SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1></FONT></FONT></SPAN><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New">}</FONT></SPAN></FONT></PRE>
<DIV>
<P><SPAN class=18061914-16041998><FONT color=#000000 face=Arial size=2>If the
above was implemented, then the following piece of code in the ParserFactory
implementation could automatically register the SAX Driver.</FONT></SPAN></P><PRE><SPAN class=18061914-16041998><FONT color=#000000 face=Arial size=2></FONT></SPAN><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1> static {</FONT></FONT></SPAN><FONT size=1></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1></FONT></FONT></SPAN><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> org.sax.ParserFactory.addParserFactory( new MyParserFactory() );</FONT></SPAN></FONT></PRE><PRE><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"><FONT size=1></FONT></FONT></SPAN><FONT size=1><SPAN class=18061914-16041998><FONT color=#000000 face="Courier New"> }</FONT></SPAN></FONT></PRE>
<P><BIG><FONT color=#800080></FONT></BIG> </P>
<P><BIG><FONT color=#800080></FONT></BIG><SPAN class=18061914-16041998><FONT
color=#000000 face=Arial size=2>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.</FONT></SPAN></P>
<P><SPAN class=18061914-16041998><FONT color=#000000 face=Arial
size=2></FONT></SPAN><SPAN class=18061914-16041998><FONT color=#000000
face=Arial size=2>Any thoughts?</FONT></SPAN></P>
<P> </P>
<P><BIG><FONT color=#800080>Andrew n marshall</FONT></BIG><BR><SMALL>
student - artist - programmer<BR> <A
href="http://www.media-electronica.com/anm-bin/anm"
style="TEXT-DECORATION: none">http://www.media-electronica.com/anm-bin/anm</A><BR> "Everyone
a mentor, Everyone a pupil"</SMALL></P></DIV>
<DIV> </DIV></BODY></HTML>