Package javax.xml.xpath

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


        // Verify STR is included in the signature references
        final XPathExpression sigRefExpr = xpath.compile(
            "/s:Envelope/s:Header/wsse:Security/ds:Signature/ds:SignedInfo/ds:Reference");
       
        final NodeList sigReferenceNodes =
            (NodeList) sigRefExpr.evaluate(signedDoc, XPathConstants.NODESET);
       
        boolean foundStrReference = false;
        for (int i = 0; i < sigReferenceNodes.getLength(); i++) {
            Node sigRefNode = (Node) sigReferenceNodes.item(i);
            String sigRefURI = sigRefNode.getAttributes().getNamedItem("URI").getNodeValue();
View Full Code Here


        // Advance the reader so that the namespace context changes its prefix/namespace mapping
        reader.nextTag();
        reader.close();

        Document doc = domHelper.load(XML);
        NodeList nodes = (NodeList)expression.evaluate(doc, XPathConstants.NODESET);
        Assert.assertEquals(1, nodes.getLength());
        Node node = nodes.item(0);
        Assert.assertTrue(node instanceof Element);
        Assert.assertEquals(node.getNodeName(), "c:child1");
    }
View Full Code Here

        // Advance the reader so that the namespace context changes its prefix/namespace mapping
        reader.nextTag();
        reader.close();

        Document doc = domHelper.load(XML);
        NodeList nodes = (NodeList)expression.evaluate(doc, XPathConstants.NODESET);
        Assert.assertEquals(1, nodes.getLength());
        Node node = nodes.item(0);
        Assert.assertTrue(node instanceof Element);
        Assert.assertEquals(node.getNodeName(), "c:child1");
    }
View Full Code Here

        InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
        String str = "//sca:composite/sca:component[IntentRefs('sca:confidentiality')]";
        str = normalize(str, "sca");
        // Test the rewrite of xpath so that the self:node() is passed into the SCA function
        XPathExpression exp = xpath.compile(str);
        Object result = exp.evaluate(xml, XPathConstants.NODESET);
        Assert.assertTrue(result instanceof NodeList);
        NodeList nodes = (NodeList)result;
        Assert.assertEquals(1, nodes.getLength());
    }
   
View Full Code Here

        InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
        String str = " //sca:composite/sca:component[sca:IntentRefs('sca:confidentiality')]";
        str = normalize(str, "sca");
        // Test the rewrite of xpath so that the self:node() is passed into the SCA function
        XPathExpression exp = xpath.compile(str);
        Object result = exp.evaluate(xml, XPathConstants.NODESET);
        Assert.assertTrue(result instanceof NodeList);
        NodeList nodes = (NodeList)result;
        Assert.assertEquals(1, nodes.getLength());
    }
   
View Full Code Here

        InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
        String str = "   IntentRefs('sca:confidentiality')  ";
        str = normalize(str, "sca");
        // Test the rewrite of xpath so that the self:node() is passed into the SCA function
        XPathExpression exp = xpath.compile(str);
        Object result = exp.evaluate(xml, XPathConstants.NODESET);
        Assert.assertTrue(result instanceof NodeList);
        NodeList nodes = (NodeList)result;
        Assert.assertEquals(1, nodes.getLength());
    }
    @Test
View Full Code Here

    }
    @Test
    public void testURIRef() throws Exception {
        InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
        XPathExpression exp = xpath.compile(normalize("sca:composite/sca:component[sca:URIRef('AddServiceComponent')]","sca"));
        Object result = exp.evaluate(xml, XPathConstants.NODESET);
        Assert.assertTrue(result instanceof NodeList);
        NodeList nodes = (NodeList)result;
        // Assert.assertEquals(1, nodes.getLength());
    }
   
View Full Code Here

   
    @Test
    public void testInterfaceRef() throws Exception {
        InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
        XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:service[sca:InterfaceRef('AddService')]","sca"));
        Object result = exp.evaluate(xml, XPathConstants.NODESET);
        Assert.assertTrue(result instanceof NodeList);
        NodeList nodes = (NodeList)result;
        // Assert.assertEquals(1, nodes.getLength());
    }
View Full Code Here

    @Test
    public void testOperationRef() throws Exception {
        InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
        XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:reference[sca:OperationRef('AddService/add')]","sca"));
        Object result = exp.evaluate(xml, XPathConstants.NODESET);
        Assert.assertTrue(result instanceof NodeList);
        NodeList nodes = (NodeList)result;
        // Assert.assertEquals(1, nodes.getLength());
    }
View Full Code Here

    private static void addAlwaysApplicablePolicySets(PolicySet policySet,
                                                      Document doc,
                                                      int prefixCount) throws XPathExpressionException {
        XPathExpression expression = policySet.getAlwaysAppliesToXPathExpression();
        NodeList result = (NodeList)expression.evaluate(doc, XPathConstants.NODESET);

        if (result != null) {
            for (int counter = 0; counter < result.getLength(); ++counter) {
                Node aResultNode = result.item(counter);
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.