Package org.jaxen.dom

Examples of org.jaxen.dom.DOMXPath.selectNodes()


        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


        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

      throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/b/c");
        org.w3c.dom.Element a = doc.createElementNS("", "a");
        doc.appendChild(a);
        List result = xpath.selectNodes(doc);
        assertTrue(! xpath.booleanValueOf(result));
       
    }
   
    public void testAddNamespaceWithNonSimpleNamespaceContext() throws JaxenException {
View Full Code Here

        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());
        assertEquals(a, result.get(0));  
        assertEquals(x1, result.get(1));  
        assertEquals(b, result.get(2));  
        assertEquals(x2, result.get(3));  
View Full Code Here

       
        org.w3c.dom.Element root = doc.createElementNS("http://www.example.org", "pre:b");
        doc.appendChild(root);
        root.setAttribute("name", "value");
        XPath xpath = new DOMXPath("/*/attribute::* | /*/namespace::node()");
        List result = xpath.selectNodes(doc);
        assertTrue(((org.w3c.dom.Node) result.get(0)).getNodeType() == Pattern.NAMESPACE_NODE);
        assertTrue(((org.w3c.dom.Node) result.get(1)).getNodeType() == Pattern.NAMESPACE_NODE);
        assertTrue(((org.w3c.dom.Node) result.get(2)).getNodeType() == Node.ATTRIBUTE_NODE);
       
        // now flip the order of the statement and retest
View Full Code Here

        assertTrue(((org.w3c.dom.Node) result.get(1)).getNodeType() == Pattern.NAMESPACE_NODE);
        assertTrue(((org.w3c.dom.Node) result.get(2)).getNodeType() == Node.ATTRIBUTE_NODE);
       
        // now flip the order of the statement and retest
        xpath = new DOMXPath("/*/namespace::node() | /*/attribute::* ");
        result = xpath.selectNodes(doc);
        assertTrue(((org.w3c.dom.Node) result.get(0)).getNodeType() == Pattern.NAMESPACE_NODE);
        assertTrue(((org.w3c.dom.Node) result.get(1)).getNodeType() == Pattern.NAMESPACE_NODE);
        assertTrue(((org.w3c.dom.Node) result.get(2)).getNodeType() == Node.ATTRIBUTE_NODE);
  
    }
View Full Code Here

        root.setAttribute("name", "value");
        Element child = doc.createElementNS("http://www.example.org", "pre:child");
        root.appendChild(child);
       
        XPath xpath = new DOMXPath("/*/*/namespace::node() | //attribute::* ");
        List result = xpath.selectNodes(doc);
        assertEquals(3, result.size());
        assertTrue(((org.w3c.dom.Node) result.get(0)).getNodeType() == Node.ATTRIBUTE_NODE);
        assertTrue(((org.w3c.dom.Node) result.get(1)).getNodeType() == Pattern.NAMESPACE_NODE);
  
    }
View Full Code Here

        XPath xpath = new DOMXPath("/a:foo/b:bar/namespace::*/parent::*");
        SimpleNamespaceContext context1 = new SimpleNamespaceContext();
        context1.addNamespace("a", "http://www.a.com/");
        context1.addNamespace("b", "http://www.b.com/");
        xpath.setNamespaceContext(context1);
        List result = xpath.selectNodes(doc);
        assertEquals(1, result.size());
        assertEquals(b, result.get(0));
  
    }
   
View Full Code Here

   
    public void testJaxen107FromFile() throws JaxenException, SAXException, IOException {
       
        doc = builder.parse(new File("xml/testNamespaces.xml"));
        XPath xpath = new DOMXPath("/Template/Application2/namespace::*/parent::*");
        List result = xpath.selectNodes(doc);
        assertEquals(1, result.size());
  
    }
   
    public void testSelectNodesReturnsANonNodeSet() throws JaxenException {
View Full Code Here

  
    }
   
    public void testSelectNodesReturnsANonNodeSet() throws JaxenException {
        XPath xpath = new DOMXPath("1 + 2 + 3");
        List result = xpath.selectNodes(doc);
        assertEquals(1, result.size());
    }
   
    public void testNonElementContextNode() throws JaxenException {
       
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.