/**
   * Parses the given xml stream and returns a list of the suppression rules contained.
   *
   * @param inputStream an InputStream containing suppression rues
   * @return a list of suppression rules
   * @throws SuppressionParseException if the xml cannot be parsed
   */
  public List<SuppressionRule> parseSuppressionRules(InputStream inputStream)
      throws SuppressionParseException, SAXException {
    try {
      final InputStream schemaStream =
          this.getClass()
              .getClassLoader()
              .getResourceAsStream("schema/dependency-suppression.1.1.xsd");
      final SuppressionHandler handler = new SuppressionHandler();
      final SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setNamespaceAware(true);
      factory.setValidating(true);
      final SAXParser saxParser = factory.newSAXParser();
      saxParser.setProperty(
          SuppressionParser.JAXP_SCHEMA_LANGUAGE, SuppressionParser.W3C_XML_SCHEMA);
      saxParser.setProperty(SuppressionParser.JAXP_SCHEMA_SOURCE, new InputSource(schemaStream));
      final XMLReader xmlReader = saxParser.getXMLReader();
      xmlReader.setErrorHandler(new SuppressionErrorHandler());
      xmlReader.setContentHandler(handler);

      final Reader reader = new InputStreamReader(inputStream, "UTF-8");
      final InputSource in = new InputSource(reader);
      // in.setEncoding("UTF-8");

      xmlReader.parse(in);

      return handler.getSuppressionRules();
    } catch (ParserConfigurationException ex) {
      LOGGER.debug("", ex);
      throw new SuppressionParseException(ex);
    } catch (SAXException ex) {
      if (ex.getMessage().contains("Cannot find the declaration of element 'suppressions'.")) {
        throw ex;
      } else {
        LOGGER.debug("", ex);
        throw new SuppressionParseException(ex);
      }
    } catch (FileNotFoundException ex) {
      LOGGER.debug("", ex);
      throw new SuppressionParseException(ex);
    } catch (IOException ex) {
      LOGGER.debug("", ex);
      throw new SuppressionParseException(ex);
    }
  }
  /**
   * Parses the given xml stream and returns a list of the suppression rules contained.
   *
   * @param inputStream an InputStream containing suppression rues
   * @return a list of suppression rules
   * @throws SuppressionParseException if the xml cannot be parsed
   */
  private List<SuppressionRule> parseOldSuppressionRules(InputStream inputStream)
      throws SuppressionParseException {
    try {
      final InputStream schemaStream =
          this.getClass().getClassLoader().getResourceAsStream("schema/suppression.xsd");
      final SuppressionHandler handler = new SuppressionHandler();
      final SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setNamespaceAware(true);
      factory.setValidating(true);
      final SAXParser saxParser = factory.newSAXParser();
      saxParser.setProperty(
          SuppressionParser.JAXP_SCHEMA_LANGUAGE, SuppressionParser.W3C_XML_SCHEMA);
      saxParser.setProperty(SuppressionParser.JAXP_SCHEMA_SOURCE, new InputSource(schemaStream));
      final XMLReader xmlReader = saxParser.getXMLReader();
      xmlReader.setErrorHandler(new SuppressionErrorHandler());
      xmlReader.setContentHandler(handler);

      final Reader reader = new InputStreamReader(inputStream, "UTF-8");
      final InputSource in = new InputSource(reader);
      // in.setEncoding("UTF-8");

      xmlReader.parse(in);

      return handler.getSuppressionRules();
    } catch (ParserConfigurationException ex) {
      LOGGER.debug("", ex);
      throw new SuppressionParseException(ex);
    } catch (SAXException ex) {
      LOGGER.debug("", ex);
      throw new SuppressionParseException(ex);
    } catch (FileNotFoundException ex) {
      LOGGER.debug("", ex);
      throw new SuppressionParseException(ex);
    } catch (IOException ex) {
      LOGGER.debug("", ex);
      throw new SuppressionParseException(ex);
    }
  }