Example usage for org.jdom2 Element getValue

List of usage examples for org.jdom2 Element getValue

Introduction

In this page you can find the example usage for org.jdom2 Element getValue.

Prototype

@Override
public String getValue() 

Source Link

Document

Returns the XPath 1.0 string value of this element, which is the complete, ordered content of all text node descendants of this element (i.e. the text that's left after all references are resolved and all other markup is stripped out.)

Usage

From source file:TFG.Lector_XML.java

public void read_xml(String xml_path) {

    //Se crea un SAXBuilder para poder parsear el archivo
    SAXBuilder builder = new SAXBuilder();
    File xmlFile = new File(xml_path);

    try {/*from  www . java  2  s . c o m*/

        //Se crea el documento a traves del archivo
        Document document = (Document) builder.build(xmlFile);

        //Se obtiene la raiz <iniciativa_completa>
        Element rootNode = document.getRootElement();

        set_legislatura(rootNode.getChildText("legislatura"));
        set_numero_diario(rootNode.getChildText("numero_diario"));
        set_tipo_sesion(rootNode.getChildText("tipo_sesion"));
        set_organo(rootNode.getChildText("organo"));
        set_presidente(rootNode.getChildText("presidente"));

        Element fecha = rootNode.getChild("fecha");
        set_dia(fecha.getChildText("dia"));
        set_mes(fecha.getChildText("mes"));
        set_anio(fecha.getChildText("anio"));

        set_tipo_epigrafe(rootNode.getChildText("tipo_epigrafe"));

        Element iniciativa = rootNode.getChild("iniciativa");
        set_tipo_iniciativa(iniciativa.getChildText("tipo_iniciativa"));
        set_extracto(iniciativa.getChildText("extracto"));
        set_intervienen(iniciativa.getChildText("intervienen"));

        List<Element> intervencion = iniciativa.getChildren("intervencion");

        for (int i = 0; i < intervencion.size(); i++) {
            Element elem_intervencion = (Element) intervencion.get(i);
            formato_nombres(elem_intervencion.getChildText("interviniente"));

            String cadena_parrafo = "";
            Element discurso = elem_intervencion.getChild("discurso");
            List<Element> parrafo = discurso.getChildren("parrafo");

            for (int j = 0; j < parrafo.size(); j++) {
                Element elem_parrafo = (Element) parrafo.get(j);
                cadena_parrafo = cadena_parrafo + elem_parrafo.getValue();
            }
            set_parrafo(cadena_parrafo);
        }

    } catch (IOException io) {
        System.out.println(io.getMessage());
    } catch (JDOMException jdomex) {
        System.out.println(jdomex.getMessage());
    }

}

From source file:tinyequationscoringengine.MathScoringService.java

License:Open Source License

public boolean isEmpty(MathExpression mathexp) {
    if (mathexp == null) {
        return true;
    } else if (mathexp.getMathMLNodeList() == null) {
        // One of the MathExpression object constructors is defined to bypass
        // MathML processing and therefore
        // isEmpty function has to account for the case when MathML is left empty
        // but Sympy representation exists
        if (mathexp.getSympyResponse() == null || mathexp.getSympyResponse().size() == 0)
            return true;

        char[] charsToTrim = { ' ', '(', ')' };
        for (int expInd = 0; expInd < mathexp.getSympyResponse().size(); expInd++) {
            if (!StringUtils.isEmpty(StringHelper.trim(mathexp.getSympyResponse().get(expInd), charsToTrim)))
                return false;
        }//from ww  w .ja  v a2 s .c  o  m
        return true;
    }

    XmlNamespaceManager nsmgr = new XmlNamespaceManager();
    nsmgr.addNamespace("math", "http://www.w3.org/1998/Math/MathML");
    for (Element node_i : mathexp.getMathMLNodeList()) {
        List<Element> text_nodes = new XmlElement(node_i)
                .selectNodes("..//math:mo/text()|..//math:mi/text()|..//math:mn/text()", nsmgr);
        for (Element node_j : text_nodes) {
            if (!StringUtils.isEmpty(node_j.getValue()) && !StringUtils.isWhitespace(node_j.getValue()))
                return false;
        }
    }
    return true;
}

From source file:ucar.unidata.idv.chooser.IdvRadarDatasetCollection.java

License:Open Source License

/**
 * get station object from parent element
 *
 *
 * @param elem _more_/*from  ww w.  j a  v  a 2  s.co  m*/
 * @return stationImpl
 */
private Station readStation(Element elem) {
    // look for stations
    String name = elem.getAttributeValue("id");
    //latitude
    Element desc = elem.getChild("name");
    String descv = desc.getValue();
    Element lat = elem.getChild("latitude");
    String latv = lat.getValue();
    Element lon = elem.getChild("longitude");
    String lonv = lon.getValue();
    Element alt = elem.getChild("elevation");
    String altv = alt.getValue();

    StationImpl station = new StationImpl(name, descv, "", Double.parseDouble(latv), Double.parseDouble(lonv),
            Double.parseDouble(altv));

    return station;
}

From source file:ucar.unidata.idv.chooser.IdvRadarDatasetCollection.java

License:Open Source License

/**
 * get region from parent element//ww w.j  av  a2 s.co  m
 *
 *
 * @param elem _more_
 * @param ns _more_
 * @return _more_
 */
public LatLonRect readSelectRegion(Element elem, Namespace ns) {
    Element region = elem.getChild("LatLonBox", ns);
    //lat, lon
    Element north = region.getChild("north", ns);
    String nv = north.getValue();
    Element south = region.getChild("south", ns);
    String sv = south.getValue();
    Element east = region.getChild("east", ns);
    String ev = east.getValue();
    Element west = region.getChild("west", ns);
    String wv = west.getValue();

    LatLonPointImpl p1 = new LatLonPointImpl(Double.valueOf(sv), Double.valueOf(wv));
    LatLonPointImpl p2 = new LatLonPointImpl(Double.valueOf(nv), Double.valueOf(ev));
    LatLonRect llr = new LatLonRect(p1, p2);

    return llr;
}

From source file:ucar.unidata.idv.chooser.IdvRadarDatasetCollection.java

License:Open Source License

/**
 * get start and end elemnt form parent element
 *
 *
 * @param elem _more_/*from   w w w. j  a v  a 2s.c  om*/
 * @param ns _more_
 * @return list of times
 */
public List<String> readSelectTime(Element elem, Namespace ns) {
    // look for stations

    Element region = elem.getChild("TimeSpan", ns);

    java.util.List regionInfo = region.getChildren();
    //lat, lon
    Element start = region.getChild("start", ns);
    String sv = start.getValue();
    Element end = region.getChild("end", ns);
    String ev = end.getValue();

    List<String> ll = new ArrayList<String>();
    ll.add(sv);
    ll.add(ev);
    return ll;
}

From source file:ucar.unidata.idv.chooser.IdvRadarDatasetCollection.java

License:Open Source License

/**
 * get document from parent element//w  ww  . j a  v a2 s.c  o m
 *
 *
 * @param elem _more_
 * @param ns _more_
 * @return _more_
 */
private String readSelectDocument(Element elem, Namespace ns) {

    Element doc = elem.getChild("documentation", ns);
    return doc.getValue();

}

From source file:util.secure.AsymKeysImpl.java

License:Open Source License

@Override
protected boolean handleElement(Element e) {
    switch (e.getName()) {
    case "publicKey":
        publicKey = new BigInteger(e.getValue(), 16);
        return true;
    case "p":
        p = new BigInteger(e.getValue(), 16);
        return true;
    case "g":
        g = new BigInteger(e.getValue(), 16);
        return true;
    case "privateKey":
        encryptedPrivateKey = new BigInteger(e.getValue(), 16);
        privateKey = null;/*from   www.  j  a  v  a2  s.  c o  m*/
        return true;
    }
    return false;
}

From source file:wasr.DocNode.java

License:Apache License

private String getField(String fieldId) {
    if (fieldId != null) {
        Element fieldElement = element.getChild(fieldId);
        return fieldElement == null ? "" : fieldElement.getValue(); //todo: CDATA?
    } else {//from   w w  w .j  ava2 s  . co m
        return "";
    }
}