src/main/java/org/jboss/util/xml/catalog/readers/SAXCatalogReader.java
public void readCatalog(Catalog catalog, InputStream is) 
    throws IOException, CatalogException {

    // Create an instance of the parser
    if (parserFactory == null && parserClass == null) {
      debug.message(1, "Cannot read SAX catalog without a parser");
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    debug = catalog.getCatalogManager().debug;
    EntityResolver bResolver = catalog.getCatalogManager().getBootstrapResolver();

    this.catalog = catalog;

    try {
      if (parserFactory != null) {
	SAXParser parser = parserFactory.newSAXParser();
	SAXParserHandler spHandler = new SAXParserHandler();
	spHandler.setContentHandler(this);
	if (bResolver != null) {
	  spHandler.setEntityResolver(bResolver);
	}
	parser.parse(new InputSource(is), spHandler);
      } else {
	Parser parser = (Parser) Class.forName(parserClass).newInstance();
	parser.setDocumentHandler(this);
	if (bResolver != null) {
	  parser.setEntityResolver(bResolver);
	}
	parser.parse(new InputSource(is));
      }
    } catch (ClassNotFoundException cnfe) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (IllegalAccessException iae) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (InstantiationException ie) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (ParserConfigurationException pce) {
      throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
    } catch (SAXException se) {
      Exception e = se.getException();
      // FIXME: there must be a better way
      UnknownHostException uhe = new UnknownHostException();
      FileNotFoundException fnfe = new FileNotFoundException();
      if (e != null) {
	if (e.getClass() == uhe.getClass()) {
	  throw new CatalogException(CatalogException.PARSE_FAILED,
				     e.toString());
	} else if (e.getClass() == fnfe.getClass()) {
	  throw new CatalogException(CatalogException.PARSE_FAILED,
				     e.toString());
	}
      }
      throw new CatalogException(se);
    }
  }
public void readCatalog(Catalog catalog, InputStream is) 
    throws IOException, CatalogException {

    // Create an instance of the parser
    if (parserFactory == null && parserClass == null) {
      debug.message(1, "Cannot read SAX catalog without a parser");
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    debug = catalog.getCatalogManager().debug;
    EntityResolver bResolver = catalog.getCatalogManager().getBootstrapResolver();

    this.catalog = catalog;

    try {
      if (parserFactory != null) {
	SAXParser parser = parserFactory.newSAXParser();
	SAXParserHandler spHandler = new SAXParserHandler();
	spHandler.setContentHandler(this);
	if (bResolver != null) {
	  spHandler.setEntityResolver(bResolver);
	}
	parser.parse(new InputSource(is), spHandler);
      } else {
	Parser parser = (Parser) Class.forName(parserClass).newInstance();
	parser.setDocumentHandler(this);
	if (bResolver != null) {
	  parser.setEntityResolver(bResolver);
	}
	parser.parse(new InputSource(is));
      }
    } catch (ClassNotFoundException cnfe) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (IllegalAccessException iae) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (InstantiationException ie) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (ParserConfigurationException pce) {
      throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
    } catch (SAXException se) {
      Exception e = se.getException();
      // FIXME: there must be a better way
      UnknownHostException uhe = new UnknownHostException();
      FileNotFoundException fnfe = new FileNotFoundException();
      if (e != null) {
	if (e.getClass() == uhe.getClass()) {
	  throw new CatalogException(CatalogException.PARSE_FAILED,
				     e.toString());
	} else if (e.getClass() == fnfe.getClass()) {
	  throw new CatalogException(CatalogException.PARSE_FAILED,
				     e.toString());
	}
      }
      throw new CatalogException(se);
    }
  }
Parse an XML Catalog stream.

@param catalog The catalog to which this catalog file belongs
@param is The input stream from which the catalog will be read

@throws MalformedURLException Improper fileUrl
@throws IOException Error reading catalog file
@throws CatalogException A Catalog exception