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:AIR.ResourceBundler.Xml.FileSetInput.java

License:Open Source License

public void parse(Element fileEl) {
    // get file path
    setPath(_fileSet.resolveFile(fileEl.getValue()));
    Attribute attrib = null;// w  w w  .  ja  v a 2  s. co m

    attrib = fileEl.getAttribute("prepend");
    _prepend = (attrib != null) ? attrib.getValue() : null;

    attrib = fileEl.getAttribute("append");
    _append = (attrib != null) ? attrib.getValue() : null;
}

From source file:AIR.ResourceBundler.Xml.Resources.java

License:Open Source License

private void parseImport(Element importEl) throws JDOMException, IOException, ResourcesException {
    String importPath = resolveFile(importEl.getValue());

    // parse external config file
    Resources resources = new Resources(importPath, this);
    resources.parse();/*  w  w w  . j a  v a 2  s  .com*/

    for (Iterator<FileSet> iterator = resources.getFileSets(); iterator.hasNext();) {
        FileSet resource = iterator.next();
        _fileSets.put(resource.getName(), resource);
    }
}

From source file:at.ac.tuwien.ims.latex2mobiformulaconv.converter.mathml2html.FormulaConverter.java

License:Open Source License

/**
 * Parses a JDOM HTML Document for formula entries, sets an id to refer to it in the future.
 *
 * @param document JDOM HTML Document to parse
 * @return Map of formulas, keys: given id, values: corresponding latex formula code from the document
 *///w  w w.  ja va 2 s. com
public Map<Integer, String> extractFormulas(Document document) {
    Map<Integer, String> formulas = new HashMap<>();

    List<Element> foundElements = xpath.evaluate(document);
    if (foundElements.size() > 0) {
        int id = 0;
        for (Element element : foundElements) {
            formulas.put(id, element.getValue());

            // mark formula number
            element.setAttribute("id", FORMULA_ID_PREFIX + id);
            id++;
        }
    }

    return formulas;
}

From source file:ca.nrc.cadc.uws.JobListReader.java

License:Open Source License

private List<JobRef> parseJobList(Document doc) throws ParseException, DataConversionException {
    Element root = doc.getRootElement();
    List<Element> children = root.getChildren();
    Iterator<Element> childIterator = children.iterator();
    List<JobRef> jobs = new ArrayList<JobRef>();
    Element next = null;//from  ww w.  ja v  a2 s . c o m
    JobRef jobRef = null;
    ExecutionPhase executionPhase = null;
    Date creationTime = null;
    Attribute nil = null;
    String runID = null;
    String ownerID = null;
    while (childIterator.hasNext()) {
        next = childIterator.next();
        String jobID = next.getAttributeValue("id");

        Element phaseElement = next.getChild(JobAttribute.EXECUTION_PHASE.getAttributeName(), UWS.NS);
        String phase = phaseElement.getValue();
        executionPhase = ExecutionPhase.valueOf(phase);

        Element creationTimeElement = next.getChild(JobAttribute.CREATION_TIME.getAttributeName(), UWS.NS);
        String time = creationTimeElement.getValue();
        creationTime = dateFormat.parse(time);

        Element runIDElement = next.getChild(JobAttribute.RUN_ID.getAttributeName(), UWS.NS);
        nil = runIDElement.getAttribute("nil", UWS.XSI_NS);
        if (nil != null && nil.getBooleanValue())
            runID = null;
        else
            runID = runIDElement.getTextTrim();

        Element ownerIDElement = next.getChild(JobAttribute.OWNER_ID.getAttributeName(), UWS.NS);
        ownerID = ownerIDElement.getTextTrim();

        jobRef = new JobRef(jobID, executionPhase, creationTime, runID, ownerID);
        jobs.add(jobRef);
    }

    return jobs;
}

From source file:ch.kostceco.tools.siardval.validation.module.impl.ValidationFrowModuleImpl.java

License:Open Source License

