Package org.jaxen.dom

Examples of org.jaxen.dom.DOMXPath


    }
   
    public void testSelectSingleNodeSelectsNothing()
      throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("id('p1')");
        org.w3c.dom.Element a = doc.createElementNS("", "a");
        doc.appendChild(a);
        Object result = xpath.selectSingleNode(doc);
        assertNull(result);
       
   
View Full Code Here


       
        System.setProperty( XPathReaderFactory.DRIVER_PROPERTY,
                            "java.lang.String" );
       
        try {
            new DOMXPath("id('p1')");
        }
        catch (JaxenException e) {
            assertNotNull(e.getMessage());
        }
        finally {
View Full Code Here

   
   
    public void testBooleanValueOfEmptyNodeSetIsFalse()
      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));
       
    }
View Full Code Here

       
    }
   
    public void testAddNamespaceWithNonSimpleNamespaceContext() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/b/c");
        xpath.setNamespaceContext(new NamespaceContext() {

            public String translateNamespacePrefixToUri(String prefix) {
                return prefix;
            }
           
        });
        try {
            xpath.addNamespace("pre", "foo");           
            fail("Added namespace");
        }
        catch (JaxenException ex) {
            assertNotNull(ex.getMessage());
        }
View Full Code Here

        }
       
    }
   
    public void testDebug() throws JaxenException {
        BaseXPath xpath = new DOMXPath("/b/c");
        assertEquals(
          "[(DefaultXPath): [(DefaultAbsoluteLocationPath): [(DefaultNameStep): b]/[(DefaultNameStep): c]]]",
          xpath.debug()
        );
       
    }
View Full Code Here

        );
       
    }
   
    public void testGetRootExpr() throws JaxenException {
        BaseXPath xpath = new DOMXPath("/b/c");
        assertTrue(xpath.getRootExpr() instanceof org.jaxen.expr.LocationPath);
    }
View Full Code Here

        assertTrue(xpath.getRootExpr() instanceof org.jaxen.expr.LocationPath);
    }
   
    public void testUnionUsesDocumentOrder() throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("/descendant::x | /a | /a/b");
        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());
        assertEquals(a, result.get(0));  
        assertEquals(x1, result.get(1));  
        assertEquals(b, result.get(2));  
        assertEquals(x2, result.get(3));  
View Full Code Here

        assertEquals(x4, result.get(5));
       
    }
   
    public void testArithmeticAssociativity() throws JaxenException {
        XPath xpath = new DOMXPath("2+1-1+1");
        Double result = (Double) xpath.evaluate(doc);
        assertEquals(3, result.intValue());
    }
View Full Code Here

        Double result = (Double) xpath.evaluate(doc);
        assertEquals(3, result.intValue());
    }
   
    public void testLogicalAssociativity() throws JaxenException {
        XPath xpath = new DOMXPath("false() or true() and true() and false()");
        Boolean result = (Boolean) xpath.evaluate(doc);
        assertFalse(result.booleanValue());
    }
View Full Code Here

        Boolean result = (Boolean) xpath.evaluate(doc);
        assertFalse(result.booleanValue());
    }
   
    public void testRelationalAssociativity3() throws JaxenException {
        XPath xpath = new DOMXPath("3 > 2 > 1");
        Boolean result = (Boolean) xpath.evaluate(doc);
        assertFalse(result.booleanValue());
    }
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.