package javakurs.musterloesung.uebung02.aufgabe2;

import java.io.IOException;
import java.util.List;

import javakurs.musterloesung.uebung02.aufgabe1.TfsParser;
import javakurs.musterloesung.uebung02.aufgabe1.TypedFeatStruct;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;

/**
 * {@link TfsDomConvertorTest} is a test class for {@link TfsDomConvertor}.
 *
 * @author Joerg Steffen, DFKI
 * @version $Id: TfsDomConvertorTest.java,v 1.1 2010/11/11 16:51:26 steffen Exp $
 */
public final class TfsDomConvertorTest {

  /**
   * This would create a new instance of {@link TfsDomConvertorTest}. Not to be
   * used.
   */
  private TfsDomConvertorTest() {

    // private constructor to enforce noninstantiability
  }


  /**
   * This is the main method. It requires no arguments.
   *
   * @param args
   *          the arguments; not used here
   */
  public static void main(String[] args) {

    try {
      // init parser
      TfsParser testParser = new TfsParser();
      // parse file
      List<TypedFeatStruct> tfsList = null;
      tfsList = testParser.parseTfsFromFile("data/uebung02/katzen.xml");
      for (TypedFeatStruct oneTFS : tfsList) {
        System.out.println(oneTFS);
      }
      // convert to DOM document
      Document doc = TfsDomConvertor.convert(tfsList);
      // print result
      System.out.println(DomPrinter.printXML(doc));
    } catch (ParserConfigurationException e) {
      e.printStackTrace();
    } catch (SAXException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (TransformerException e) {
      e.printStackTrace();
    }
  }
}
