Package org.jaxen.dom

Examples of org.jaxen.dom.DOMXPath


       
    }   
   
    public void testMultipleAttributesOnElement() 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);
       
        Attr a1 = doc.createAttribute("name1");
        a1.setNodeValue("1");
        x1.setAttributeNode(a1);
        Attr a2 = doc.createAttribute("name2");
        a2.setNodeValue("2");
        x1.setAttributeNode(a2);
        Attr a3 = doc.createAttribute("name3");
        a3.setNodeValue("3");
        x1.setAttributeNode(a3);
        Attr a4 = doc.createAttribute("name4");
        a4.setNodeValue("4");
        x1.setAttributeNode(a4);
       
        List result = xpath.selectNodes(doc);
        assertEquals(4, result.size());
        assertTrue(result.contains(a1));
        assertTrue(result.contains(a2));
        assertTrue(result.contains(a3));
        assertTrue(result.contains(a4));
View Full Code Here


        root.setAttributeNodeNS(p1);
       
        org.w3c.dom.Element child = doc.createElement("child312");
        root.appendChild(child);
       
        BaseXPath xpath = new DOMXPath("ancestor::*/@xml:*");
        List result = xpath.selectNodes(child);
        assertEquals(2, result.size());
        assertEquals(p0, result.get(0));
        assertEquals(p1, result.get(1));
       
    }
View Full Code Here

       
    }
   
    public void testDescendantAxisWithAttributesAndChildren() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/descendant::x/@* | /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(8, result.size());
        assertEquals(x1, result.get(0));  
        assertEquals(a1, result.get(1));  
        assertEquals(x2, result.get(2));  
        assertEquals(a2, result.get(3));
View Full Code Here

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

    }   
   
    // test for Jaxen-83
    public void testPrincipalNodeTypeOfSelfAxisIsElement() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("child/@*[self::test]");
        org.w3c.dom.Element a = doc.createElementNS("", "child");
        org.w3c.dom.Attr test = doc.createAttributeNS("", "test");
        test.setValue("value");
        a.setAttributeNode(test);
        doc.appendChild(a);
       
        List result = xpath.selectNodes(doc);
        assertEquals(0, result.size());
       
    }
View Full Code Here

    }
   
    // test to make sure Jaxen-83 fix doesn't go too far
    public void testSelfAxisWithNodeTestCanReturnNonPrincipalNodeType() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("child/@*[self::node()]");
        org.w3c.dom.Element a = doc.createElementNS("", "child");
        org.w3c.dom.Attr test = doc.createAttributeNS("", "test");
        test.setValue("value");
        a.setAttributeNode(test);
        doc.appendChild(a);
       
        List result = xpath.selectNodes(doc);
        assertEquals(1, result.size());  
       
    }
View Full Code Here

   
    // another Jaxen-55 test to try to pin down exactly what does
    // and doesn't work
    public void testDescendantOrSelfAxis() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/descendant-or-self::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

    }   
   
   
    public void testDuplicateNodes() 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(6, result.size());
       
    }   
View Full Code Here

       
    }   
      
    public void testUnionOfNodesWithNonNodes() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("count(//*) | //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"));
       
        try {
            xpath.selectNodes(doc);
            fail("Allowed union with non-node-set");
        }
        catch (JaxenException ex) {
            assertNotNull(ex.getMessage());
        }
View Full Code Here

       
    }   
   
    public void testUnionOfEmptyNodeSetWithNonNodes() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("//y | count(//*)");
        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");
        b.appendChild(x2);
        x2.appendChild(doc.createTextNode("2"));
       
        try {
            xpath.selectNodes(doc);
            fail("Allowed union with non-node-set");
        }
        catch (JaxenException ex) {
            assertNotNull(ex.getMessage());
        }
View Full Code Here

TOP

Related Classes of org.jaxen.dom.DOMXPath

Copyright © 2018 www.massapicom. 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.