Examples of DOMXPath


Examples of org.jaxen.dom.DOMXPath

            assertCountXPath(221, context, "//*");
            assertCountXPath(20, context, "//*[local-name()='article']");
            assertCountXPath(20, context, "//article");
            assertCountXPath(20, context, "/*/*[@code]");
            assertCountXPath(1, context, "/moreovernews/article[@code='13563275']");
                DOMXPath xpath = new DOMXPath("/moreovernews/article[@code='13563275']");
                List results = xpath.selectNodes(getContext(context));
                Object result = results.get(0);
                assertValueOfXPath("http://c.moreover.com/click/here.pl?x13563273", result, "url");
            xpath = new DOMXPath("/*/article[@code='13563275']");
            results = xpath.selectNodes(getContext(context));
            result = results.get(0);
                assertValueOfXPath("http://c.moreover.com/click/here.pl?x13563273", result, "url");
            xpath = new DOMXPath("//article[@code='13563275']");
            results = xpath.selectNodes(getContext(context));
            result = results.get(0);
                assertValueOfXPath("http://c.moreover.com/click/here.pl?x13563273", result, "url");
            xpath = new DOMXPath("//*[@code='13563275']");
            results = xpath.selectNodes(getContext(context));
            result = results.get(0);
                assertValueOfXPath("http://c.moreover.com/click/here.pl?x13563273", result, "url");
            xpath = new DOMXPath("/child::node()/child::node()[@code='13563275']");
            results = xpath.selectNodes(getContext(context));
            result = results.get(0);
                assertValueOfXPath("http://c.moreover.com/click/here.pl?x13563273", result, "url");
            xpath = new DOMXPath("/*/*[@code='13563275']");
            results = xpath.selectNodes(getContext(context));
            result = results.get(0);
                assertValueOfXPath("http://c.moreover.com/click/here.pl?x13563273", result, "url");
            }
            }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

       
    }
   
    public void testSelectSingleNodeForContext() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("1 + 2");
       
        String stringValue = xpath.stringValueOf(xpath);
        assertEquals("3", stringValue);
       
        Number numberValue = xpath.numberValueOf(xpath);
        assertEquals(3, numberValue.doubleValue(), 0.00001);
       
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

            a
                img
            a        <- return that node
                img   <- select this node
        */
        XPath xpath = new DOMXPath("(/html/a/img[contains(@src,'gif')])[2]/..");
        org.w3c.dom.Element html = doc.createElementNS("", "html");
        org.w3c.dom.Element a1 = doc.createElementNS("", "a");
        org.w3c.dom.Element a2 = doc.createElementNS("", "a");
        org.w3c.dom.Element img1 = doc.createElementNS("", "img");
          org.w3c.dom.Attr img1_src = doc.createAttributeNS("", "src");
        img1_src.setValue("1.gif");
        org.w3c.dom.Element img2 = doc.createElementNS("", "img");
        org.w3c.dom.Attr img2_src = doc.createAttributeNS("", "src");
        img2_src.setValue("2.gif");

        img1.setAttributeNode(img1_src);
        img2.setAttributeNode(img2_src);
        a1.appendChild(img1);
        a2.appendChild(img2);
        html.appendChild(a1);
        html.appendChild(a2);
        doc.appendChild(html);

        List result = xpath.selectNodes(doc);
        assertEquals(1, result.size());
        assertEquals(a2, result.get(0));
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

   
   
    public void testEvaluateString() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("string(/*)");
       
        doc.appendChild(doc.createElement("root"));
        String stringValue = (String) xpath.evaluate(doc);
        assertEquals("", stringValue);
       
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }
   
   
    public void testNumberValueOfEmptyNodeSetIsNaN() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/x");
       
        doc.appendChild(doc.createElement("root"));
        Double numberValue = (Double) xpath.numberValueOf(doc);
        assertTrue(numberValue.isNaN());
       
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }
   
   
    public void testPathWithParentheses() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("(/root)/child");
       
        Element root = doc.createElement("root");
        doc.appendChild(root);
        Element child = doc.createElement("child");
        root.appendChild(child);
       
        assertEquals(child, xpath.selectSingleNode(doc));
       
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }
   
   
    public void testEvaluateWithMultiNodeAnswer() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("(/descendant-or-self::node())");
       
        doc.appendChild(doc.createElement("root"));
        List result = (List) xpath.evaluate(doc);
        assertEquals(2, result.size());
       
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }
   
   
    public void testValueOfEmptyListIsEmptyString() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/element");
        doc.appendChild(doc.createElement("root"));
       
        String stringValue = xpath.stringValueOf(doc);
        assertEquals("", stringValue);
       
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

       
    }

    public void testAllNodesQuery() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("//. | /");
        org.w3c.dom.Element root = doc.createElementNS("http://www.example.org/", "root");
        doc.appendChild(root);
       
        String stringValue = xpath.stringValueOf(doc);
        assertEquals("", stringValue);
       
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }

   
    public void testAncestorAxis() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("ancestor::*");
        org.w3c.dom.Element root = doc.createElementNS("", "root");
        org.w3c.dom.Element parent = doc.createElementNS("", "parent");
        doc.appendChild(root);
        org.w3c.dom.Element child = doc.createElementNS("", "child");
        root.appendChild(parent);
        parent.appendChild(child);
       
        List result = xpath.selectNodes(child);
        assertEquals(2, result.size());
        assertEquals(root, result.get(0));  
        assertEquals(parent, result.get(1));
       
    }   
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.