Java 类org.jdom2.Content.CType 实例源码

项目:ixa-pipe-convert    文件:TimeMLToNAF.java   
private static void timeMLToNAFNER(KAFDocument kaf, String fileName, String language) {
  //reading the TimeML xml file
  SAXBuilder sax = new SAXBuilder();
  XPathFactory xFactory = XPathFactory.instance();
  try {
    Document doc = sax.build(fileName);
    Element rootElement = doc.getRootElement();
    XPathExpression<Element> timexExpr = xFactory.compile("//TIMEX3",
        Filters.element());
    List<Element> timexElems = timexExpr.evaluate(doc);
    XPathExpression<Element> eventExpr = xFactory.compile("//EVENT", Filters.element());

    //getting the Document Creation Time
    Element dctElement = rootElement.getChild("DCT");
    Element dctTimex = dctElement.getChild("TIMEX3");
    String dctTimexValue = dctTimex.getAttributeValue("value");
    kaf.createFileDesc().creationtime = dctTimexValue;
    //getting the TEXT
    Element textElement = rootElement.getChild("TEXT");
    List<Content> textElements = textElement.getContent();
    //we need to iterate over single content of the text element
    //to get the text and the relevant attributes from TIMEX and
    //EVENT elements
    for (Content textElem : textElements) {
      if (textElem.getCType().equals(CType.Element)) {
        System.out.println(textElem.getValue());
      }
    }
  } catch (JDOMException | IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}