private boolean validateTableXMLFiles(ValidationContext validationContext) throws Exception {
    boolean validTableXMLFiles = true;
    StringBuilder namesOfInvalidTables = new StringBuilder();
    Properties properties = validationContext.getValidationProperties();
    List<SiardTable> siardTables = validationContext.getSiardTables();

    for (SiardTable siardTable : siardTables) {
        Element tableRootElement = siardTable.getTableRootElement();
        Element tableRowsElement = tableRootElement.getChild(
                properties.getProperty("module.f.siard.table.xml.rows.element.name"),
                validationContext.getXmlNamespace());
        Integer rowNumber = new Integer(tableRowsElement.getValue());
        List<Element> xmlRowElements = siardTable.getTableXMLElements();
        Integer rows = new Integer(xmlRowElements.size());
        if (rowNumber > rows) {
            validTableXMLFiles = false;/*  ww w  . j  av  a 2  s.com*/
            namesOfInvalidTables.append((namesOfInvalidTables.length() > 0) ? ", " : "");
            namesOfInvalidTables.append(siardTable.getTableName()
                    + properties.getProperty("module.f.siard.table.xml.file.extension") + " ("
                    + (rows - rowNumber) + ") ");
        }

        if (rowNumber < rows) {
            validTableXMLFiles = false;
            namesOfInvalidTables.append((namesOfInvalidTables.length() > 0) ? ", " : "");
            namesOfInvalidTables.append(siardTable.getTableName()
                    + properties.getProperty("module.f.siard.table.xml.file.extension") + " (+"
                    + (rows - rowNumber) + ") ");
        }
    }
    // Writing back error log
    this.setIncongruentTableXMLFiles(namesOfInvalidTables);
    // Return the current validation state
    return validTableXMLFiles;
}

From source file:ch.kostceco.tools.siardval.validation.module.impl.ValidationFrowModuleImpl.java

License:Open Source License

private boolean validateTableXSDFiles(ValidationContext validationContext) throws Exception {
    boolean validTableXSDFiles = true;
    StringBuilder namesOfInvalidTables = new StringBuilder();
    Properties properties = validationContext.getValidationProperties();
    List<SiardTable> siardTables = validationContext.getSiardTables();

    for (SiardTable siardTable : siardTables) {

        Element tableRootElement = siardTable.getTableRootElement();
        Element tableRowsElement = tableRootElement.getChild(
                properties.getProperty("module.f.siard.table.xml.rows.element.name"),
                validationContext.getXmlNamespace());
        Integer rowNumber = new Integer(tableRowsElement.getValue());
        Long extendedRowNumber = rowNumber.longValue();

        Element tableXSDRootElement = siardTable.getTableXSDRootElement();
        Element tableElement = tableXSDRootElement.getChild(
                properties.getProperty("module.f.siard.table.xsd.element"), tableXSDRootElement.getNamespace());

        Element tableComplexType = tableElement.getChild(
                properties.getProperty("module.f.siard.table.xsd.complexType"),
                tableXSDRootElement.getNamespace());

        Element tableSequence = tableComplexType.getChild(
                properties.getProperty("module.f.siard.table.xsd.sequence"),
                tableXSDRootElement.getNamespace());

        String maxOccurs = tableSequence
                .getChild(properties.getProperty("module.f.siard.table.xsd.element"),
                        tableXSDRootElement.getNamespace())
                .getAttributeValue(properties.getProperty("module.f.siard.table.xsd.attribute.maxOccurs.name"));
        String minOccurs = tableSequence
                .getChild(properties.getProperty("module.f.siard.table.xsd.element"),
                        tableXSDRootElement.getNamespace())
                .getAttributeValue(properties.getProperty("module.f.siard.table.xsd.attribute.minOccurs.name"));

        // Implicite max. bound: the maximal value of Long is used
        if (maxOccurs
                .equalsIgnoreCase(properties.getProperty("module.f.siard.table.xsd.attribute.unbounded"))) {
            if (extendedRowNumber >= 0 && extendedRowNumber <= Long.MAX_VALUE) {
            } else {
                validTableXSDFiles = false;
                namesOfInvalidTables.append((namesOfInvalidTables.length() > 0) ? ", " : "");
                namesOfInvalidTables.append(siardTable.getTableName()
                        + properties.getProperty("module.f.siard.table.xsd.file.extension"));
            }//from   ww w.ja  v  a  2 s  .  c o m
        }

        // Explicite max. bound is used
        if (isLong(maxOccurs) && isLong(minOccurs)) {
            if (new Long(minOccurs) == extendedRowNumber && new Long(maxOccurs) == extendedRowNumber) {
            } else {
                if (new Long(minOccurs) - extendedRowNumber == 0
                        && new Long(maxOccurs) - extendedRowNumber == 0) {
                } else {
                    if (new Long(maxOccurs) > extendedRowNumber) {
                        validTableXSDFiles = false;
                        namesOfInvalidTables.append((namesOfInvalidTables.length() > 0) ? ", " : "");
                        namesOfInvalidTables.append(siardTable.getTableName()
                                + properties.getProperty("module.f.siard.table.xsd.file.extension") + " (+"
                                + (new Long(maxOccurs) - extendedRowNumber) + ") ");

                    } else {
                        validTableXSDFiles = false;
                        namesOfInvalidTables.append((namesOfInvalidTables.length() > 0) ? ", " : "");
                        namesOfInvalidTables.append(siardTable.getTableName()
                                + properties.getProperty("module.f.siard.table.xsd.file.extension") + " ("
                                + (new Long(maxOccurs) - extendedRowNumber) + ") ");
                    }
                }
            }
        }
    }

    this.setIncongruentTableXSDFiles(namesOfInvalidTables);
    return validTableXSDFiles;
}

