Package nu.xom

Examples of nu.xom.Node


            }           
        }
        else {
            ParentNode parent = (ParentNode) parents.get(parents.size()-1);
            for (int i = 0; i < nodes.size(); i++) {
                Node node = nodes.get(i);
                if (node instanceof Attribute) {
                    ((Element) parent).addAttribute((Attribute) node);
                }
                else {
                    parent.appendChild(node);
View Full Code Here


        Element originalRoot = doc.getRootElement();
        Element root = copy(originalRoot, null);
        Document copy = new Document(root);
        copy.setBaseURI(doc.getBaseURI());
        for (int i = 0; i < doc.getChildCount(); i++) {
            Node child = doc.getChild(i);
            if (child == originalRoot) continue;
            Node node = copy(child);
            copy.insertChild(node, i);
        }
        return copy;
       
    }
View Full Code Here

        // Weird; need to find just the additional namespaces????
        /* for (int i = original.getNamespaceDeclarationCount()-1; i >= 0; i--) {
             copy.addNamespaceDeclaration(original.);
        } */
        for (int i = 0; i < original.getChildCount(); i++) {
            Node child = original.getChild(i);
            if (child instanceof Element) {
                copy((Element) child, copy);
            }
            else {
                Node node = copy(child);
                copy.appendChild(node);
            }
        }
        return copy;
       
View Full Code Here

        Element originalRoot = doc.getRootElement();
        Element root = copy(originalRoot);
        Document copy = new Document(root);
        copy.setBaseURI(doc.getBaseURI());
        for (int i = 0; i < doc.getChildCount(); i++) {
            Node child = doc.getChild(i);
            if (child == originalRoot) continue;
            Node node = copy(child);
            copy.insertChild(node, i);
        }
        return copy;
       
    }
View Full Code Here

        // Weird; need to find just the additional namespaces????
        /* for (int i = original.getNamespaceDeclarationCount()-1; i >= 0; i--) {
             copy.addNamespaceDeclaration(original.);
        } */
        for (int i = 0; i < original.getChildCount(); i++) {
            Node node = copy(original.getChild(i));
            copy.appendChild(node);
        }
        return copy;
       
    }
View Full Code Here

   
    public static void merge(ParentNode parent) {
       
        for (int i = 0; i < parent.getChildCount(); i++) {
            Node child = parent.getChild(i);
            if (child instanceof Text) {
                StringBuffer sb = new StringBuffer(child.getValue());
                Node nextChild;
                while ((nextChild = parent.getChild(i+1)) instanceof Text) {
                    sb.append(nextChild.getValue());
                    parent.removeChild(nextChild);
                    if (i+1 == parent.getChildCount()) break;
                }
                if (sb.length() == 0) parent.removeChild(child);
                else parent.replaceChild(child, new Text(sb.toString()));
View Full Code Here

            Element tr = new Element("tr", XHTML_NAMESPACE);
            Element td = new Element("td", XHTML_NAMESPACE);
            td.addAttribute(new Attribute("colspan", "2"));
            tr.appendChild(td);
            while (element.getChildCount() > 0) {
                Node child = element.removeChild(0);
                td.appendChild(child);  
            }
            table.appendChild(tr);
           
            Attribute href = element.getAttribute("role", XLINK_NAMESPACE);
View Full Code Here

public class ProcessingInstructionLister {

    public static void list(Node node) {
       
        for (int i = 0; i < node.getChildCount(); i++) {          
            Node child = node.getChild(i);
            if (child instanceof ProcessingInstruction) {
                System.out.println(child.toXML());
            }
            else {
                list(child);  
            }
        }
View Full Code Here

       
        empty.replaceChild(old1, new1);
        empty.replaceChild(old3, new3);
        empty.replaceChild(old2, new2);

        Node current1 = empty.getChild(0);
        Node current2 = empty.getChild(1);
        Node current3 = empty.getChild(2);
       
        assertEquals(new1, current1);
        assertEquals(new2, current2);
        assertEquals(new3, current3);
       
View Full Code Here

            else if (xpath.indexOf("id(") >= 0) continue;
            Nodes result = input.query(xpath);
            Element answer = query.getFirstChildElement("answer");
            Nodes expected = new Nodes();
            for (int j = 0; j < answer.getChildCount(); j++) {
                Node node = answer.getChild(j);
                if (node instanceof Text) {
                    if (!("".equals(node.getValue().trim()))) {
                        expected.append(node);
                    }
                }
                else {
                    expected.append(node);
                }
            }
            assertEquals("Failed query " + id, expected.size(), result.size());
            for (int j = 0; j < result.size(); j++) {
                Node expectedNode = expected.get(j);
                Node actualNode = result.get(j);               
                assertEquals(id + " " + expectedNode.toXML() + " " + actualNode.toXML(), expectedNode, actualNode);
            }
        }
       
    }
View Full Code Here

TOP

Related Classes of nu.xom.Node

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.