You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by "K. W. Landry" <kw...@gmail.com> on 2006/11/23 23:05:51 UTC

Removing Nodes Error

Folks,
A little help please,

I've tried every iteration of "removing DOM node" I can find, they all fail.
Can someone give me a pointer in the right direction and/or help me
understand the error message? Which I have to say,  regardless of my pesent
level of understanding, seems a bit cryptic; more sage minds than mine can
correct me on that point.

Thanks,

The code in question follows:

            SVGOMDocument sd = (SVGOMDocument)ad;
            Element svgRoot = sd.getDocumentElement();

//        Get rid of the previous Graph

            Node rn = sd.getElementById("BarChart"); //.getParentNode();
//            while(rn.hasChildNodes()){
                sd.removeChild(rn);
//            }
            rn = sd.getElementById("dropshadow"); //.getParentNode();
//                while(rn.hasChildNodes()){
                    sd.removeChild(rn);
//            }

            if(sd.getElementById("dropshadow")!=null) sd.removeChild(
d.getElementById("dropshadow"));
            if(sd.getElementById("BarChart")  !=null) sd.removeChild(
d.getElementById("BarChart"));

//            Import the new document's parent node to the svg root element
by
//             building the import node off the original document and then
appending the import node.
            Node n = sd.importNode(d.getElementById("dropshadow"), true);


And the error produced: "The child node (type: 1, name: g) is missing."

Caused by: org.w3c.dom.DOMException: The child node (type: 1, name: g) is
missing.
    at org.apache.batik.dom.AbstractNode.createDOMException(Unknown Source)
    at org.apache.batik.dom.AbstractParentNode.removeChild(Unknown Source)
    at
com.bluepearlsystems.Client.Controller.RateReturnSlide.DOMAttrModified(
RateReturnSlide.java:96)
    ... 33 more

Re: Removing Nodes Error

Posted by "K. W. Landry" <kw...@gmail.com>.
Thomas,

Thanks, I would have bet the ranch that I had tried that combination as I
remember the pattern from a previous email in the batik archive, but, in any
case, the code snip you provided,

        rn.getParentNode().removeChild(rn);

now deletes the node appropriately,

Thanks again,

KWL


On 11/26/06, thomas.deweese@kodak.com <th...@kodak.com> wrote:
>
> Hi K.W.
>
> "K. W. Landry" <kw...@gmail.com> wrote on 11/23/2006 05:05:51 PM:
>
> > I've tried every iteration of "removing DOM node" I can find, they all
> fail.
>
>    I think your basic problem is that you are trying to remove a node
> from a node that is not it's parent:
>
> >             SVGOMDocument sd = (SVGOMDocument)ad;
> >             Node rn = sd.getElementById("BarChart"); //.getParentNode();
> >             sd.removeChild(rn);
>
>     The last line should probably be:
>         rn.getParentNode().removeChild(rn);
>
> > And the error produced: "The child node (type: 1, name: g) is missing."
>
>     Yes, the node 'rn' is missing from the child node list of 'sd'.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Re: Removing Nodes Error

Posted by th...@kodak.com.
Hi K.W.

"K. W. Landry" <kw...@gmail.com> wrote on 11/23/2006 05:05:51 PM:

> I've tried every iteration of "removing DOM node" I can find, they all 
fail. 

   I think your basic problem is that you are trying to remove a node
from a node that is not it's parent:

>             SVGOMDocument sd = (SVGOMDocument)ad;
>             Node rn = sd.getElementById("BarChart"); //.getParentNode();
>             sd.removeChild(rn);

    The last line should probably be:
        rn.getParentNode().removeChild(rn);

> And the error produced: "The child node (type: 1, name: g) is missing."

    Yes, the node 'rn' is missing from the child node list of 'sd'.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org