From source file:com.astronomy.project.Declination.java

/**
 * 
 * @param e XML element
 */
public Declination(Element e) {
    super(Double.valueOf(e.getValue()));
}

From source file:com.bc.ceres.jai.opimage.XmlRIF.java

License:Open Source License

private RenderedOp parseImage(Element targetElement, Map<String, Element> definedSourceElements,
        Map<String, Element> definedParameterElements, Map<String, Object> configuration,
        RenderingHints renderHints, String modeName) {
    Element opElement = targetElement.getChild(ENAME_OP);
    String opName = opElement.getValue();

    ParameterBlockJAI parameterBlock = new ParameterBlockJAI(opName, modeName);

    parseSources(parameterBlock, targetElement, definedSourceElements, definedParameterElements, configuration,
            renderHints);//w  w  w .  j a  va2 s  . co  m

    parseParameters(parameterBlock, targetElement, definedParameterElements, configuration);

    return JAI.create(opName, parameterBlock, renderHints);
}

From source file:com.bc.ceres.jai.opimage.XmlRIF.java

License:Open Source License

private void parseParameters(ParameterBlockJAI parameterBlock, Element targetElement,
        Map<String, Element> definedParameterElements, Map<String, Object> configuration) {
    List parameterElements = targetElement.getChildren(ENAME_PARAMETER);
    for (int i = 0; i < parameterElements.size(); i++) {
        Element parameterElement = (Element) parameterElements.get(i);
        String parameterName = parameterElement.getAttributeValue(ANAME_ID);
        if (parameterName == null) {
            String[] paramNames = parameterBlock.getParameterListDescriptor().getParamNames();
            if (i < paramNames.length) {
                parameterName = paramNames[i];
            } else {
                throw new IllegalArgumentException(
                        MessageFormat.format("Operation ''{0}'': Unknown parameter #{1}'",
                                parameterBlock.getOperationDescriptor().getName(), i));
            }// w  ww  .  j ava2  s.com
        }
        String parameterId = parameterElement.getAttributeValue(ANAME_REFID);
        Object parameterValue;

        if (parameterId != null) {
            parameterValue = configuration.get(parameterId);
            if (parameterValue == null) {
                Element definedParameterElement = definedParameterElements.get(parameterId);
                parameterValue = parseParameterValue(parameterBlock, parameterName,
                        definedParameterElement.getValue());
                configuration.put(parameterId, parameterValue);
            }
        } else {
            parameterValue = parseParameterValue(parameterBlock, parameterName, parameterElement.getValue());
        }
        if (parameterName != null) {
            parameterBlock.setParameter(parameterName, parameterValue);
        } else {
            parameterBlock.add(parameterValue);
        }
    }
}

From source file:com.forum.action.eder.TemaACT.java

private ArrayList<Respuesta> respuestasTema(int id, String url) {
    ArrayList<Respuesta> arreglo = new ArrayList<>();
    Document document = getDocument(url);
    Element root = document.getRootElement();
    Element temas = root.getChild("respuestas");
    List<Element> child = temas.getChildren();
    for (Element e : child) {
        if (Integer.parseInt(e.getAttributeValue("id")) != id)
            continue;
        List<Element> child2 = e.getChildren();
        for (Element e2 : child2) {
            arreglo.add(new Respuesta(e2.getAttributeValue("usuario"), e2.getValue(),
                    Integer.parseInt(e2.getAttributeValue("id")),
                    Integer.parseInt(e2.getAttributeValue("calificacion"))));
        }/*from   w w w.  j  a v a2 s  .co  m*/
    }
    return arreglo;
}