Package com.volantis.mcs.dom

Examples of com.volantis.mcs.dom.Node


            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


     * Removes any text that has been in lined in
     * @param dom The DOMOutputBuffer.
     */
    private void removeInlineText(DOMOutputBuffer dom) {
        Element element = dom.getCurrentElement();
        Node child = element.getHead();

        StringBuffer content = new StringBuffer();
        for (child = element.getHead(); child!=null; child = child.getNext()) {
            if (child instanceof Text) {
                Text text = (Text)child;
                content.append(text.getContents(), 0, text.getLength());
            }
        }
View Full Code Here

    // Javadoc inherited
    public void insert(Element element, StyleValue value) {
        this.parent = element;
        // store the original nodes
        originalNodes = new LinkedList();
        Node node = parent.getHead();
        while (node != null) {
            final Node next = node.getNext();
            node.remove();
            originalNodes.add(node);
            node = next;
        }
View Full Code Here

    public void insertPreservingExistingContent(Element element,
                                                StyleValue value) {
        this.parent = element;
        // store the original nodes
        originalNodes = new LinkedList();
        Node node = parent.getHead();
        while (node != null) {
            final Node next = node.getNext();
            originalNodes.add(node);
            node = next;
        }

        value.visit(this, null);
View Full Code Here

     */
    //javadoc inherited
    public void visit(StyleKeyword value, Object object) {
        if (value == StyleKeywords.CONTENTS) {
            for (Iterator iter = originalNodes.iterator(); iter.hasNext();) {
                final Node node = (Node) iter.next();
                node.addToTail(parent);
            }
            originalNodes.clear();
        }
    }
View Full Code Here

           
            // and if its name is null
            if (element.getName() == null) {
                // then remove it and add its children to its parent
                Element parent = element.getParent();
                final Node previous = element.getPrevious();
                if (previous != null) {
                    // it wasn't the first child, so add its children after
                    // the previous element
                    element.insertChildrenAfter(previous);
                } else {
View Full Code Here

                         + destinationLayout);
        }

        // Hack to add the mode to the first card.
        Element root = buffer.getRoot();
        Node node = root.getHead();
        if (node != null && node instanceof Element) {
            Element card = (Element) node;
            if ("card".equals(card.getName())) {
                card.setAttribute("mode", "#" + destinationLayout);
            }
View Full Code Here

     *
     * @param parent The {@link Element} whose children we wish to purge of
     * {@link Text} which contain only whitespace characters
     */
    protected void removeWhitespaceChildren(Element parent) {
        Node node = parent.getHead();
        while (node != null) {
            // Store a reference to the next sibling to assign to node at the
            // end of the loop as the current node may be discarded.
            Node next = node.getNext();

            if (isWhitespaceTextNode(node)) {
                // First we will remove it from the parent.
                node.remove();
            }
View Full Code Here

     *
     * @param form
     */
    private void includeNeighbourInlineElements(Element form) {

        Node nextNode;

        for (Node node = form.getPrevious(); node != null; node = nextNode) {
            if (checkCorrectInlineNode(node, form)) {
                nextNode = node.getPrevious();
                node.remove();
View Full Code Here

        if ((parent.getHead() != table) || (parent.getTail() != table)) {
            removeWhitespaceChildren(parent);
        }

        if ((parent.getHead() != table) || (parent.getTail() != table)) {
            Node child = parent.getHead();
            boolean previousNotTable = false;

            StylingFactory factory = StylingFactory.getDefaultInstance();
            Styles parentStyles = parent.getStyles();
            Styles tableStyles;
            if (parentStyles == null) {
               // This may occur if we are dealing with custom markup
                tableStyles = factory.createStyles (null);
                if (logger.isDebugEnabled ()) {
                    logger.debug("Encountered null styles on parent element "
                            + parent.getName ());
                }
            } else {
                tableStyles = factory.createInheritedStyles(parentStyles,
                        DisplayKeywords.TABLE);
            }
            newTable = allocateElement();
            newTable.setName(elementHelper.getTable());
            newTable.setStyles(tableStyles);
            newTable.setAttribute(OptimizationConstants.OPTIMIZATION_ATTRIBUTE,
                                  OptimizationConstants.OPTIMIZE_ALWAYS);

            while (child != null) {
                // Allocate a new row/cell within the new table to receive
                // the current td's first available child

                Styles rowStyles = factory.createInheritedStyles(tableStyles,
                        DisplayKeywords.TABLE_ROW);
                Element newRow = allocateElement();
                newRow.setName(elementHelper.getRow());
                newRow.setStyles(rowStyles);

                Styles cellStyles = factory.createInheritedStyles(rowStyles,
                        DisplayKeywords.TABLE_CELL);
                Element newCell = allocateElement();
                newCell.setName(elementHelper.getCell());
                newCell.setStyles(cellStyles);

                newTable.addTail(newRow);
                newRow.addTail(newCell);

                // Remove the child from its old parent then add it into the
                // new cell
                child.remove();
                newCell.addTail(child);
                previousNotTable = !elementHelper.isTable(child);
                child = parent.getHead();

                while ((child != null) &&
                       previousNotTable &&
                       !elementHelper.isTable(child)) {
                    // Concatenate all sequential non-table children together
                    // within the same row/cell
                    child.remove();
                    newCell.addTail(child);
                    child = parent.getHead();
                }
            }
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.