Example usage for org.jdom2.xpath XPathFactory instance

List of usage examples for org.jdom2.xpath XPathFactory instance

Introduction

In this page you can find the example usage for org.jdom2.xpath XPathFactory instance.

Prototype

public static final XPathFactory instance() 

Source Link

Document

Obtain an instance of an XPathFactory using the default mechanisms to determine what XPathFactory implementation to use.

Usage

From source file:test.sql.XPathModifier.java

License:Apache License

String getElementValueNew(Document doc, String elementToFind) {

    String val = null;

    if ((doc == null) || (elementToFind == null))
        return null;

    if (debugFlag)
        System.out.println("getElementValueNew:  looking for " + elementToFind);

    XPathFactory xpf = XPathFactory.instance();
    if (debugFlag)
        System.out.println("number of namespaces:  " + namespaces.size());

    XPathExpression<Element> xpath = xpf.compile(elementToFind, Filters.element(), null, namespaces);

    Element el = xpath.evaluateFirst(doc);

    return el.getText();
}

From source file:unidue.ub.statistics.resolver.JOPResolver.java

/**
 * Returns true, if any electronic data is marked with state '3' (partially licensed) in the given
 * full XML response of JOP. //from   w  w w .  j  a v a  2 s.  co m
 */
private boolean isElectronicDataState3(Element fullXML) throws JDOMException {
    String path = xpathToElectronicDataFull + xpathPredicateState3;
    XPathExpression<Element> xPath = XPathFactory.instance().compile(path, Filters.element());
    boolean result = (null != xPath.evaluateFirst(fullXML));
    LOGGER.debug("electronic availability is marked as partially licensed? " + result);
    return result;
}

From source file:unidue.ub.statistics.resolver.JOPResolver.java

/**
 * Queries the JOP brief xml service to get the total status of electronic availability, and adds that state
 * to the ElectronicData element. In case total access is given by combining multiple licenses with state '3' 
 * (partially licensed), only the brief response contains the information that the combined license covers
 * the complete journal, if so. /*from w w  w  .j  av a2s.c  o  m*/
 */
private void addElectronicDataTotalState(Element fullXML, String query)
        throws SAXException, IOException, JDOMException {
    Element briefData = getJOPDataFromRemoteServer(query, jopBriefURL);
    XPathExpression<Attribute> xPath = XPathFactory.instance().compile(xpathToElectronicDataState,
            Filters.attribute());
    Attribute state = xPath.evaluateFirst(briefData);
    LOGGER.debug("electronic availability total state from brief xml response is " + state.getValue());
    Element electronicData = XPathFactory.instance().compile(xpathToElectronicDataFull, Filters.element())
            .evaluateFirst(fullXML);
    state.detach();
    electronicData.setAttribute(state);
}

From source file:us.xwhite.dvd.endpoint.RentalEndpoint.java

License:Apache License

public RentalEndpoint(RentalService rentalService)
        throws JDOMException, XPathFactoryConfigurationException, XPathExpressionException {
    this.rentalService = rentalService;
    Namespace namespace = Namespace.getNamespace("sakila", NAMESPACE_URI);
    XPathFactory xPathFactory = XPathFactory.instance();
    this.storeId = xPathFactory.compile("//@storeId", Filters.attribute(), null, namespace);
    this.filmTitles = xPathFactory.compile("//@title", Filters.attribute(), null, namespace);
}