Ejemplo n.º 1
0
  /**
   * Parse the content of the string as XML using the specified SAXHandler and engine.
   *
   * @param data The string containing the XML to parse.
   * @param handler The SAX handler to use.
   * @param recovery Whether work in recovery mode or not, tries to read not well formed document.
   * @param engine The SAXHandlerEngine to use.
   */
  public static void parseSAX(
      String data, SAXHandler handler, boolean recovery, SAXHandlerEngine engine) {
    if (data == null) throw new IllegalArgumentException("Can't parse null data");

    engine.setHandler(handler);
    parseSAXImpl(data, engine, recovery ? 1 : 0);
  }
Ejemplo n.º 2
0
 /**
  * Parse the content located in specified systemId as XML document using specified SAXHandler and
  * engine.
  *
  * @param systemId The system identifier which indicates location of XML document as URI.
  * @param handler The SAX Handler to use.
  * @param recovery Whether work in recovery mode or not, tries to read not well formed document.
  * @param engine The SAXHandlerEngine to use.
  * @throws IOException If any IO error occur.
  */
 public static void parseSAXSystemId(
     String systemId, SAXHandler handler, boolean recovery, SAXHandlerEngine engine)
     throws IOException {
   engine.setHandler(handler);
   // Resolve systemId's input stream
   InputStream in = new URL(systemId).openStream();
   try {
     parseSAXSystemIdImpl(systemId, in, engine, recovery ? 1 : 0);
   } finally {
     in.close();
   }
 }
Ejemplo n.º 3
0
 /**
  * Parse the content of the file as XML document using specified SAXHandler and engine.
  *
  * @param file The file containing the XML to parse.
  * @param handler The SAX Handler to use.
  * @param recovery Whether work in recovery mode or not, tries to read not well formed document.
  * @param engine The SAXHandlerEngine to use.
  */
 public static void parseSAX(
     File file, SAXHandler handler, boolean recovery, SAXHandlerEngine engine) {
   engine.setHandler(handler);
   parseSAXFileImpl(file.getAbsolutePath(), engine, recovery ? 1 : 0);
 }