Package mf.org.apache.xml.resolver

Examples of mf.org.apache.xml.resolver.CatalogException


    factory.setNamespaceAware(false);
    factory.setValidating(false);
    try {
      builder = factory.newDocumentBuilder();
    } catch (ParserConfigurationException pce) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    Document doc = null;

    try {
      //MF
      doc = (Document) builder.parse(is);
    } catch (SAXException se) {
      throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
    }

    Element root = doc.getDocumentElement();

    String namespaceURI = Namespaces.getNamespaceURI(root);
    String localName    = Namespaces.getLocalName(root);

    String domParserClass = getCatalogParser(namespaceURI,
               localName);

    if (domParserClass == null) {
      if (namespaceURI == null) {
  catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
              + localName);
      } else {
  catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
              + "{" + namespaceURI + "}"
              + localName);
      }
      return;
    }

    DOMCatalogParser domParser = null;

    try {
      domParser = (DOMCatalogParser) Class.forName(domParserClass).newInstance();
    } catch (ClassNotFoundException cnfe) {
      catalog.getCatalogManager().debug.message(1, "Cannot load XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (InstantiationException ie) {
      catalog.getCatalogManager().debug.message(1, "Cannot instantiate XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (IllegalAccessException iae) {
      catalog.getCatalogManager().debug.message(1, "Cannot access XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (ClassCastException cce ) {
      catalog.getCatalogManager().debug.message(1, "Cannot cast XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    Node node = root.getFirstChild();
    while (node != null) {
      domParser.parseCatalogEntry(catalog, node);
View Full Code Here


    ch = nextch;
    nextch = nextChar();
  }

  if (nextch < 0) {
    throw new CatalogException(CatalogException.UNENDED_COMMENT,
             "Unterminated comment in catalog file; EOF treated as end-of-comment.");
  }

  // Ok, we've found the end of the comment,
  // loop back to the top and start again...
View Full Code Here

    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, true, loader != null ? loader : this.getClass().getClassLoader()).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);
    }
  }
View Full Code Here

TOP

Related Classes of mf.org.apache.xml.resolver.CatalogException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.