Examples of DOMXPath


Examples of org.jaxen.dom.DOMXPath

    }   
   
   
    public void testPrecedingSiblingAxisIsInDocumentOrder() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("preceding-sibling::*");
        org.w3c.dom.Element root = doc.createElementNS("", "root");
        doc.appendChild(root);
        org.w3c.dom.Element child1 = doc.createElementNS("", "child1");
        root.appendChild(child1);
        org.w3c.dom.Element child2 = doc.createElementNS("", "child2");
        root.appendChild(child2);
        org.w3c.dom.Element child3 = doc.createElementNS("", "child3");
        root.appendChild(child3);
       
        List result = xpath.selectNodes(child3);
        assertEquals(2, result.size());
        assertEquals(child1, result.get(0));  
        assertEquals(child2, result.get(1));
       
    }   
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }   
   
   
    public void testPrecedingAxisIsInDocumentOrder() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("preceding::*");
        org.w3c.dom.Element root = doc.createElementNS("", "root");
        doc.appendChild(root);
        org.w3c.dom.Element parent1 = doc.createElementNS("", "parent1");
        root.appendChild(parent1);
        org.w3c.dom.Element parent2 = doc.createElementNS("", "parent2");
        root.appendChild(parent2);
        org.w3c.dom.Element child1 = doc.createElementNS("", "child1");
        parent2.appendChild(child1);
        org.w3c.dom.Element child2 = doc.createElementNS("", "child2");
        parent2.appendChild(child2);
        org.w3c.dom.Element child3 = doc.createElementNS("", "child3");
        parent2.appendChild(child3);
       
        List result = xpath.selectNodes(child3);
        assertEquals(3, result.size());
        assertEquals(parent1, result.get(0));  
        assertEquals(child1, result.get(1));  
        assertEquals(child2, result.get(2));
       
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }   
   
   
    public void testPrecedingAxisWithPositionalPredicate() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("preceding::*[1]");
        org.w3c.dom.Element root = doc.createElementNS("", "root");
        doc.appendChild(root);
        org.w3c.dom.Element child1 = doc.createElementNS("", "child1");
        root.appendChild(child1);
        org.w3c.dom.Element child2 = doc.createElementNS("", "child2");
        root.appendChild(child2);
        org.w3c.dom.Element child3 = doc.createElementNS("", "child3");
        root.appendChild(child3);
       
        List result = xpath.selectNodes(child3);
        assertEquals(1, result.size())
        assertEquals(child2, result.get(0));
       
    }   
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }   
   
   
    public void testAncestorAxisWithPositionalPredicate() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("ancestor::*[1]");
        org.w3c.dom.Element root = doc.createElementNS("", "root");
        doc.appendChild(root);
        org.w3c.dom.Element child1 = doc.createElementNS("", "child1");
        root.appendChild(child1);
        org.w3c.dom.Element child2 = doc.createElementNS("", "child2");
        child1.appendChild(child2);
        org.w3c.dom.Element child3 = doc.createElementNS("", "child3");
        child2.appendChild(child3);
       
        List result = xpath.selectNodes(child3);
        assertEquals(1, result.size())
        assertEquals(child2, result.get(0));
       
    }   
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }   
   
   
    public void testAncestorOrSelfAxis() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("ancestor-or-self::*");
        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(3, result.size());
        assertEquals(root, result.get(0));  
        assertEquals(parent, result.get(1));
        assertEquals(child, result.get(2));
       
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

   
   
    // test case for JAXEN-55
    public void testAbbreviatedDoubleSlashAxis() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("//x");
        org.w3c.dom.Element a = doc.createElementNS("", "a");
        org.w3c.dom.Element b = doc.createElementNS("", "b");
        doc.appendChild(a);
        org.w3c.dom.Element x1 = doc.createElementNS("", "x");
        x1.appendChild(doc.createTextNode("1"));
        a.appendChild(x1);
        a.appendChild(b);
        org.w3c.dom.Element x2 = doc.createElementNS("", "x");
        org.w3c.dom.Element x3 = doc.createElementNS("", "x");
        org.w3c.dom.Element x4 = doc.createElementNS("", "x");
        a.appendChild(x4);
        b.appendChild(x2);
        b.appendChild(x3);
        x2.appendChild(doc.createTextNode("2"));
        x3.appendChild(doc.createTextNode("3"));
        x4.appendChild(doc.createTextNode("4"));
       
        List result = xpath.selectNodes(doc);
        assertEquals(4, result.size());
        assertEquals(x1, result.get(0));  
        assertEquals(x2, result.get(1));  
        assertEquals(x3, result.get(2));  
        assertEquals(x4, result.get(3));
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

   
   
    // test case for JAXEN-55
    public void testAncestorFollowedByChildren() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/a/b/x/ancestor::*/child::x");
        org.w3c.dom.Element a = doc.createElementNS("", "a");
        org.w3c.dom.Element b = doc.createElementNS("", "b");
        doc.appendChild(a);
        org.w3c.dom.Element x1 = doc.createElementNS("", "x");
        x1.appendChild(doc.createTextNode("1"));
        a.appendChild(x1);
        a.appendChild(b);
        org.w3c.dom.Element x2 = doc.createElementNS("", "x");
        org.w3c.dom.Element x3 = doc.createElementNS("", "x");
        org.w3c.dom.Element x4 = doc.createElementNS("", "x");
        a.appendChild(x4);
        b.appendChild(x2);
        b.appendChild(x3);
        x2.appendChild(doc.createTextNode("2"));
        x3.appendChild(doc.createTextNode("3"));
        x4.appendChild(doc.createTextNode("4"));
       
        List result = xpath.selectNodes(doc);
        assertEquals(4, result.size());
        assertEquals(x1, result.get(0));  
        assertEquals(x2, result.get(1));  
        assertEquals(x3, result.get(2));  
        assertEquals(x4, result.get(3));
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

   
   
    // test case for JAXEN-55
    public void testDescendantAxis() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/descendant::x");
        org.w3c.dom.Element a = doc.createElementNS("", "a");
        org.w3c.dom.Element b = doc.createElementNS("", "b");
        doc.appendChild(a);
        org.w3c.dom.Element x1 = doc.createElementNS("", "x");
        x1.appendChild(doc.createTextNode("1"));
        a.appendChild(x1);
        a.appendChild(b);
        org.w3c.dom.Element x2 = doc.createElementNS("", "x");
        org.w3c.dom.Element x3 = doc.createElementNS("", "x");
        org.w3c.dom.Element x4 = doc.createElementNS("", "x");
        a.appendChild(x4);
        b.appendChild(x2);
        b.appendChild(x3);
        x2.appendChild(doc.createTextNode("2"));
        x3.appendChild(doc.createTextNode("3"));
        x4.appendChild(doc.createTextNode("4"));
       
        List result = xpath.selectNodes(doc);
        assertEquals(4, result.size());
        assertEquals(x1, result.get(0));  
        assertEquals(x2, result.get(1));  
        assertEquals(x3, result.get(2));  
        assertEquals(x4, result.get(3));
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

       
    }   
   
    public void testDescendantAxisWithAttributes() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/descendant::x/@*");
        org.w3c.dom.Element a = doc.createElementNS("", "a");
        org.w3c.dom.Element b = doc.createElementNS("", "b");
        doc.appendChild(a);
        org.w3c.dom.Element x1 = doc.createElementNS("", "x");
        a.appendChild(x1);
        a.appendChild(b);
        org.w3c.dom.Element x2 = doc.createElementNS("", "x");
        org.w3c.dom.Element x3 = doc.createElementNS("", "x");
        org.w3c.dom.Element x4 = doc.createElementNS("", "x");
        a.appendChild(x4);
        b.appendChild(x2);
        b.appendChild(x3);
       
        Attr a1 = doc.createAttribute("name");
        a1.setNodeValue("1");
        x1.setAttributeNode(a1);
        Attr a2 = doc.createAttribute("name");
        a2.setNodeValue("2");
        x2.setAttributeNode(a2);
        Attr a3 = doc.createAttribute("name");
        a3.setNodeValue("3");
        x3.setAttributeNode(a3);
        Attr a4 = doc.createAttribute("name");
        a4.setNodeValue("4");
        x4.setAttributeNode(a4);
       
        List result = xpath.selectNodes(doc);
        assertEquals(4, result.size());
        assertEquals(a1, result.get(0));  
        assertEquals(a2, result.get(1));  
        assertEquals(a3, result.get(2));  
        assertEquals(a4, result.get(3));
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

       
    }   
   
    public void testDescendantAxisWithNamespaceNodes() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/descendant::x/namespace::node()");
        org.w3c.dom.Element a = doc.createElementNS("", "a");
        org.w3c.dom.Element b = doc.createElementNS("", "b");
        doc.appendChild(a);
        org.w3c.dom.Element x1 = doc.createElementNS("", "x");
        a.appendChild(x1);
        a.appendChild(b);
        org.w3c.dom.Element x2 = doc.createElementNS("", "x");
        org.w3c.dom.Element x3 = doc.createElementNS("", "x");
        org.w3c.dom.Element x4 = doc.createElementNS("", "x");
        a.appendChild(x4);
        b.appendChild(x2);
        b.appendChild(x3);
       
        Attr a1 = doc.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:a");
        a1.setNodeValue("http://www.example.org/");
        x1.setAttributeNode(a1);
        Attr a2 = doc.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:b");
        a2.setNodeValue("http://www.example.org/");
        x2.setAttributeNode(a2);
        Attr a3 = doc.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:c");
        a3.setNodeValue("http://www.example.org/");
        x3.setAttributeNode(a3);
        Attr a4 = doc.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:d");
        a4.setNodeValue("http://www.example.org/");
        x4.setAttributeNode(a4);
       
        List result = xpath.selectNodes(doc);
        assertEquals(8, result.size());
        Iterator iterator = result.iterator();
        StringBuffer sb = new StringBuffer(4);
        while (iterator.hasNext()) {
            NamespaceNode ns = (NamespaceNode) iterator.next();
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.