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

Re: ANN: SAX 2.0 extension proposals.

  • From: David Megginson <david@m...>
  • To: xml-dev@x...
  • Date: 21 Feb 2000 16:38:05 -0500

ann sax
Miles Sabin <msabin@c...> writes:

> Interesting, but, I think, orthogonal to the factory part of
> my proposals. As a means of constucting chains of SAX event
> processors it's quite nice (tho' I have a bit of a horror of
> String based specifications), but it doesn't help to resolve
> the bootstrap issue. At some point or another you'll still have
> to programmatically reference some vendors parser. That means
> either hard-wiring a reference to that parser into mainline
> code, or coming up with an ad hoc factory solution.

Or allowing apps to pull it from the command line or a configuration
file (though it's best still to provide a default).

> Better to put that in the SAX core, I'd say.

For the SAX core, I'm leaning towards a rewrite of the SAX1
ParserFactory into XMLReaderFactory, only with methods that throw
SAXException (as David B. suggested).  It will look like this:


====================8<====================8<====================
  package org.xml.sax.helpers;
  import org.xml.sax.SAXException;
  import org.xml.sax.XMLReader;

  final public class XMLReaderFactory
  {

      private XMLReaderFactory ()
      {
      }

      public static XMLReader makeXMLReader ()
	  throws SAXException
      {
	  String className = System.getProperty("org.xml.sax.driver");
	  if (className == null) {
	      throw new
		  SAXException("System property org.xml.sax.driver not specified");
	  } else {
	      return makeXMLReader(className);
	  }
      }

      public static XMLReader makeXMLReader (String className)
	  throws SAXException
      {
	  try {
	      return (XMLReader)(Class.forName(className).newInstance());
	  } catch (ClassNotFoundException e1) {
	      throw new SAXException("SAX2 driver class " + className +
				     " not found", e1);
	  } catch (IllegalAccessException e2) {
	      throw new SAXException("SAX2 driver class " + className +
				     " found but cannot be loaded", e2);
	  } catch (InstantiationException e3) {
	      throw new SAXException("SAX2 driver class " + className +
				     " loaded but cannot be instantiated (no empty public constructor?)",
				     e3);
	  } catch (ClassCastException e4) {
	      throw new SAXException("SAX2 driver class " + className +
				     " does not implement XMLReader", e4);
	  }

      }

  }
====================8<====================8<====================


All the best,


David

-- 
David Megginson                 david@m...
           http://www.megginson.com/

***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/threads.html
***************************************************************************

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.