示例#1
0
  /** Create DOM builder using JAXP libraries. */
  static DocumentBuilder makeBuilder(boolean validate) throws IOException, SAXException {

    DocumentBuilder builder;
    DocumentBuilderFactory factory;

    // create factory according to javax.xml.parsers.SAXParserFactory property
    // or platform default (i.e. com.sun...)
    try {
      factory = DocumentBuilderFactory.newInstance();
      factory.setValidating(validate);
      factory.setNamespaceAware(false);
    } catch (FactoryConfigurationError err) {
      notifyFactoryErr(err, "javax.xml.parsers.DocumentBuilderFactory"); // NOI18N
      throw err;
    }

    try {
      builder = factory.newDocumentBuilder();
    } catch (ParserConfigurationException ex) {
      SAXException sex = new SAXException("Configuration exception."); // NOI18N
      ErrorManager emgr = ErrorManager.getDefault();
      emgr.annotate(sex, ex);
      emgr.annotate(
          sex,
          "Can not create a DOM builder!\nCheck javax.xml.parsers.DocumentBuilderFactory property and the builder library presence on classpath."); // NOI18N
      throw sex;
    }

    return builder;
  }
示例#2
0
 /** Annotate & notify the exception. */
 private static void notifyNewSAXParserEx(Exception ex) {
   ErrorManager emgr = ErrorManager.getDefault();
   emgr.annotate(
       ex,
       "Can not create a SAX parser!\nCheck javax.xml.parsers.SAXParserFactory property features and the parser library presence on classpath."); // NOI18N
   emgr.notify(ex);
 }
示例#3
0
 /** Annotate & notify the error. */
 private static void notifyFactoryErr(Error err, String property) {
   ErrorManager emgr = ErrorManager.getDefault();
   emgr.annotate(
       err,
       "Can not create a factory!\nCheck "
           + property
           + "  property and the factory library presence on classpath."); // NOI18N
   emgr.notify(err);
 }