Package nu.xom

Examples of nu.xom.Element.query()


   
     public void testContextSizeForParaentlessNodeIs1() {
     
         Element root = new Element("html");
        
         Nodes result = root.query("self::*[last()=1]");
         assertEquals(1, result.size());
         assertEquals(root, result.get(0));
        
     }
   
View Full Code Here


         Element child2 = new Element("child2");
         root.appendChild(child1);
         root.appendChild(child2);
         new Document(root);
        
         Nodes result = child2.query("self::*[position()=last()]");
         assertEquals(1, result.size());
         assertEquals(child2, result.get(0));
        
     }
    
View Full Code Here

    public void testAttributeWithUnderscore() {
    
        Element a = new Element("a");
        Attribute foo = new Attribute("_foo", "bar");
        a.addAttribute(foo);
        Nodes results = a.query("//@_foo");
        assertEquals(1, results.size());
        assertEquals(foo, results.get(0));
       
    }
   
View Full Code Here

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

   
    public void testCanonicalizeNamespace() throws IOException {
    
        Element element = new Element("pre:foo", "http://www.example.org");
        Nodes namespaces = element.query("namespace::pre");
        Namespace ns = (Namespace) namespaces.get(0);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(ns);
View Full Code Here

   
    public void testCanonicalizeDefaultNamespace() throws IOException {
    
        Element element = new Element("foo", "http://www.example.org");
        Nodes namespaces = element.query("namespace::*");
        Namespace ns = (Namespace) namespaces.get(0);
        if (ns.getPrefix().equals("xml")) ns = (Namespace) namespaces.get(1);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
View Full Code Here

   
    public void testCanonicalizeXMLNamespace() throws IOException {
    
        Element element = new Element("foo");
        Nodes namespaces = element.query("namespace::*");
        Namespace ns = (Namespace) namespaces.get(0);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(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);
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

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.