Examples of XPathContext


Examples of nu.xom.XPathContext

        assertEquals("http://www.example.org", url);
    }
   

    public void testLookupNonexistentPrefix() {
        XPathContext context = new XPathContext();
        context.addNamespace("foo", "http://www.example.org");
        String url = context.lookup("bar");
        assertNull(url);
    }
View Full Code Here

Examples of nu.xom.XPathContext

       
        Element parent = new Element("Test", "http://www.example.org");
        Element child = new Element("child", "http://www.example.org");
        parent.appendChild(child);
       
        XPathContext context = new XPathContext("pre", "http://www.example.org");
        Nodes result = parent.query("child::pre:child", context);
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));  
       
    }
View Full Code Here

Examples of nu.xom.XPathContext

   
   
    public void testNamespaceQueryWithNullPrefix() {
       
        try {
            XPathContext context = new XPathContext("pre", "http://www.example.org");
            context.addNamespace(null, "http://www.w3.org");
            fail("Allowed null prefix");
        }
        catch (NullPointerException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

Examples of nu.xom.XPathContext

   
   
    public void testNamespaceQueryWithNullPrefix2() {
       
        try {
            new XPathContext(null, "http://www.example.org");
            fail("Allowed null prefix");
        }
        catch (NullPointerException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

Examples of nu.xom.XPathContext

   
   
    public void testNamespaceQueryWithEmptyPrefix() {
       
        try {
            XPathContext context = new XPathContext("pre", "http://www.example.org");
            context.addNamespace("", "http://www.w3.org");
        }
        catch (NamespaceConflictException success) {
            assertTrue(success.getMessage().length() > 1);
        }
       
View Full Code Here

Examples of nu.xom.XPathContext

   
   
    public void testNamespaceQueryWithEmptyPrefix2() {
       
        try {
            new XPathContext("", "http://www.example.org");
        }
        catch (NamespaceConflictException success) {
            assertTrue(success.getMessage().length() > 1);
        }
       
View Full Code Here

Examples of nu.xom.XPathContext

       
        Element parent = new Element("Test", "http://www.example.org");
        Element child = new Element("child", "http://www.example.org");
        parent.appendChild(child);
       
        XPathContext context = new XPathContext("pre", null);
        try {
            parent.query("child::pre:child", context);
            fail("Allowed null URI");
        }
        catch (XPathException success) {
View Full Code Here

Examples of nu.xom.XPathContext

       
        Element parent = new Element("Test", "http://www.example.org");
        Element child = new Element("child", "http://www.example.org");
        parent.appendChild(child);
       
        XPathContext context = new XPathContext("pre", "");
        try {
            parent.query("child::pre:child", context);
            fail("Allowed empty string as namespace URI");
        }
        catch (XPathException success) {
View Full Code Here

Examples of nu.xom.XPathContext

       
        Element parent = new Element("Test", "http://www.example.org");
        Element child = new Element("child", "http://www.example.org");
        parent.appendChild(child);
       
        XPathContext context = new XPathContext("pre", "http://www.example.com");
        Nodes result = parent.query("child::pre:child", context);
        assertEquals(0, result.size());
       
        context.addNamespace("pre", "http://www.example.org");
        result = parent.query("child::pre:child", context);
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));  
       
    }
View Full Code Here

Examples of nu.xom.XPathContext

       
        Element parent = new Element("Test", "http://www.example.org");
        Element child = new Element("child", "http://www.example.org");
        parent.appendChild(child);
       
        XPathContext context = new XPathContext("not", "http://www.example.com");
        try {
            parent.query("child::pre:child", context);
            fail("Queried with unbound prefix");
        }
        catch (XPathException success) {
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.