Package org.jaxen.dom

Examples of org.jaxen.dom.DOMXPath


    public void testNamespaceNodesComeBeforeAttributeNodesInDocumentOrder() throws JaxenException {
       
        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
        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


  
    }

    public void testJaxen97() throws JaxenException {
        // jaxen 97 claims this expression throws an exception.
        new DOMXPath("/aaa:element/text()");
    }
View Full Code Here

        doc.appendChild(root);
        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

        org.w3c.dom.Element a = doc.createElementNS("http://www.a.com/", "a:foo");
        doc.appendChild(a);
        Element b = doc.createElementNS("http://www.b.com/", "b:bar");
        a.appendChild(b);
       
        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());
  
    }
View Full Code Here

        assertEquals(1, result.size());
  
    }
   
    public void testSelectNodesReturnsANonNodeSet() throws JaxenException {
        XPath xpath = new DOMXPath("1 + 2 + 3");
        List result = xpath.selectNodes(doc);
        assertEquals(1, result.size());
    }
View Full Code Here

        org.w3c.dom.Element a = doc.createElementNS("http://www.a.com/", "a:foo");
        doc.appendChild(a);
        Text b = doc.createTextNode("ready");
        a.appendChild(b);
       
        XPath xpath = new DOMXPath("..");
        List result = (List) xpath.evaluate(b);
        assertEquals(1, result.size());
        assertEquals(a, result.get(0));
  
    }
View Full Code Here

        org.w3c.dom.Element a = doc.createElementNS("http://www.a.com/", "a:foo");
        doc.appendChild(a);
        Text b = doc.createTextNode("ready");
        a.appendChild(b);
       
        XPath xpath = new DOMXPath("..");
        try {
            xpath.evaluate("String");
            fail("Allowed String as context");
        }
        catch (ClassCastException ex) {
            // success
        }
View Full Code Here

   
   
    // JAXEN-206
    public void testMismatchedDepthsInContext()
      throws JaxenException {
        XPath xpath = new DOMXPath("parent::*");
        org.w3c.dom.Element z = doc.createElementNS("", "z");
        doc.appendChild(z);
        org.w3c.dom.Element a = doc.createElementNS("", "a");
        z.appendChild(a);
        org.w3c.dom.Element b = doc.createElementNS("", "b");
        a.appendChild(b);
        org.w3c.dom.Element c = doc.createElementNS("", "c");
        z.appendChild(c);

        List context = new ArrayList();
        context.add(b);
        context.add(c);
        List result = xpath.selectNodes(context);
        assertEquals(z, result.get(0));
    }
View Full Code Here

    }
   

    public void testConstruction() throws JaxenException
    {
        DOMXPath xpath = new DOMXPath( "/foo/bar/baz" );
        assertEquals("/foo/bar/baz", xpath.toString());
    }
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.