import java.io.*;
import java.util.*;

import javax.xml.bind.*;
import javax.xml.transform.stream.StreamSource;

import UMLS.*;

/********************************************************
 * 
 *******************************************************/

public class TermUMLS
{
  public static void main(String[] args) throws Exception
  {
    // --- read the UMLS term list the following XML format:

    // ---------------------------------------------------------------------------
    // <?xml version = '1.0'?>
    // <termList>
    //  <term>
    //     <str>...</str>
    //     <sty>...</sty>
    //  </term>
    //  <term>
    //     <str>...</str>
    //     <sty>...</sty>
    //  </term>
    //  ...
    // </termList>
    // ---------------------------------------------------------------------------

    // --- prepare for XML unmarshalling
    JAXBContext jc;            // --- JAXBContext object to provide entry point to JAXB API
    Unmarshaller unmarshaller; // --- Unmarshaller object to control the process of unmarshalling

    jc = JAXBContext.newInstance("UMLS");
    unmarshaller = jc.createUnmarshaller();

    UMLS.TermList root = (UMLS.TermList) unmarshaller.unmarshal(new File(".\\data\\tmp\\termsUMLS.xml"));

    List<TermList.Term> termList = root.getTerm();

    for(Iterator<TermList.Term> i = termList.iterator(); i.hasNext(); )
    {
      UMLS.TermList.Term term = i.next();
      String str = term.getStr();
      System.out.println(str);
    }
  }
}

