コード例 #1
0
  /**
   * main
   *
   * @param args
   */
  public static void main(String[] args) {
    try {
      String tmxfile = args[0];
      Timer timer = new Timer();
      timer.startTimer();
      File f = new File(tmxfile);
      TmxDocument doc = new TmxDocument();
      // load the xml file
      doc.loadXmlFile(f);
      timer.stopTimer();
      System.out.println(
          timer.timerString("TMX file read " + tmxfile + ": Version " + doc.getTmxVersion()));
      timer.startTimer();
      // save it
      doc.saveToXmlFile(tmxfile + ".copy.tmx");
      timer.stopTimer();

      Element header = doc.getTmxHeader();
      System.out.println("TMX Header:\n" + doc.createLinguisticProperties(header).format());

      System.out.println(
          timer.timerString("TMX file save " + tmxfile + ": Version " + doc.getTmxVersion()));
      System.out.println("TMX file #tuvs = " + doc.getTuList().size());
      for (int i = 0; i < doc.getTuList().size(); i++) {
        Element tu = doc.getTuList().get(i);
        String tustring = doc.elementToString(tu);
        System.out.println("TUV string (" + i + ") = \"" + tustring + "\"");
        List<Element> tuvs = doc.getTuvList(tu);
        for (int j = 0; j < tuvs.size(); j++) {
          Element tuv = tuvs.get(j);
          Element seg = doc.getSeg(tuv);
          System.out.println("\tTU string a (" + j + ") = \"" + doc.elementToString(seg) + "\"");
          System.out.println(
              "\tTU string b (" + j + ") = \"" + doc.elementContentToString(seg) + "\"");
        }

        MultiLingualObject multi = doc.tuToMultiLingualObject(tu);
        System.out.println(multi.format());
      }
      doc = null;
    } catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();
    }
  }