Package nu.xom

Examples of nu.xom.Node


                // need to sort these into specific order
                list.append(a);
            }
        }
        for (int i = 0; i < element.getChildCount(); i++) {
            Node child = element.getChild(i);
            if (child instanceof Element) {
                getIDs((Element) child, list);
            }
        }
       
View Full Code Here



    public void testCopyisNotACDATASection() {
       
        Text c1 = new Text("test");
        Node c2 = c1.copy();
        assertEquals(Text.class, c2.getClass());

    }
View Full Code Here

        Document doc = builder.build(data, "http://www.example.org/");
        Element root = doc.getRootElement();
        assertEquals("Skipped comment interrupted text node",
          2, root.getChildCount());
        assertEquals("18", doc.getValue());
        Node first = root.getChild(0);
        assertEquals(first.getValue(), "1");       
        Node second = root.getChild(1);
        assertEquals(second.getValue(), "8");  
       
    }
View Full Code Here

        assertEquals(
          "Skipped processing instruction interrupted text node",
          2, root.getChildCount()
        );
        assertEquals("18", doc.getValue());
        Node first = root.getChild(0);
        assertEquals(first.getValue(), "1");       
        Node second = root.getChild(1);
        assertEquals(second.getValue(), "8");  

    }
View Full Code Here

        Builder builder = new Builder(new BFilter());
        Document doc = builder.build(data, "http://www.example.org/");
        Element root = doc.getRootElement();
        assertEquals("1234innermost5678", doc.getValue());
        assertEquals(5, root.getChildCount());
        Node first = root.getChild(0);
        assertEquals("1", first.getValue());
        Node middle = root.getChild(2);
        assertEquals("34innermost56", middle.getValue());
        Node last = root.getChild(4);
        assertEquals("8", last.getValue());
       
        Node innermost = middle.getChild(2);
        assertEquals("innermost", innermost.getValue());
        Node inner1 = middle.getChild(0);
        assertEquals("3", inner1.getValue());
        Node inner3 = middle.getChild(4);
        assertEquals("6", inner3.getValue());
       
    }
View Full Code Here

    // XXX remove recursion
    // recursively descend through document; in document
    // order, and add results as they are found
    private Nodes sort(Nodes in) {

        Node root = in.get(0).getDocument();
        if (in.size() > 1) {
            Nodes out = new Nodes();
            List list = new ArrayList(in.size());
            List namespaces = new ArrayList();
            for (int i = 0; i < in.size(); i++) {
                Node node = in.get(i);
                list.add(node);
                if (node instanceof Namespace) namespaces.add(node);
            }
            sort(list, namespaces, out, (ParentNode) root);
            if (! list.isEmpty() ) {
                // Are these just duplicates; or is there really a node
                // from a different document?
                Iterator iterator = list.iterator();
                while (iterator.hasNext()) {
                    Node next = (Node) iterator.next();
                    if (root != next.getDocument()) {
                        throw new CanonicalizationException(
                          "Cannot canonicalize subsets that contain nodes from more than one document");
                    }
                }
            }
View Full Code Here

            // if (in.isEmpty()) return;
        }
       
        int childCount = parent.getChildCount();
        for (int i = 0; i < childCount; i++) {
            Node child = parent.getChild(i);
            if (child instanceof Element) {
                Element element = (Element) child;
                if (in.contains(element)) {
                    out.append(element);
                    in.remove(element);
View Full Code Here

                Element child = makeElement((org.w3c.dom.Element) current);
                parent.appendChild(child);
                if (current.hasChildNodes()) parent = child;
            }
            else {
                Node child = convert(current);
                parent.appendChild(child);
            }
           
        }
       
View Full Code Here

         = impl.createDocument(rootNamespace, rootName, domDOCTYPE);
        org.w3c.dom.Element domRoot = domDoc.getDocumentElement();
       
        boolean beforeRoot = true;
        for (int i = 0; i < document.getChildCount(); i++) {
            Node original = document.getChild(i);
            // Need to test positioning of doctype
            if (original instanceof DocType) continue;
            else if (original instanceof Element) {
                convert((Element) original, domDoc);
                beforeRoot = false;  
View Full Code Here

    private static org.w3c.dom.Element convert(
      Element xomElement, org.w3c.dom.Document document) {
       
        org.w3c.dom.Element domResult = makeElement(xomElement, document);
        org.w3c.dom.Node domParent = domResult;
        Node xomCurrent = xomElement;
        int index = 0;
        int[] indexes = new int[10];
        int top = 0;
        indexes[0] = 0;
        boolean end = false;
        while (true) {
           
            if (!end && xomCurrent.getChildCount() > 0) {
               xomCurrent = xomCurrent.getChild(0);
               index = 0;
               top++;
               indexes = grow(indexes, top);
               indexes[top] = 0;
            }
            else {
                end = false;
                ParentNode xomParent = xomCurrent.getParent();
                org.w3c.dom.Node grandparent = domParent.getParentNode();
                if (grandparent.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE
                  && xomCurrent instanceof Element) {
                    domParent = grandparent;
                }
                if (xomParent.getChildCount() - 1 == index) {
                    xomCurrent = xomParent;
                    top--;
                    if (xomCurrent == xomElement) break;
                    ParentNode tp = xomCurrent.getParent();
                    if (tp == null) break;
                    index = indexes[top];
                    end = true;
                    continue;
                }
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.