Package javax.xml.xpath

Examples of javax.xml.xpath.XPathExpression.evaluate()


        if (target != null) {
            org.w3c.dom.Node parent = null;
                parent = ((org.w3c.dom.Node) target).getParentNode();
               
               
            targetElem = exprTo.evaluate(parent, XPathConstants.NODE);
           
            if (targetElem == null) {
                throw new RuntimeException("Nothing was selected by the to expression " + to + " on " + targetExpr);
            }
        }
View Full Code Here


        resolver.declarePrefix(CATALONG_URI_PREFIX, CATALONG_URI);
        xpath.setNamespaceContext(resolver);
        final String count = "count(" + testPath + ")";
        XPathExpression expr = xpath.compile(count);
        final Document catalog = catalogPool.borrowObject();
        final Double d = (Double) expr.evaluate(catalog, XPathConstants.NUMBER);
        catalogPool.returnObject(catalog);
        return d.intValue();
    }

    public void invokeTest(final String testPath) throws Exception {
View Full Code Here

        NamespaceBinder resolver = new NamespaceBinder();
        resolver.declarePrefix(XQTSTestBase.CATALONG_URI_PREFIX, XQTSTestBase.CATALONG_URI);
        xpath.setNamespaceContext(resolver);
        final String count = "count(" + testPath + ")";
        XPathExpression expr = xpath.compile(count);
        final Double d = (Double) expr.evaluate(catalog, XPathConstants.NUMBER);
        return d.intValue();
    }

    private static String toClassName(String name) {
        final StringBuilder buf = new StringBuilder(64);
View Full Code Here

    throws XPathExpressionException
  {
    NodeList nodes = null;
    final String sXPath = "//" + nodeName;
    XPathExpression xPathExpression = getXPathExpression(sXPath);
    nodes = (NodeList) xPathExpression.evaluate(parent, XPathConstants.NODESET);
    List<Node> realNodeList = createRealNodeList(nodes);
    return realNodeList;
  }

  public Node getChild(Node parent, String nodeName)
View Full Code Here

    throws XPathExpressionException
  {
    NodeList nodes = null;
    final String sXPath = nodeName;
    XPathExpression xPathExpression = getXPathExpression(sXPath);
    nodes = (NodeList) xPathExpression.evaluate(parent, XPathConstants.NODESET);
    List<Node> realNodeList = createRealNodeList(nodes);
    return realNodeList;
  }

  public List<Node> getChildren(Node parent)
View Full Code Here

                    for (XmlSchema schema : schemas.getXmlSchemas()) {
                        if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(schema.getTargetNamespace())) {
                            continue;
                        }
                        Object src = getSchemaNode(schema, schemas);
                        NodeList nodes = (NodeList)xpe.evaluate(src, XPathConstants.NODESET);
                        if (nodes.getLength() > 0) {
                            String key = schema.getSourceURI();
                            binding = convertToTmpInputSource(d.getDocumentElement(), key);
                            opts.addBindFile(binding);
                            binding = null;
View Full Code Here

    private static String xpathGetText(Document doc, String expression) throws XPathExpressionException {
        XPathFactory xPathFactory = XPathFactory.newInstance();
        XPath xPath = xPathFactory.newXPath();
        XPathExpression expr = xPath.compile(expression);

        return (String) expr.evaluate(doc, XPathConstants.STRING);
    }

    /**
     * Select matching node set and extract specified attribute value.
     *
 
View Full Code Here

    private static List<String> xpathGetAttributeValueList(Document doc, String expression, String attribute) throws XPathExpressionException {
        XPathFactory xPathFactory = XPathFactory.newInstance();
        XPath xPath = xPathFactory.newXPath();
        XPathExpression expr = xPath.compile(expression);

        NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);

        List<String> attributeValues = new ArrayList<String>();

        for (int i = 0; i < nl.getLength(); i++) {
            attributeValues.add(((Element) nl.item(i)).getAttribute(attribute));
View Full Code Here

        .newDocumentBuilder()
        .parse(new ByteArrayInputStream(c24.getXml().getBytes()));

    XPath xpath = XPathFactory.newInstance().newXPath();
    XPathExpression xpathExpression = xpath.compile("//transaction/value");
    String result = xpathExpression.evaluate(document).toLowerCase();
   
    return result.contains("valid");
  }

}
View Full Code Here

    protected Node getOutputNodeViaXPath(Input input) throws Exception { //NOPMD
        checkSearchValueNotNull(input);
        checkSearchValueOfType(XPathFilterParameterSpec.class, input);
        XPathFilterParameterSpec xpathFilter = (XPathFilterParameterSpec) input.getOutputNodeSearch();
        XPathExpression expr = XmlSignatureHelper.getXPathExpression(xpathFilter);
        NodeList nodes = (NodeList) expr.evaluate(input.getMessageBodyDocument(), XPathConstants.NODESET);
        if (nodes == null || nodes.getLength() == 0) {
            throw new XmlSignatureException(
                    String.format(
                            "Cannot extract root node for the output document from the XML signature document. No node found for XPATH %s as specified in the output node search.",
                            xpathFilter.getXPath()));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.