Package nu.xom

Examples of nu.xom.XPathContext


    }
   
   
    public void testCantRebindXMLPrefix() {
       
        XPathContext context = new XPathContext();
        try {
            context.addNamespace("xml", "http://www.example.org");
            fail("Rebound xml prefix");
        }
        catch (NamespaceConflictException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here


    }
   

    public void testCantBindNonPrefix() {
       
        XPathContext context = new XPathContext();
        try {
            context.addNamespace("foo:bar", "http://www.example.org");
            fail("Allowed preix with colon");
        }
        catch (IllegalNameException success) {
            assertNotNull(success.getMessage());
        }
       
        try {
            context.addNamespace("foo bar", "http://www.example.org");
            fail("Allowed preix with space");
        }
        catch (IllegalNameException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

       
    }
   

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

        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

       
        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

   
   
    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

   
   
    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

   
   
    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

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

       
        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

TOP

Related Classes of nu.xom.XPathContext

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.