Package nu.xom

Examples of nu.xom.Namespace


       
        Element parent = new Element("Test", "http://www.example.org");
       
        Nodes result = parent.query("namespace::*");
        assertEquals(2, result.size());
        Namespace n1 = (Namespace) result.get(0);
        Namespace n2 = (Namespace) result.get(1);
        assertTrue(n1.getPrefix().equals("") || n2.getPrefix().equals(""));
        assertTrue(n1.getPrefix().equals("xml") || n2.getPrefix().equals("xml"));
        assertTrue(n1.getValue().equals("http://www.example.org")
          || n2.getValue().equals("http://www.example.org"));
        assertTrue(n1.getValue().equals(Namespace.XML_NAMESPACE)
          || n2.getValue().equals(Namespace.XML_NAMESPACE));
       
    }
View Full Code Here


        String xpath = "(/*/* | /*/*/namespace::*)\n";
        Nodes result = doc.query(xpath);
        assertEquals(4, result.size());
        Element parent = (Element) result.get(0);
        for (int i = 1; i < 4; i++) {
            Namespace namespace = (Namespace) result.get(i);
            assertEquals(parent, namespace.getParent());
        }
       
    }
View Full Code Here

       
        Element parent = new Element("Test", "http://www.example.org");
       
        Nodes result = parent.query("namespace::*");
        assertEquals(2, result.size());
        Namespace n1 = (Namespace) result.get(0);
        Namespace n2 = (Namespace) result.get(1);
        assertTrue(n1.getPrefix().equals("") || n2.getPrefix().equals(""));
        assertTrue(n1.getPrefix().equals("xml") || n2.getPrefix().equals("xml"));
        assertTrue(n1.getValue().equals("http://www.example.org")
          || n2.getValue().equals("http://www.example.org"));
        assertTrue(n1.getValue().equals(Namespace.XML_NAMESPACE)
          || n2.getValue().equals(Namespace.XML_NAMESPACE));
       
    }
View Full Code Here

        String xpath = "(/*/* | /*/*/namespace::*)\n";
        Nodes result = doc.query(xpath);
        assertEquals(4, result.size());
        Element parent = (Element) result.get(0);
        for (int i = 1; i < 4; i++) {
            Namespace namespace = (Namespace) result.get(i);
            assertEquals(parent, namespace.getParent());
        }
       
    }
View Full Code Here

       
    }
   
   
    public void testNamespaceEqualsItself() {
        Namespace ns = new Namespace("pre", "http://www.example.org", null);
        assertEquals(ns, ns);
    }
View Full Code Here

    public void testGetters() {
    
        Element root = new Element("pre:root", "http://www.example.org/");
        Nodes result = root.query("namespace::pre");
        assertEquals(1, result.size());
        Namespace namespace = (Namespace) result.get(0);
        assertEquals("pre", namespace.getPrefix());
        assertEquals("http://www.example.org/", namespace.getValue());
        assertEquals(root, namespace.getParent());
       
    }
View Full Code Here

    public void testCopy() {
    
        Element root = new Element("pre:root", "http://www.example.org/");
        Nodes result = root.query("namespace::pre");
        assertEquals(1, result.size());
        Namespace namespace = (Namespace) result.get(0);
       
        Namespace copy = (Namespace) namespace.copy();
        assertEquals(namespace, copy);
        assertEquals("pre", copy.getPrefix());
        assertEquals("http://www.example.org/", copy.getValue());
        assertEquals(null, copy.getParent());
       
    }
View Full Code Here

   
    public void testToXML() {
    
        Element root = new Element("pre:root", "http://www.example.org/");
        Nodes result = root.query("namespace::pre");
        Namespace namespace = (Namespace) result.get(0);
        assertEquals("xmlns:pre=\"http://www.example.org/\"", namespace.toXML());
       
    }
View Full Code Here

   
    public void testGetChildCount() {
    
        Element root = new Element("pre:root", "http://www.example.org/");
        Nodes result = root.query("namespace::pre");
        Namespace namespace = (Namespace) result.get(0);
        assertEquals(0, namespace.getChildCount());
       
    }
View Full Code Here

   
    public void testGetChild() {
    
        Element root = new Element("pre:root", "http://www.example.org/");
        Nodes result = root.query("namespace::pre");
        Namespace namespace = (Namespace) result.get(0);
        try {
            namespace.getChild(0);
            fail("Got namespace child");
        }
        catch (IndexOutOfBoundsException success) {
            assertEquals("Namespaces do not have children", success.getMessage());
        }
View Full Code Here

TOP

Related Classes of nu.xom.Namespace

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.