Package nu.xom

Examples of nu.xom.Document.query()


        Element child2 = new Element("pre:child", "http://www.example.com/");
        parent.appendChild(child1);
        parent.appendChild(child2);
        grandparent.appendChild(parent);
       
        Nodes result = doc.query("descendant::*[name(.)='pre:child']");
        assertEquals(2, result.size());
        assertEquals(child1, result.get(0));  
        assertEquals(child2, result.get(1));
       
    }
View Full Code Here


        child2.appendChild("bar");
        parent.appendChild(child1);
        parent.appendChild(child2);
        grandparent.appendChild(parent);
       
        Nodes result = doc.query("descendant::*[.='foo']");
        assertEquals(1, result.size());
        assertEquals(child1, result.get(0));
       
    }
   
View Full Code Here

        Element child = new Element("child");
        root.appendChild(child);
        Attribute id = new Attribute("id", "p2");
        child.addAttribute(id);
        id.setNamespace("xml", "http://www.w3.org/XML/1998/namespace");
        Nodes result = doc.query("id('p2')");
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));
       
    }
   
View Full Code Here

            return;
        }
       
        try {
            Document input = builder.build(args[0]);
            Nodes result = input.query(args[1]);
            for (int i = 0; i < result.size(); i++) {
                // ???? add a wrap option like Saxon
                // or based on the XQuery serialization format?
                System.out.println(result.get(i).toXML());
            }
View Full Code Here

        String expected = " a1=\"v1\" a2=\"v2\"";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
       
        Document doc = new Document(pdu);
        canonicalizer.write(doc.query("//@*"))
       
        byte[] result = out.toByteArray();
        out.close();
        String s = new String(out.toByteArray(), "UTF8");
        assertEquals(expected, s);
View Full Code Here

        String expected = " a1=\"v1\" a2=\"v2\"";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
       
        Document doc = new Document(pdu);
        Nodes subset = doc.query("//@*");
        subset.append(a1);
        subset.append(a2);
        canonicalizer.write(subset)
       
        byte[] result = out.toByteArray();
View Full Code Here

        String expected = " xmlns=\"http://www.example.com\"";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
       
        Document doc = new Document(pdu);
        canonicalizer.write(doc.query("//namespace::node()"))
       
        byte[] result = out.toByteArray();
        out.close();
        String s = new String(out.toByteArray(), "UTF8");
        assertEquals(expected, s);
View Full Code Here

        String expected = " xmlns:pre=\"http://www.example.com\"";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
       
        Document doc = new Document(pdu);
        canonicalizer.write(doc.query("//namespace::node()"))
       
        byte[] result = out.toByteArray();
        out.close();
        String s = new String(out.toByteArray(), "UTF8");
        assertEquals(expected, s);
View Full Code Here

       
        String expected = "<!--comment 1-->\n<!--comment 2-->\n\n<!--comment 3-->\n<!--comment 4-->";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
       
        canonicalizer.write(doc.query("//comment()"))
       
        byte[] result = out.toByteArray();
        out.close();
        String s = new String(out.toByteArray(), "UTF8");
        assertEquals(expected, s);
View Full Code Here

        String expected = " a2=\"v1\" a1=\"v2\"";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
       
        Document doc = new Document(pdu);
        canonicalizer.write(doc.query("//@*"))
       
        byte[] result = out.toByteArray();
        out.close();
        String s = new String(out.toByteArray(), "UTF8");
        assertEquals(expected, s);
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.