Esempio n. 1
0
  private static boolean checkXml(String text) {

    try {
      XMLReader reader = factory.newSAXParser().getXMLReader();
      reader.setEntityResolver(NoOpEntityResolver.getInstance());
      reader.parse(text);
      return true;
    } catch (SAXException e) {
      return false;
    } catch (IOException e) {
      return false;
    } catch (ParserConfigurationException e) {
      return false;
    }
  }
Esempio n. 2
0
  public static Reader convertRdf2Ics(InputStream is) throws SAXException, IOException {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(false);
    factory.setNamespaceAware(true);
    XMLReader reader = null;
    try {
      reader = factory.newSAXParser().getXMLReader();
      reader.setEntityResolver(NoOpEntityResolver.getInstance());
    } catch (ParserConfigurationException e) {
      log.error("", e);
    }

    Rdf2IcsHandler xmlHandler = new Rdf2IcsHandler();

    reader.setContentHandler(xmlHandler);
    reader.parse(new InputSource(is));
    return new StringReader(xmlHandler.getResult());
  }