Package nu.xom

Examples of nu.xom.Node


    }
   
   
    public void testCompareXMLBaseAttributes() {
    
        Node a1 = new Attribute("xml:base", Namespace.XML_NAMESPACE, "value.xml");
        Node a2 = new Attribute("xml:base", Namespace.XML_NAMESPACE, "./value.xml");
        assertEquals(a1, a2);
       
    }
View Full Code Here


    private static boolean hasAdjacentTextNodes(Element element) {

        boolean previousWasText = false;
        int count = element.getChildCount();
        for (int i = 0; i < count; i++) {
            Node child = element.getChild(i);
            if (child instanceof Text) {
                if (previousWasText) return true;
                else previousWasText = true;
            }
            else {
View Full Code Here

        int count = expectedCopy.getChildCount();
        assertEquals(message, count, actualCopy.getChildCount());
        int nonTextNodes = count;
        for (int i = 0; i < count; i++) {
            Node child1 = expectedCopy.getChild(i);
            // could remove this instanceof Test by having combineTextNodes
            // set a list of text indices
            if (child1 instanceof Text) {
                nonTextNodes--;
                Node child2 = actualCopy.getChild(i);
                assertEquals(message, child1, child2);
            }
        }
       
        // now compare everything that isn't text using the original
        // element objects
        for (int i = 0; i < nonTextNodes; i++) {
            Node expectedChild = getNonTextNode(expected, i);
            Node actualChild = getNonTextNode(actual, i);
            assertEquals(message, expectedChild, actualChild);
        }
       
    }
View Full Code Here

    private static Node getNonTextNode(Element element, int index) {

        int nonTextCount = 0;
        int count = element.getChildCount();
        for (int i = 0; i < count; i++) {
            Node child = element.getChild(i);
            if (! (child instanceof Text) ) {
                if (nonTextCount == index) return child;
                nonTextCount++;
            }
        }
View Full Code Here

        Element stub = new Element("a");
        Comment stubc = new Comment("c");
        StringBuffer sb = new StringBuffer();
        int count = element.getChildCount();
        for (int i = 0; i < count; i++) {
            Node child = element.getChild(i);
            if (child instanceof Text) {
                sb.setLength(0);
                do {
                    sb.append(child.getValue());
                    i++;
                    if (i == count) {
                        break;
                    }
                    child = element.getChild(i);
View Full Code Here

        assertEquals(message,
          expected.getChildCount(),
          actual.getChildCount()
        );
        for (int i = 0; i < actual.getChildCount(); i++) {
            Node child1 = expected.getChild(i);
            Node child2 = actual.getChild(i);
            assertEquals(message, child1, child2);
        }

    }
View Full Code Here

        int length = 10;
        for (int i = 0; i < length; i++) {
            nodes.append(new Text(String.valueOf(i)));  
        }    
       
        Node result = nodes.remove(0);
        assertEquals(length-1, nodes.size());
        assertEquals("0", result.getValue());
       
        for (int i = 0; i < nodes.size(); i++) {
            assertEquals(String.valueOf(i+1), nodes.get(i).getValue());  
       
        nodes.remove(nodes.size()-1);
View Full Code Here

            for (; position < parent.getChildCount(); position++) {
                if (parent.getChild(position) == element) break;
            }
            parent.removeChild(position);
            while (element.getChildCount() > 0) {
                Node child = element.getChild(0);
                element.removeChild(0);
                parent.insertChild(child, position);
                position++;
                if (child instanceof Element) strip((Element) child);
            }    
View Full Code Here

public class CommentReader {

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

        Element root = doc.getRootElement();
        assertEquals(5, root.getChildCount());
        assertEquals("datadatadatadatadata", root.getValue());
        Element middle = (Element) root.getChild(2);
        assertEquals("data", middle.getValue());
        Node start = root.getChild(0);
        Node end = root.getChild(4);
        assertEquals("data", start.getValue());
        assertEquals("data", end.getValue());     
       
    }
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.