You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Lyle Coder <x_...@hotmail.com> on 2001/04/13 22:39:48 UTC

How do I swap nodes in Xalan???

All I want to do is swap a child (C) with it's parent (P).... In the
process, the children of the child node (C) become the children of (P), and
children of (p) become children of (C).  It would have been nice if I could
just SET the tag name and attributes, but since I cant do a setName, I have
to go through these hoops.  It still doesent work

What am I doing wrong?

XalanNode *dom_bubble(XalanNode *node)
{
    XalanNode *child = node;
    XalanNode *childDup = node->cloneNode(false);
    node = node->getParent();
    XalanNode *parent = node;
    XalanNode *parentDup = node->cloneNode(false);
    node = node->getParent;


    node->replaceChild(childDup, parent);
    while (parent->getFirstChild()) {
        XalanNode *temp = parent->removeChild(parent->getFirstChild());
        if (temp == child)
            continue;
        childDup->appendChild(temp->cloneNode(true));
    }
    childDup->appendChild(parentDup);
    while (child->getFirstChild()) {
        XalanNode *temp = child->removeChild(child->getFirstChild());
        parentDup->appendChild(temp->cloneNode(true));
    }

    return childDup;
}


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org