Package com.volantis.mcs.dom

Examples of com.volantis.mcs.dom.Node


            return;
        }

        // Make sure that the node being replaced is not in the sequence as
        // that would corrupt the DOM.
        Node end = s.getEnd();
        for (NodeImpl node = first; node != end; node = node.next) {
            if (this == node) {
                throw new IllegalStateException(
                        "Cannot replace node with sequence containing node");
            }
View Full Code Here


            // Do the pre-processing.
            convertDivideHintToKeepTogether(element);

            // Iterate recursively through the children of this element.
            Node child = element.getHead();
            while (child != null) {
                iterateBefore(child);
                child = child.getNext();
            }
        }
    }
View Full Code Here

    private Node iterateAfter(Node node) {
        if (node instanceof Element) {
            Element element = (Element) node;

            // Iterate recursively through the children of this element.
            Node child = element.getHead();
            while (child != null) {
                child = iterateAfter(child);
                child = child.getNext();
            }

            // Now that we have rendered any child logical block elements into
            // <p> and <br> we can know where the <p>s are and can emulate
            // their styles appropriately. As an optimisation we only need to
View Full Code Here

            // a zero length piece of text and a dividehint (which would be
            // converted into another keep together.
            boolean validChild = false;
            while (!validChild) {
                // Get the next node.
                Node next = element.getNext();

                if (next != null) {
                    if (next instanceof Text) {
                        Text text = (Text) next;

                        // If the next node is a piece of zero length text, we
                        // remove it and surround the following node with the
                        // keeptogether element.
                        if (text.getLength() == 0) {
                            next = text.getNext();
                            text.remove();
                            // Get the next node
                            continue;
                        }
                    }

                    if (next instanceof Element) {
                        // Deal with consecutive dividehints e.g.
                        // <dividehint/><dividehint/><p>.....</p>
                        Element element2 = (Element) next;
                        if (DIVIDE_HINT_ELEMENT.equals(element2.getName())) {
                            element2.remove();
                            // Get the next node
                            continue;
                        }
                    }

                    // Remove the node from the current list.
                    next.remove();
                    // Add it back as a child of the keeptogether element.
                    element.addHead(next);
                }

                // We've found and moved a valid child of keeptogether or
View Full Code Here

        return current;
    }

    private void removeTrailingLineBreak(Element element) {
        Node tail = element.getTail();
        if (tail instanceof Element) {
            Element tailElement = (Element) tail;
            if ("br".equals(tailElement.getName())) {
                tailElement.remove();
            }
View Full Code Here

    }

    private void transformChildren(
            Element element) {

        Node next;
        Node child = element.getHead();
        for (; child != null; child = next) {
            next = child.getNext();
            transformNode(child);
        }
    }
View Full Code Here

                    } else if (dissectingPane != null) {
                        pane.setName(VDXMLConstants.DISSECT_TEXT_ELEMENT);

                        // Juggle fake dissection elements
                        Element parent = pane.getParent();
                        Node children = parent.getHead();
                        while (children != null) {
                            if (children instanceof Element) {
                                Element element = (Element) children;
                                if (element.getName().equals(VDXMLConstants.
                                           PSEUDO_DISSECTION_CONTENT)) {
                                    // Copy contents across
                                    element.addChildrenToHead(pane);
                                    break;
                                }
                            } else {
                                children = children.getNext();
                            }
                        }
                        pane.replace(parent);

                        // Any navigs found elsehwere within this page forces
View Full Code Here

        if (node == null) {
            return null;
        } else if (node == stop) {
            if (node instanceof Element) {
                Element element = (Element) node;
                Node next = element.getHead();
                if (next instanceof Element) {
                    Element nextElement = (Element) next;
                    if (KEEPTOGETHER_ELEMENT.equals(nextElement.getName())) {
                        return getRealNode(nextElement.getHead());
                    }
                }
                return next;
            } else {
                return null;
            }
        }

        if (node instanceof Element) {
            Element element = (Element) node;
            if (KEEPTOGETHER_ELEMENT.equals(element.getName())) {
                return getRealNode(element.getHead());
            }
        }

        Node next = node.getNext();
        if (next == null) {
            Node parent = node.getParent();
            if (parent != null) {
                if (parent.equals(stop)) {
                    return null;
                } else {
                    return getRealNode(parent.getNext());
                }
            } else {
                return null;
            }
        } else if (next instanceof Element) {
View Full Code Here

     *
     * @param element The Element whose child td tags to remove.
     */
    private void removeChildTableCells(Element element) {

        Node next;
        for (Node node = element.getHead(); node != null; node = next) {
            next = node.getNext();

            if (node instanceof Element &&
                    "td".equals(((Element) node).getName())) {
View Full Code Here

        // we cannot allow <td> children to be separated by <br>
        // tags - though descendents further down must not have this
        // restriction. Also, we must be careful with tds that appear nested
        // since they might become unnested. If you change this code be sure
        // to check that the unit tests still work.
        Node currentSibling = tableElement.getHead();
        Node lastSibling = tableElement.getTail();
        tableElement.insertChildrenAfter(tableElement);
        tableElement.remove();
        boolean done = false;
        while (!done) {
            if (currentSibling == lastSibling) {
                done = true;
            }
            Node nextSibling = currentSibling.getNext();
            if (currentSibling instanceof Element) {
                Element currentSiblingElement =
                        (Element) currentSibling;
                if (currentSiblingElement.getName().equals("tr")) {
                    currentSiblingElement.setName(WMLConstants.BLOCH_ELEMENT);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.dom.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.