Example usage for javax.xml.xpath XPathConstants DOM_OBJECT_MODEL

List of usage examples for javax.xml.xpath XPathConstants DOM_OBJECT_MODEL

Introduction

In this page you can find the example usage for javax.xml.xpath XPathConstants DOM_OBJECT_MODEL.

Prototype

String DOM_OBJECT_MODEL

To view the source code for javax.xml.xpath XPathConstants DOM_OBJECT_MODEL.

Click Source Link

Document

<p>The URI for the DOM object model, "http://java.sun.com/jaxp/xpath/dom".</p>

Usage

From source file:Main.java

public static Object getNodesListXpath(String XpathS, Node node, String nsuri, String pre, QName returnType)
        throws Exception {
    Object matches = null;/*from  w w w. j av a  2s  . com*/
    // TODO move this to a generic start up method
    System.setProperty("javax.xml.xpath.XPathFactory:" + XPathConstants.DOM_OBJECT_MODEL, XpathFactory);

    XPathFactory xpathFactory = XPathFactory.newInstance(XPathConstants.DOM_OBJECT_MODEL);
    XPath xpath = xpathFactory.newXPath();
    XPathExpression xpe = xpath.compile(XpathS);
    matches = xpe.evaluate(node, returnType);

    return matches;
}

From source file:Main.java

private static XPathFactory getXPathFactory() throws XPathFactoryConfigurationException {
    if (_xPathFactory == null) {
        String magicValue = System
                .getProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom");
        System.setProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom",
                "net.sf.saxon.xpath.XPathFactoryImpl");
        //          System.setProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom","org.apache.xpath.jaxp.XPathFactoryImpl");
        //          System.setProperty("jaxp.debug","yes");
        _xPathFactory = XPathFactory.newInstance(XPathConstants.DOM_OBJECT_MODEL);
        if (magicValue == null)
            System.clearProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom");
        else/*from   w  w w  . java 2  s  . c o  m*/
            System.setProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom", magicValue);
    }
    return _xPathFactory;
}

From source file:Main.java

public static Object getNodesListXpath(String XpathS, Node node, String nsuri, String pre, QName returnType)
        throws Exception {
    Object matches = null;/*from   ww  w .j a va2s  .  c  o m*/
    // TODO move this to a generic start up method
    //System.setProperty("javax.xml.xpath.XPathFactory:"+ XPathConstants.DOM_OBJECT_MODEL, XpathFactory);

    XPathFactory xpathFactory = XPathFactory.newInstance(XPathConstants.DOM_OBJECT_MODEL);
    XPath xpath = xpathFactory.newXPath();
    XPathExpression xpe = xpath.compile(XpathS);
    matches = xpe.evaluate(node, returnType);

    return matches;
}

From source file:Main.java

/**
 * /*w w w .  j a v a  2s .c o m*/
 * @param xPathS
 * @param node
 * @param nsuri
 * @param pre
 * @param returnType
 * @return Return type is one of XPathConstants .BOOLEAN, .NODE, .NODESET,
 *         .NUMBER, .STRING
 * @throws Exception
 */
public static Object getNodesListXpath(final String xPathS, final Node node, final String nsuri,
        final String pre, final QName returnType) throws Exception {
    Object matches = null;
    System.setProperty("javax.xml.xpath.XPathFactory:" + XPathConstants.DOM_OBJECT_MODEL, XPATH_FACTORY);

    XPathFactory xpathFactory = XPathFactory.newInstance(XPathConstants.DOM_OBJECT_MODEL);
    XPath xpath = xpathFactory.newXPath();
    XPathExpression xpe = xpath.compile(xPathS);
    matches = xpe.evaluate(node, returnType);

    return matches;
}