static Object load(InputStream is, String name, Handler handler) {
   try {
     try {
       XMLReader reader = XMLUtil.createXMLReader();
       reader.setEntityResolver(handler);
       reader.setContentHandler(handler);
       reader.parse(new InputSource(is));
       return handler.getResult();
     } finally {
       is.close();
     }
   } catch (SAXException ex) {
     if (System.getProperty("org.netbeans.optionsDialog") != null) {
       System.out.println("File: " + name);
       ex.printStackTrace();
     }
     return handler.getResult();
   } catch (IOException ex) {
     if (System.getProperty("org.netbeans.optionsDialog") != null) {
       System.out.println("File: " + name);
       ex.printStackTrace();
     }
     return handler.getResult();
   } catch (Exception ex) {
     if (System.getProperty("org.netbeans.optionsDialog") != null) {
       System.out.println("File: " + name);
       ex.printStackTrace();
     }
     return handler.getResult();
   }
 }
コード例 #2
0
 public void parse(java.io.Reader src) throws IOException {
   try {
     org.xml.sax.XMLReader reader = org.openide.xml.XMLUtil.createXMLReader(false, false);
     reader.setContentHandler(this);
     reader.setEntityResolver(this);
     org.xml.sax.InputSource is = new org.xml.sax.InputSource(src);
     try {
       reader.setProperty("http://xml.org/sax/properties/lexical-handler", this); // NOI18N
     } catch (SAXException sex) {
       XMLSettingsSupport.err.warning(
           "Warning: XML parser does not support lexical-handler feature."); // NOI18N
     }
     reader.parse(is);
   } catch (SAXException ex) {
     IOException ioe = new IOException();
     ioe.initCause(ex);
     throw ioe;
   }
 }