public boolean parseXmlResource(Object resourceName,InputSource source){
  XMLReader reader;
  source.setEncoding("UTF8");
  try {
    reader=XMLReaderFactory.createXMLReader();
  }
 catch (  SAXException e) {
    if (logger.isLoggable(Level.SEVERE)) {
      logger.warning("Failed to create reader for " + resourceName + ": "+ e.getMessage());
    }
    return false;
  }
  boolean status=false;
  reader.setContentHandler(this);
  reader.setErrorHandler(this);
  try {
    reader.parse(source);
    status=true;
  }
 catch (  SAXParseException e) {
    if (logger.isLoggable(Level.WARNING)) {
      logger.warning("Failed to parse " + resourceName + " Line: "+ e.getLineNumber()+ " Col: "+ e.getColumnNumber()+ ": "+ e);
    }
  }
catch (  SAXException e) {
    if (logger.isLoggable(Level.WARNING)) {
      logger.warning("Failed to parse " + resourceName + e.getMessage());
    }
  }
catch (  IOException e) {
    if (logger.isLoggable(Level.WARNING)) {
      logger.warning("Failed to parse " + resourceName + ":"+ e.getMessage());
    }
  }
  return status;
}

public boolean parseXmlResource ( Object resourceName , InputSource source ) { XMLReader reader ; source . setEncoding ( "UTF8" ) ; try { reader = XMLReaderFactory . createXMLReader ( ) ; } catch ( SAXException e ) { if ( logger . isLoggable ( Level . SEVERE ) ) { logger . warning ( "Failed to create reader for " + resourceName + ": " + e . getMessage ( ) ) ; } return false ; } boolean status = false ; reader . setContentHandler ( this ) ; reader . setErrorHandler ( this ) ; try { reader . parse ( source ) ; status = true ; } catch ( SAXParseException e ) { if ( logger . isLoggable ( Level . WARNING ) ) { logger . warning ( "Failed to parse " + resourceName + " Line: " + e . getLineNumber ( ) + " Col: " + e . getColumnNumber ( ) + ": " + e ) ; } } catch ( SAXException e ) { if ( logger . isLoggable ( Level . WARNING ) ) { logger . warning ( "Failed to parse " + resourceName + e . getMessage ( ) ) ; } } catch ( IOException e ) { if ( logger . isLoggable ( Level . WARNING ) ) { logger . warning ( "Failed to parse " + resourceName + ":" + e . getMessage ( ) ) ; } } return status ; }
parse from the given source . the source will not be closed after the parse : the caller should do this . exceptions are logged rather than thrown . if an exception occurs the return value will be false to indicate that fact .
